我怎样才能 Boolean(Disable/Enable) SetActive MY 对象
How can I Boolean(Disable/Enable) SetActive MY Object
我需要 Boolean SetActive,例如我想要 setAccefalse 一个对象,然后我想要 setAcctice 为真,但是当我玩我的游戏并首先设置为假我的对象时 (boy.max) 我不能 return 我的对象甚至我的 set Active 都会是 true
using UnityEngine;
using System.Collections;
public class Hidden : MonoBehaviour {
// Use this for initializatio
// Update is called once per frame
void Update(){
if(Input.GetButtonDown ("Fire1")){
gameObject.SetActive(false);
Debug.Log("Remove");
}
if(Input.GetButtonDown ("Fire2")){
gameObject.SetActive(true);
Debug.Log("Return");
}
}
}
这是我的问题视频:
https://drive.google.com/open?id=0B-1NrBmZJDU2LWwyZlloNll4NWs
一旦禁用 GameObject
,它的所有组件都会停止 运行。这包括告诉它重新打开自己的脚本。当它根本不读取任何信息时,它如何读取信息以重新打开?因此,您必须从外部禁用它。
using UnityEngine;
using System.Collections;
public class HideObject : MonoBehaviour {
public GameObject objectToHide;
// Update is called once per frame
void Update(){
if(Input.GetButtonDown ("Fire1")){
objectToHide.SetActive(false);
Debug.Log("Remove");
}
if(Input.GetButtonDown ("Fire2")){
objectToHide.SetActive(true);
Debug.Log("Return");
}
}
}
我需要 Boolean SetActive,例如我想要 setAccefalse 一个对象,然后我想要 setAcctice 为真,但是当我玩我的游戏并首先设置为假我的对象时 (boy.max) 我不能 return 我的对象甚至我的 set Active 都会是 true
using UnityEngine;
using System.Collections;
public class Hidden : MonoBehaviour {
// Use this for initializatio
// Update is called once per frame
void Update(){
if(Input.GetButtonDown ("Fire1")){
gameObject.SetActive(false);
Debug.Log("Remove");
}
if(Input.GetButtonDown ("Fire2")){
gameObject.SetActive(true);
Debug.Log("Return");
}
}
}
这是我的问题视频: https://drive.google.com/open?id=0B-1NrBmZJDU2LWwyZlloNll4NWs
一旦禁用 GameObject
,它的所有组件都会停止 运行。这包括告诉它重新打开自己的脚本。当它根本不读取任何信息时,它如何读取信息以重新打开?因此,您必须从外部禁用它。
using UnityEngine;
using System.Collections;
public class HideObject : MonoBehaviour {
public GameObject objectToHide;
// Update is called once per frame
void Update(){
if(Input.GetButtonDown ("Fire1")){
objectToHide.SetActive(false);
Debug.Log("Remove");
}
if(Input.GetButtonDown ("Fire2")){
objectToHide.SetActive(true);
Debug.Log("Return");
}
}
}