- Home /
Disable/Enable object imported from 3ds max
Hello to all,
First of all thanks for this awsome game engine :D
I'm having a problem in disable the rendering and the animation of one imported model from 3ds max. I've tried gameObect.enabled = false, gameObject.active = false, even added one Mesh Renderer to the object and tried gameObject.renderer.enabled = false. None of these worked, the object is always displayed. Is there any other option i could try?
I'm doing that on the pause menu:
function OnGUI(){
GameObject.Find("MenuCam").GetComponent("Camera").enabled = true;
GameObject.Find("MenuCam").GetComponent("Camera").transform.LookAt(Vector3.zero);
GameObject.Find("MenuCam").GetComponent("Camera").transform.Translate(0.05,0,0);
rect = new Rect(0, 0, 150, 75);
rect.x = (Screen.width - rect.width ) / 2;
rect.y = ((Screen.height - rect.height) / 2)-50;
if(GUI.Button(rect, "Jogar")){
GameObject.Find("MenuCam").GetComponent("Camera").enabled = false;
GameObject.Find("bus").enabled = false;
this.enabled = false;
}
The object bus is one model imported from 3ds.
The problem is where i want to make the bus not visible.
Thanks
Can you edit your post and show us a sample of the exact code you are using to disable the object, as well as how you are trying to get an instance of the object.
Answer by GlennHeckman · May 30, 2011 at 03:38 PM
Set your gameObject's active property to false, not enabled. The enabled property is for components (scripts on a game object) while active is for the gameObject itself. So your code will look like this:
GameObject.Find("bus").active = false;
Answer by capzulu · May 30, 2011 at 04:20 PM
I have found what my problem was, i needed to set the children active status to false.
I've used this function gameObject.SetActiveRecursively(false);
Your answer

Follow this Question
Related Questions
Disabling prefabs in a row one by one sequentially when an animation is played? 0 Answers
How to STOP music when loading a SPECIFIC SCENE? 3 Answers
Disable one of child of parent gameobject 1 Answer
What is the best way to update array in runtime? 3 Answers
Disabling a player in multiplayer then teleporting it to a different place 1 Answer