- Home /
 
Problem is not reproducible or outdated
My SetActive(false) doesn´t work
I want to activate my particle system with a button, but it seems like my Start function just execute the first line.
using UnityEngine; using System.Collections.Generic;
public class ScriptMago : MonoBehaviour {
 private GameObject Espiral;
 // Use this for initialization
 void Start() {
     GetComponent<Animation> ().CrossFade ("Idle1");
     Espiral = transform.FindChild("Cyclone").gameObject;
     Espiral.SetActive (false);
 }
 public Texture2D icon;
 
 void OnGUI () {
     if (GUI.Button (new Rect (10, 10, 100, 50), icon)) {  
         GetComponent<Animation> ().CrossFade ("Magic Attack3");
         Espiral.SetActive(true);
     }
     
     
 }
 
               }
Transform.FindChild is just a wrapper for Transform.Find. So it should work exactly the same.
 // UnityEngine.Transform
 public Transform FindChild(string name)
 {
     return this.Find(name);
 }
 
                  Right, or in other words: Do you get a null reference exception in line 7 ? ^^
I get this:
NullReferenceException: Object reference not set to an instance of an object
Ok, so i guess this problem is now outdated based on your comment. So i close it.
Follow this Question
Related Questions
OnSelect and OnPointerEnter work in one script but not another on the same object 2 Answers
Unable to reactive the game object 1 Answer
shop/button opening problems due to the starting(?) 1 Answer
Script Two Button Functions At Once 1 Answer
SetActive Button from another scene isn't working in build 0 Answers