You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
using AX.InputSystem; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
[RequireComponent(typeof(BaseGameObjInfo))] |
|
[RequireComponent(typeof(CreateStaticObjID))] |
|
[RequireComponent(typeof(Toggle))] |
|
public abstract class BaseToggle : MonoBehaviour { |
|
|
|
public virtual void OnEnable() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.AddListener(OnValueChanged); |
|
} |
|
|
|
public virtual void OnDisable() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.RemoveListener( OnValueChanged); |
|
} |
|
|
|
public virtual void OnDestroy() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.RemoveListener(OnValueChanged); |
|
} |
|
|
|
public void OnValueChanged(bool value) |
|
{ |
|
var arg = new UIToggleArgs(); |
|
arg.isOn = value; |
|
arg.currentCursorPos = Input.mousePosition; |
|
RegisterUIInputEvent.RegisterUIInputHistory(gameObject, this.GetType().Name, "ValueChanged", arg); |
|
RespondFun(value); |
|
} |
|
|
|
public void ValueChanged(CmdArgs arg) |
|
{ |
|
if (GameSettings.othersSettings.isReplayMode) |
|
{ |
|
if (!GameSettings.othersSettings.isReplayPause && !GameSettings.othersSettings.isReplayOver) |
|
{ |
|
CursorManager.GetInstance.SetClick(arg); |
|
} |
|
} |
|
GetComponent<Toggle>().isOn = ((UIToggleArgs)arg).isOn; |
|
} |
|
public abstract void RespondFun(bool value); |
|
}
|
|
|