using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class AddPointBehaviour : MonoBehaviour
|
{
|
[SerializeField] int m_Property;
|
[SerializeField] Text m_PropertyName;
|
[SerializeField] Text m_PropertyValue;
|
[SerializeField] Text m_PropertyPreview;
|
[SerializeField] RectTransform m_PointBottom;
|
[SerializeField] Button m_Sub;
|
[SerializeField] Button m_Add;
|
|
public int property
|
{
|
get { return m_Property; }
|
}
|
|
public Text propertyName
|
{
|
get { return m_PropertyName; }
|
}
|
|
public Text propertyValue
|
{
|
get { return m_PropertyValue; }
|
}
|
|
public Text propertyPreview
|
{
|
get { return m_PropertyPreview; }
|
}
|
|
public RectTransform pointBottom
|
{
|
get
|
{
|
return m_PointBottom;
|
}
|
}
|
|
public Action<int> onPreview;
|
public Action<int, bool> onSub;
|
public Action<int, bool> onAdd;
|
|
private void Awake()
|
{
|
UIEventTrigger.Get(m_PropertyPreview.gameObject).OnNoParamsClick = () =>
|
{
|
if (onPreview != null)
|
{
|
onPreview(property);
|
}
|
};
|
UIEventTrigger.Get(m_Sub.gameObject).OnDown = OnSubDown;
|
UIEventTrigger.Get(m_Sub.gameObject).OnUp = OnSubUp;
|
UIEventTrigger.Get(m_Add.gameObject).OnDown = OnAddDown;
|
UIEventTrigger.Get(m_Add.gameObject).OnUp = OnAddUp;
|
}
|
|
private void OnAddUp(GameObject go)
|
{
|
if (onAdd != null)
|
{
|
onAdd(property, false);
|
}
|
}
|
|
private void OnAddDown(GameObject go)
|
{
|
if (onAdd != null)
|
{
|
onAdd(property, true);
|
}
|
}
|
|
private void OnSubDown(GameObject go)
|
{
|
if (onSub != null)
|
{
|
onSub(property, true);
|
}
|
}
|
|
private void OnSubUp(GameObject go)
|
{
|
if (onSub != null)
|
{
|
onSub(property, false);
|
}
|
}
|
}
|
}
|