C# 离开一个游戏对象,从阵列中停用其他游戏对象
我有一系列的游戏对象,我可以通过一个循环轻松地停用它们。然而,我不想停用一个游戏对象的地段。所以我提供了一个int值,它是游戏对象在该数组中的位置。如何停用除此特定对象之外的其他对象C# 离开一个游戏对象,从阵列中停用其他游戏对象,c#,unity3d,C#,Unity3d,我有一系列的游戏对象,我可以通过一个循环轻松地停用它们。然而,我不想停用一个游戏对象的地段。所以我提供了一个int值,它是游戏对象在该数组中的位置。如何停用除此特定对象之外的其他对象 public GameObject[] myObjs; int exceptionObj; void Start() { exceptionObj = 2; //Position of object in the array for(int i = 0; i<myObjs.Length; i++)
public GameObject[] myObjs;
int exceptionObj;
void Start()
{
exceptionObj = 2; //Position of object in the array
for(int i = 0; i<myObjs.Length; i++)
{
myObjs[i].SetActive(false);
}
}
publicgameobject[]myObjs;
int exceptionObj;
void Start()
{
exceptionObj=2;//数组中对象的位置
对于(inti=0;ipublicgameobject[]myObjs;
int exceptionObj;
void Start()
{
exceptionObj=2;//数组中对象的位置
对于(inti=0;ipublicgameobject[]myObjs;
int exceptionObj;
void Start()
{
exceptionObj=2;//数组中对象的位置
对于(int i=0;i两种方式:
如果:
exceptionObj = 2; //Position of object in the array
for(int i = 0; i<myObjs.Length; i++)
{
if (i != exceptionObj) // If not the exception ID
myObjs[i].SetActive(false);
}
exceptionObj=2;//数组中对象的位置
对于(int i=0;i两种方式:
如果:
exceptionObj = 2; //Position of object in the array
for(int i = 0; i<myObjs.Length; i++)
{
if (i != exceptionObj) // If not the exception ID
myObjs[i].SetActive(false);
}
exceptionObj=2;//数组中对象的位置
对于(int i=0;iThanks!这非常有效!您可以顺便说一句将其进一步缩短:对于(var int=0;i
;)谢谢!这非常有效您甚至可以进一步缩短它:对于(var int=0;i
)