Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (parameters_change())
        {
            Debug.Log("jauwhsd");
            foreach (GameObject child in children)
            {
                if (recursion_iterations > 0)
                {
                    RecursiveInstantiator child_inst = child.GetComponent <RecursiveInstantiator>();
                    child.SendMessage("DestroyRecursive", child_inst.get_children());
                }
                else
                {
                    Destroy(child);
                }
            }

            if (recursion_iterations > 0)
            {
                children.Clear();
                for (int i = 0; i < split_number; i++)
                {
                    GameObject branch_copy = Instantiate(gameObject);
                    children.Add(branch_copy);
                    RecursiveInstantiator branch_copy_rec_inst = branch_copy.GetComponent <RecursiveInstantiator>();
                    branch_copy_rec_inst.recursion_iterations -= 1;
                    Vector3 arguments = new Vector3((float)i, branch_scale, branch_angle_rotation);
                    branch_copy.SendMessage("Generated", arguments);
                }
            }
        }
    }
 public void DestroyRecursive(List <GameObject> children)
 {
     foreach (GameObject child in children)
     {
         //Debug.Log("jauwhsd");
         RecursiveInstantiator child_inst = child.GetComponent <RecursiveInstantiator>();
         //child_inst.updateNode(this.gameObject);
         child.SendMessage("DestroyRecursive", child_inst.get_children());
         //i++;
     }
     Destroy(this.gameObject);
 }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        elapsedTime   += Time.deltaTime;
        scale_fraction = elapsedTime / 5;

        if (elapsedTime > 5)
        {
            this.transform.localScale = new Vector3(final_scale, final_scale, final_scale);
            children = rec_inst.get_children();
            foreach (GameObject child in children)
            {
                child.SetActive(true);
            }
        }
        else
        {
            this.transform.localScale = new Vector3(scale_fraction * final_scale, scale_fraction * final_scale, scale_fraction * final_scale);
        }
    }
Example #4
0
 // Start is called before the first frame update
 void Start()
 {
     rec_inst    = GetComponent <RecursiveInstantiator>();
     children    = rec_inst.get_children();
     final_scale = this.transform.localScale.y;
 }