68 lines
1.3 KiB
C#
68 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelectIn : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
|
{
|
|
public Sprite InUI;
|
|
public Sprite OutUI;
|
|
public bool selected = false;
|
|
public Button[] other;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (!selected)
|
|
{
|
|
this.GetComponent<Image>().sprite = InUI;
|
|
selected = true;
|
|
foreach (Button n in other)
|
|
{
|
|
n.GetComponent<SelectIn>().selected = false;
|
|
n.GetComponent<SelectIn>().refresh();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
this.GetComponent<Image>().sprite = OutUI;
|
|
selected = false;
|
|
}
|
|
|
|
public void refresh()
|
|
{
|
|
if (selected)
|
|
{
|
|
this.GetComponent<Image>().sprite = InUI;
|
|
}
|
|
else
|
|
{
|
|
this.GetComponent<Image>().sprite = OutUI;
|
|
}
|
|
}
|
|
}
|