所以我只想在其他多个按钮被激活时激活一个按钮,在这种情况下,那些多个按钮是Button1,所以当它被激活时,它也应该激活按钮readyToRun
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class GratzScript : MonoBehaviour
{
public Button Button1;
public Button readyToRun;
public void Update()
{
if (Button1.enabled == true)
{
readyToRun.enabled = true;
}
}
}
尝试 Gameobject.activeInHierarchy
http://docs.unity3d.com/ScriptReference/GameObject-activeInHierarchy.html
GameObject.activeSelf; //Returns if the object is active or not
GameObject.activeInHierarchy; //Return if the object is active in the scene
您应该使用 setActive(true/false) 在场景中将游戏对象设置为活动/非活动状态
if(Button1.activeInHierarchy==true)
{
readyToRun.setActive(true);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句