- Home /
Boolean a Array of Transforms
hello :) i have been playing about with Transforms and arraying them by using the '.active' and i was just wondering how i would boolean an Array of transforms i tried
var GunParts : Transform[];
function Update(){
if(Input.GetKeyUp(KeyCode.Alpha1)){
GunParts.active = false;
}
}
ok so basicly all i needed is you attach the gameobjects to the array of transforms i have 3 objects so if i made 3 transforms from the array in the Inspector and attach the objects to it therefore theoretical making that array of gameobjects boolean'd but it doesn't work :( can someone help ?
I'm having a difficult time understanding your question. Are you asking how to put the GunParts Transforms into the GunParts array when their status is active? Or are you trying to change the status of all the GunParts Transforms found in the GunParts array?
Answer by ScroodgeM · Aug 09, 2012 at 08:43 PM
if (Input.GetKeyUp(KeyCode.Alpha1)) { for (int i = 0; i < GunParts.Length; i++) { //if you need to disable only root transforms GunParts[i].gameObject.active = false; //if you need to disable root transforms with childs GunParts[i].gameObject.SetActiveRecursively(false); } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613075432im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Accessing boolean properties from array of transforms 1 Answer
List and store vector3 of game objects with tag 1 Answer
I am making a 2d game and I want to make it where to can pick up bricks with your mouse 3 Answers
Unity3D - Playback object array of position (with dynamic velocity) 0 Answers
Same Input? 0 Answers