!go.IsActive() || !go.GetTag() != 0解决方法
void OnDisable()
{
if(gameObject.active)
{
if(isMouse==true)
{
Object pigDeadObj;
pigDeadObj=Instantiate(pigDead,transform.position,transform.rotation);
}
}
else
{
在此处不可使用GameObject[] holeObjs1 = GameObject.FindGameObjectsWithTag("Hole"); find等方法
}
}解决方法:void Start()
{
Invoke("CRandomPig",2.5F);
}把销毁对象放在find方法后:void CRandomPig()
{
GameObject[] holeObjs1 = GameObject.FindGameObjectsWithTag("Hole");
int i=Random.Range(0,holeObjs1.Length);
Object clonePig2=Instantiate(me,new Vector3(holeObjs1.transform.position.x-0.9f,holeObjs1.transform.position.y,2.1f),holeObjs1.transform.rotation);
GameObject [] pigObjs1=GameObject.FindGameObjectsWithTag("Pig");
int j=Random.Range(0,i);
if(pigObjs1.Length<=5)
{
Object clonePig3=Instantiate(me,new Vector3(holeObjs1.transform.position.x-0.9f,holeObjs1.transform.position.y,2.1f),holeObjs1.transform.rotation);
}
isMouse=false;
Destroy(gameObject);
}在void OnDisable()添加if(isMouse==true)void OnDisable()
{
if(gameObject.active)
{
if(isMouse==true)
{
Object pigDeadObj;
pigDeadObj=Instantiate(pigDead,transform.position,transform.rotation);
}
}
else
{
}
} 很不错 真心顶 说的非常好 很好哦 不错不错 很不错 顶顶多好 真心顶 说的非常好