37 lines
759 B
C#
37 lines
759 B
C#
|
|
using System;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class NGUIButtonPress : MonoBehaviour
|
||
|
|
{
|
||
|
|
public bool AddDragScrollView = true;
|
||
|
|
|
||
|
|
Action m_act;
|
||
|
|
bool IsPress;
|
||
|
|
int tick = 5;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
UIEventListener.Get(gameObject).onPress = onPress;
|
||
|
|
if (AddDragScrollView) gameObject.AddComponent<UIDragScrollView>();
|
||
|
|
}
|
||
|
|
public void Set_Action(Action _act) { m_act = _act; }
|
||
|
|
|
||
|
|
private void onPress(GameObject go, bool state)
|
||
|
|
{
|
||
|
|
IsPress = state;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
if (IsPress)
|
||
|
|
{
|
||
|
|
--tick;
|
||
|
|
if (tick <= 0)
|
||
|
|
{
|
||
|
|
tick = 5;
|
||
|
|
m_act?.Invoke();
|
||
|
|
ServerInfo.Ins.ServerSave();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|