Инверсия зависимости в Unity3D С#
Ребята, хочу внедрить инверсию зависимости и вот не как голова не поймет как это сделать, туторы смотрю, а результат получается NullReference в строке: float x = _controllerService.GetAxisRowX();
public class Character : MonoBehaviour{
[SerializeField] Character _character;
private int speedForce = 10;
public IPlayerControllerService _controllerService;
public void Inject(IPlayerControllerService controllerService)
{_controllerService = controllerService;}
private void Update()
{
Move();
}
public void Move()
{
float x = _controllerService.GetAxisRowX();
float y = _controllerService.GetAxisRowY();
Debug.Log($"input keyboard {x}:{y}");
Vector3 newDirection = new Vector3(x, 0, y);
_character.transform.position = newDirection.normalized * speedForce * Time.deltaTime;
}
Источник: Stack Overflow на русском