Exemplo n.º 1
0
    // Adjust the number of iteration scripts that exist towards the number of iterations requested via the settings.
    private void adjustIterationObjects()
    {
        GuidingVectorTree t   = target as GuidingVectorTree;
        int iterations_should = t.nIterations;

        TreeIterationParam[] iterations_is = t.gameObject.GetComponents <TreeIterationParam>();

        if (iterations_should == iterations_is.Length)
        {
            return;                                            // nothing to do (this is not required as the loops will iterate 0 times, but just to be sure)
        }
        // Add Iterations, if too few
        for (int i = iterations_is.Length; i < iterations_should; i++)
        {
            TreeIterationParam p = t.gameObject.AddComponent <TreeIterationParam>();
            p.iterationCounter = i + 1;
        }


        // Remove Iterations, if too many
        List <TreeIterationParam> deleteList = new List <TreeIterationParam>();

        for (int i = iterations_is.Length - 1; i >= iterations_should; i--)
        {
            deleteList.Add(iterations_is[i]);
        }
        deleteIterations(deleteList);
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        DrawDefaultInspector();

        GUILayout.Space(10.0f);         // Some vertical spacing

        GuidingVectorTree t = target as GuidingVectorTree;

        adjustIterationObjects();
        TreeIterationParam[] iterations = t.gameObject.GetComponents <TreeIterationParam>();

        for (int i = 0; i < iterations.Length; i++)
        {
            Editor e = Editor.CreateEditor(iterations[i]);
            ((TreeIterationParamEditor)e).visible = true;
            e.OnInspectorGUI();
        }

        serializedObject.ApplyModifiedProperties();
    }