using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Group : MonoBehaviour
{
public GameObject Object;
void Start()
{
}
public void Toggle(GameObject go)
{
if (!go.activeSelf)
{
SetShow(go,true);
}
else
{
SetShow(go,false);
}
}
public void SetShow(GameObject go ,bool state)
{
Debug.Log("设置选择对象位"+go);
if (Object!=null)
{
Object.SetActive(false);
}
Object = go;
Object.SetActive(state);
}
public void Hide()
{
if (Object != null)
{
Object.SetActive(false);
}
}
void Update()
{
}
你只需调用Toggle()方法即可。此脚本只放一个物体上,外部传值给总方法