Project_WL/Assets/Script/Util/NGUIButtonPress.cs

37 lines
759 B
C#
Raw Permalink Normal View History

2024-12-15 01:39:39 +00:00
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();
}
}
}
}