add
This commit is contained in:
73
Assets/trCRM/Scripts/ui/MyInputReset.cs
Normal file
73
Assets/trCRM/Scripts/ui/MyInputReset.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
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 = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user