Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!