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.
34 lines
923 B
34 lines
923 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ShopNavButton : MonoBehaviour
|
|
{
|
|
private Image[] highlights;
|
|
|
|
private void Start()
|
|
{
|
|
var buttons = GetComponentsInChildren<Button>(true);
|
|
List<Image> allHighlights = new List<Image>();
|
|
foreach (var button in buttons)
|
|
{
|
|
for(int i = 0; i < button.transform.childCount; i++)
|
|
{
|
|
var img = button.transform.GetChild(i).GetComponent<Image>();
|
|
if(img != null)
|
|
allHighlights.Add(img);
|
|
}
|
|
}
|
|
highlights = allHighlights.ToArray();
|
|
}
|
|
|
|
public void SetActiveButton(Button active)
|
|
{
|
|
foreach (var highlight in highlights)
|
|
{
|
|
highlight.gameObject.SetActive(highlight.transform.parent == active.transform);
|
|
}
|
|
}
|
|
}
|
|
|