48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
|
||
|
|
// 主视图存在时,点击次视图,主视图消失,次视图出现;
|
||
|
|
// 次视图存在时,点击相同次视图,次视图消失,主视图出现;
|
||
|
|
// 次视图存在时,点击不同次视图,次视图消失,另一个次视图出现;
|
||
|
|
|
||
|
|
public class MenuSL : MonoBehaviour
|
||
|
|
{
|
||
|
|
// 主视图
|
||
|
|
public GameObject main;
|
||
|
|
// 次视图
|
||
|
|
public GameObject second;
|
||
|
|
// 次视图数组
|
||
|
|
public GameObject[] secondViews;
|
||
|
|
|
||
|
|
public void OnMouseDown()
|
||
|
|
{
|
||
|
|
print("MenuSL OnPointerClick");
|
||
|
|
bool isMain = main.activeSelf;
|
||
|
|
bool isSecond = second.activeSelf;
|
||
|
|
if (isMain)
|
||
|
|
{
|
||
|
|
main.SetActive(false);
|
||
|
|
second.SetActive(true);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
foreach (var secondView in secondViews)
|
||
|
|
{
|
||
|
|
secondView.SetActive(false);
|
||
|
|
}
|
||
|
|
if (isSecond)
|
||
|
|
{
|
||
|
|
main.SetActive(true);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
second.SetActive(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|