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.
85 lines
2.1 KiB
85 lines
2.1 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.InputSystem;
|
||
|
|
||
|
[RequireComponent(typeof(BaseGameObjInfo))]
|
||
|
public class CloneButtonTest : Toggle
|
||
|
{
|
||
|
public CloneObjType cloneObjType;
|
||
|
// Use this for initialization
|
||
|
protected override void Start () {
|
||
|
base.Start();
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
|
||
|
protected override void OnEnable()
|
||
|
{
|
||
|
base.OnEnable();
|
||
|
//#if !UNITY_EDITOR
|
||
|
this.onValueChanged.AddListener(OnSelected);
|
||
|
//#endif
|
||
|
}
|
||
|
|
||
|
protected override void OnDisable()
|
||
|
{
|
||
|
base.OnDisable();
|
||
|
this.onValueChanged.RemoveListener(OnSelected);
|
||
|
}
|
||
|
|
||
|
protected override void OnDestroy()
|
||
|
{
|
||
|
base.OnDestroy();
|
||
|
this.onValueChanged.RemoveListener(OnSelected);
|
||
|
}
|
||
|
|
||
|
public void OnSelected(bool selected)
|
||
|
{
|
||
|
var arg = new CloneCmdArgs();
|
||
|
arg.cloneObjType = cloneObjType;
|
||
|
arg.selected = selected;
|
||
|
arg.currentCursorPos = Input.mousePosition;
|
||
|
|
||
|
Select(arg);
|
||
|
}
|
||
|
|
||
|
public void Select(CmdArgs arg)
|
||
|
{
|
||
|
if (((CloneCmdArgs)arg).selected)
|
||
|
{
|
||
|
transform.Find("Image").gameObject.SetActive(true);
|
||
|
InputManager.cloneObjType = cloneObjType;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
transform.Find("Image").gameObject.SetActive(false);
|
||
|
|
||
|
this.InstantClearState();
|
||
|
|
||
|
InputManager.cloneObjType = CloneObjType.None;
|
||
|
}
|
||
|
|
||
|
RegisterUIInputEvent.RegisterUIInputHistory(gameObject, this.GetType().Name, "Select", arg);
|
||
|
|
||
|
//if (GameSettings.othersSettings.isReplayMode)
|
||
|
//{
|
||
|
// if (!GameSettings.othersSettings.isReplayPause && !GameSettings.othersSettings.isReplayOver)
|
||
|
// {
|
||
|
// CursorManager.GetInstance.SetClick(arg);
|
||
|
// }
|
||
|
//}
|
||
|
if (GameSettings.othersSettings.playState != PlayState.None)
|
||
|
{
|
||
|
if (GameSettings.othersSettings.playState == PlayState.Playing)
|
||
|
{
|
||
|
CursorManager.GetInstance.SetClick(arg);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|