73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Optionsbox : MonoBehaviour
|
|
{
|
|
public Button anniu;
|
|
public Image Image;
|
|
private GameObject game1;
|
|
private GameObject game2;
|
|
private GameObject game3;
|
|
public List<GameObject> games = new List<GameObject>();
|
|
public List<Image> buttons = new List<Image>();
|
|
public bool isp = true;
|
|
public bool isp2 = true;
|
|
public Transform weizhi;
|
|
private Sprite sprite1;
|
|
private Sprite sprite2;
|
|
void Start()
|
|
{
|
|
game1 = Resources.Load<GameObject>("UIPanel/subject1_iamg");
|
|
game2 = Resources.Load<GameObject>("UIPanel/subject2_iamg");
|
|
game3 = Resources.Load<GameObject>("UIPanel/subject3_iamg");
|
|
sprite1 = Resources.Load<Sprite>("sprite/三角形 绿");
|
|
sprite2 = Resources.Load<Sprite>("sprite/三角形白");
|
|
Debug.Log(sprite1);
|
|
games.Add(game1);
|
|
games.Add(game2);
|
|
games.Add(game3);
|
|
anniu.onClick.AddListener(() =>
|
|
{
|
|
if (isp == true)
|
|
{
|
|
Image.sprite = sprite1;
|
|
for (int i = 0; i < games.Count; i++)
|
|
{
|
|
Instantiate(games[i], weizhi);
|
|
}
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
buttons.Add(GameObject.Find("Scroll_view_Drop").transform.GetChild(0).transform.GetChild(0).transform.GetChild(i).GetComponent<Image>());
|
|
// buttons.Add(transform.GetChild(3).transform.GetChild(0).transform.GetChild(0).transform.GetChild(i).GetComponent<Image>());
|
|
}
|
|
isp = false;
|
|
}
|
|
else
|
|
{
|
|
if (isp2 == true)
|
|
{
|
|
Debug.Log(21);
|
|
Image.sprite = sprite2;
|
|
for (int i = 0; i < buttons.Count; i++)
|
|
{
|
|
buttons[i].gameObject.SetActive(false);
|
|
}
|
|
isp2 = false;
|
|
}
|
|
else
|
|
{
|
|
Image.sprite=sprite1;
|
|
for (int i = 0; i < buttons.Count; i++)
|
|
{
|
|
buttons[i].gameObject.SetActive(true);
|
|
}
|
|
isp2 = true;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|