You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
public class OutlineCtrl : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
|
|
public Button[] buttons;
|
|
public Color color;
|
|
public float witch;
|
|
void Start()
|
|
{
|
|
color = new Color(1, 0.5f, 0.1f,1);
|
|
witch = 7;
|
|
buttons = GetComponentsInChildren<Button>();
|
|
for (int i = 0; i < buttons.Length; i++)
|
|
{
|
|
buttons[i].gameObject.AddComponent<Outline>();
|
|
int k = i;
|
|
buttons[i].onClick.AddListener(() => OnClick(k));
|
|
}
|
|
for (int i = 0; i < buttons.Length; i++)
|
|
{
|
|
buttons[i].GetComponent<Outline>().effectDistance = new Vector2(witch, -witch);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void OnClick(int id)
|
|
{
|
|
for (int i = 0; i < buttons.Length; i++)
|
|
{
|
|
buttons[i].GetComponent<Outline>().enabled = false;
|
|
}
|
|
buttons[id].GetComponent<Outline>().enabled = true;
|
|
}
|
|
}
|