public static void RemoveInput(int index, Action action, MouseType type) { switch (type) { case MouseType.Down: obj.LateUpdate += () => { if (obj && obj.inputsMouseDown.ContainsKey(index)) { obj.inputsMouseDown[index] -= action; if (obj.inputsMouseDown[index] == null) { obj.inputsMouseDown.Remove(index); if (obj.inputsMouseDown.Count == 0) { GameEvent.RemoveEvent(obj.TOnUpdate_MouseDown, Method.Update); } } } }; break; case MouseType.Press: obj.LateUpdate += () => { if (obj && obj.inputsMousePress.ContainsKey(index)) { obj.inputsMousePress[index] -= action; if (obj.inputsMousePress[index] == null) { obj.inputsMousePress.Remove(index); if (obj.inputsMousePress.Count == 0) { GameEvent.RemoveEvent(obj.TOnUpdate_MousePress, Method.Update); } } } }; break; case MouseType.Up: obj.LateUpdate += () => { if (obj && obj.inputsMouseUp.ContainsKey(index)) { obj.inputsMouseUp[index] -= action; if (obj.inputsMouseUp[index] == null) { obj.inputsMouseUp.Remove(index); if (obj.inputsMouseUp.Count == 0) { GameEvent.RemoveEvent(obj.TOnUpdate_MouseUp, Method.Update); } } } }; break; } }
public static void RemoveInput(string name, Action <float> action) { if (obj && obj.inputs.ContainsKey(name)) { obj.inputs[name] -= action; if (obj.inputs[name] == null) { obj.inputs.Remove(name); if (obj.inputs.Count == 0) { GameEvent.RemoveEvent(obj.TOnUpdate, Method.Update); } } } }
private void OnDisable() { if (inputs.Count != 0) { GameEvent.RemoveEvent(TOnUpdate, Method.Update); } if (inputsMouseDown.Count != 0) { GameEvent.RemoveEvent(TOnUpdate_MouseDown, Method.Update); } if (inputsMousePress.Count != 0) { GameEvent.RemoveEvent(TOnUpdate_MousePress, Method.Update); } if (inputsMouseUp.Count != 0) { GameEvent.RemoveEvent(TOnUpdate_MouseUp, Method.Update); } GameEvent.RemoveEvent(LateUpdateMethod, Method.LateUpdate); }
private void OnDisable() { InputEvent.RemoveInput(InputDatas); GameEvent.RemoveEvent(EventDatas); EOnDisable(); }