public void OnDestroy() { if (dispatcher != null) { dispatcher.DispatchEvent(new InputEvents.MoveEvent(Vector2.zero)); } if (SceneRefs.IsSet <VirtualJoystick>() && SceneRefs.Get <VirtualJoystick>() == this) { SceneRefs.Remove(this); } }
private void Awake() { if (SceneRefs.IsSet <VirtualJoystick>()) { SceneRefs.Remove(SceneRefs.Get <VirtualJoystick>()); } SceneRefs.Set(this); joystick = GetComponent <RectTransform>(); joystickBase = base.transform.GetChild(0).GetComponent <RectTransform>(); joystickPad = base.transform.GetChild(0).GetChild(0).GetComponent <RectTransform>(); dispatcher = Service.Get <EventDispatcher>(); }