/* Let user choose an AnimationEnum. If that Enum already exists for the _targetAnimController,
     * show a message warning the user that this will replace the animation.
     *
     * User can then press OK/Cancel */
    void OnGUI()
    {
        DrawAnimationEnum();

        /* If the currently selected _animEnum already exists as an animation for the current object,
         * show a warning to the user! */
        if (_targetAnimController.GetAnimObjectHolders().Count > 0)
        {
            if (_targetAnimController.GetAnimObjectHolders().Any(holder => holder.GetAnimationEnum() == _animEnum))
            {
                GUILayout.Space(15f);
                DrawOverrideWarning();
            }
        }

        GUILayout.Space(15f);

        /* OK/Cancel buttons */
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Add New Animation", GUILayout.MaxWidth(70f)))
        {
            AnimObjectHolder newAOH = AnimObjectHolder.CreateNewAnimObjectHolder();
            newAOH.SetFields(_animEnum);

            _targetAnimController.SetAnimObjectHolder(newAOH);
            this.Close();
        }
        if (GUILayout.Button("Cancel", GUILayout.MaxWidth(50f)))
        {
            this.Close();
        }
    }
Example #2
0
    /* Override Inspector GUI */
    public override void OnInspectorGUI()
    {
        // TO-DO: Draw the initial button which allows you to add an animation
        DrawAddAnimationButton();

        /* This foreach loop is responsible for DRAWING the header and body of
         * each AnimObjectHolder. Each AnimObjectHolder represents an animation "type"
         * (e.g. GetHit, Death, MeleeAttack...) */
        _animController.GetAnimObjectHolders().RemoveAll(holder => holder == null);
        foreach (AnimObjectHolder aoh in _animController.GetAnimObjectHolders())
        {
            aoh.GetAnimObjects().RemoveAll(a => a == null);
        }

        foreach (AnimObjectHolder aoh in _animController.GetAnimObjectHolders())
        {
            if (aoh == null)
            {
                Debug.LogWarning("AnimObjectHolder in _animController is null");
                Debug.Log(_animController.GetAnimObjectHolders().Count);
                continue;
            }
            DrawAnimationTitle(aoh.GetAnimationEnum());

            /* Draws each AnimObject */
            if (aoh.GetAnimObjects() != null)
            {
                foreach (AnimObject ao in aoh.GetAnimObjects())
                {
                    EditorGUILayout.BeginVertical();
                    DrawFoldoutHeader(ao, aoh); // draws header, with up/down buttons
                    EditorGUI.indentLevel++;
                    ao.SetDescription(EditorGUILayout.TextField("Description: ", ao.GetDescription(), GUILayout.MinWidth(250f)));
                    EditorGUI.indentLevel--;

                    EditorGUILayout.EndVertical();

                    if (ao.foldout)
                    {
                        EditorGUI.indentLevel++;
                        DrawAnimObject(ao);
                        EditorGUI.indentLevel--;
                        //EditorGUILayout.EndFadeGroup();
                    }
                }
                GUILayout.Space(15f);
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_animController);
            //foreach (AnimObjectHolder aoh in _animController.GetAnimObjectHolders())
            //{
            //    EditorUtility.SetDirty(aoh);
            //}
        }
    }
Example #3
0
 public void OnEnable()
 {
     /* Get ref to animController */
     _animController = (RSRAnimationController)target;
     if (_animController.GetAnimObjectHolders() == null)
     {
         _animController.SetAnimObjectHolders(new AnimObjectHolder[] {});
     }
     SetupStyles();
 }