Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

316
Visualizações
Dejando un gameObject, desactive otros de una matriz

Tengo una variedad de gameObjects que puedo desactivar fácilmente con un bucle. Sin embargo, no quiero desactivar un gameObject del lote. Así que estoy proporcionando un valor int que es la posición de gameObject en esa matriz. ¿Cómo desactivo otros excepto este objeto en particular?

 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); } }
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

public GameObject[] myObjs; int exceptionObj; void Start() { exceptionObj = 2; //Position of object in the array for(int i = 0; i<myObjs.Length; i++) { if(exceptionObj != i) myObjs[i].SetActive(false); } }

O;

 public GameObject[] myObjs; int exceptionObj; void Start() { exceptionObj = 2; //Position of object in the array for(int i = 0; i<myObjs.Length; i++) { if(exceptionObj == i) continue; myObjs[i].SetActive(false); } }

O tal vez incluso simplemente reactivando al final;

 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); } myObjs[exceptionObj].SetActive(true); }
over 4 years ago · Santiago Trujillo Relatório

0

Dos caminos:

  1. Con un si:

     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); }
  2. O con dos bucles:

     exceptionObj = 2; //Position of object in the array for(int i = 0; i<exceptionObj; i++) { myObjs[i].SetActive(false); } for(int i = exceptionObj+1; i<myObjs.Length; i++) { myObjs[i].SetActive(false); }
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda