Files
tianrunCRM/Assets/trCRM/Scripts/ui/MyInputReset.cs
2020-07-04 14:41:25 +08:00

74 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyInputReset : UIEventListener
{
public UIInput input;
private void Start()
{
if (input == null)
{
input = GetComponentInParent<UIInput>();
}
if (input != null)
{
EventDelegate newDel = new EventDelegate();
newDel.target = this;
newDel.methodName = "onInputChg";
input.onChange.Add(newDel);
onInputChg(input.gameObject);
}
}
bool _disabled = false;
public bool disabled
{
set
{
_disabled = value;
if (value)
{
gameObject.SetActive(false);
}
else
{
if (input != null)
{
onInputChg(input.gameObject);
}
}
}
get
{
return _disabled;
}
}
public void onInputChg(GameObject go)
{
if (disabled) return;
if (string.IsNullOrEmpty(input.value))
{
gameObject.SetActive(false);
}
else
{
gameObject.SetActive(true);
}
}
public void OnClick()
{
if (disabled) return;
if (input != null)
{
input.value = "";
}
}
}