AR骑行动画&换装基本交互逻辑
This commit is contained in:
1 parent
d938a0c8be
commit
995aef63f8
117 files changed
+60802
-2718
No files matched your search
@@ -0,0 +1,89 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Player
|
||||
{
|
||||
public abstract class AbstractEquipmentScript : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler, IPointerUpHandler
|
||||
{
|
||||
public Image Content;//装备图片
|
||||
public GameObject bglock;
|
||||
public GameObject bglockLight;//选中样式
|
||||
public GameObject Click;//选中勾选
|
||||
public GameObject lockGrey;//灰色的锁定
|
||||
public GameObject lockLight;//白色的锁定 选中时使用
|
||||
public Text Title;
|
||||
public Text Desc;
|
||||
|
||||
protected int Id { get; set; }
|
||||
protected string Name { get; set; }
|
||||
protected string Remark { get; set; }
|
||||
|
||||
protected string URL { get; set; }
|
||||
protected bool IsLock { get; set; }
|
||||
protected virtual void Start()
|
||||
{
|
||||
var btn = GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
Select();
|
||||
});
|
||||
}
|
||||
public virtual void Init(int id, string name, string remark, string url, bool isLock)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Remark = remark;
|
||||
IsLock = isLock;
|
||||
URL = url;
|
||||
Utils.DisplayImage(Content, url);
|
||||
}
|
||||
|
||||
public virtual void Select()
|
||||
{
|
||||
UnSelectAll();
|
||||
bglockLight.SetActive(true);
|
||||
if (lockGrey != null && lockLight != null)
|
||||
{
|
||||
lockLight.SetActive(IsLock);
|
||||
lockGrey.SetActive(false);
|
||||
}
|
||||
Title.text = Name;
|
||||
Desc.text = Remark;
|
||||
}
|
||||
|
||||
public virtual void UnSelect()
|
||||
{
|
||||
bglockLight.SetActive(false);
|
||||
if (lockGrey != null && lockLight != null)
|
||||
{
|
||||
lockGrey.SetActive(IsLock);
|
||||
lockLight.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UnSelectAll()
|
||||
{
|
||||
var list = FindObjectsOfType<AbstractEquipmentScript>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.UnSelect();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user