Zenject将monobehaviur对象传递给工厂

时间:2018-03-28 12:06:10

标签: c# unity3d dependency-injection zenject

我有一个Monobehaviour对象BaseUnit可以有一些状态,所以我创建了 州工厂,就像在Zenject示例项目中一样,但我的问题是当我为这个BaseUnit创建这个状态工厂时如何传递这个BaseUnit的引用?

public class UnitStateFactory
{
readonly UnitMoveState.Factory _moveState;
readonly UnitActiveState.Factory _activeState;
readonly BaseUnit _unit;

public UnitStateFactory(
     UnitMoveState.Factory mS,
     UnitActiveState.Factory aS,
     BaseUnit unit

     )
{

    _moveState = mS;
    _activeState = aS;
    _unit = unit;
    }
}

0 个答案:

没有答案