Ejemplo n.º 1
0
//--> Remove a specific sound on a specific surface
    private void RemoveSound(footstepSystem myScript, int i, int j)
    {
        Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
        myScript.listFootstepSystem[i].footstepSamples.RemoveAt(j);
    }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                             // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("See Inspector :", GUILayout.Width(85));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;


        GUILayout.Label("");
        footstepSystem myScript = (footstepSystem)target;

        for (var i = 0; i < listCompareMangnitude.arraySize; i++)
        {
            EditorGUILayout.BeginVertical(style_Yellow_01);
//--> Choose the time between two steps
            EditorGUILayout.HelpBox("Choose the time between two steps", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Time between two steps : ", GUILayout.Width(140));
            EditorGUILayout.PropertyField(listCompareMangnitude.GetArrayElementAtIndex(i).FindPropertyRelative("listTimeBetweenTwoStep"), new GUIContent(""), GUILayout.Width(40));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }

        GUILayout.Label("");

        for (var i = 0; i < listFootstepSystem.arraySize; i++)
        {
//--> Setup sound for each surface
            SerializedProperty footstepType = listFootstepSystem.GetArrayElementAtIndex(i);
            SerializedProperty refTag       = listFootstepSystem.GetArrayElementAtIndex(i).FindPropertyRelative("MaterialTag");


            EditorGUILayout.BeginVertical(style_Orange);
            EditorGUILayout.HelpBox("When character is on surface with the Tag "
                                    + "''" + refTag.stringValue + "''" +
                                    " next footsteps are played.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Surface : ", GUILayout.Width(65));
            EditorGUILayout.LabelField("");
            Rect r = GUILayoutUtility.GetLastRect();
            refTag.stringValue = EditorGUI.TagField(new Rect(r.x, r.y, 110, 18), new GUIContent(""), refTag.stringValue);
            EditorGUILayout.EndHorizontal();

            for (var j = 0; j < footstepType.FindPropertyRelative("footstepSamples").arraySize; j++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(footstepType.FindPropertyRelative("footstepSamples").GetArrayElementAtIndex(j)
                                              , new GUIContent(""), GUILayout.Width(200));


//--> Add/Remove footstep
                if (GUILayout.Button("+", GUILayout.Width(20)))
                {
                    AddSound(myScript, i, j);
                }
                if (footstepType.FindPropertyRelative("footstepSamples").arraySize > 1)
                {
                    if (GUILayout.Button("-", GUILayout.Width(20)))
                    {
                        RemoveSound(myScript, i, j);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.LabelField("");
        }


//--> Create a new surface
        EditorGUILayout.BeginVertical(style_Blue);
        EditorGUILayout.HelpBox("This section allow to create a new footstep surface." +
                                "\n1-Choose a name for the new surface" +
                                "\n2-Press Create", MessageType.Info);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Choose a name for the new surface : ", GUILayout.Width(200));

        newTagName = EditorGUILayout.TextField(newTagName, GUILayout.Width(85));
        if (GUILayout.Button("Create", GUILayout.Width(85)))
        {
            CreateNewSurface(newTagName);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        EditorGUILayout.LabelField("");
        EditorGUILayout.LabelField("");

        serializedObject.ApplyModifiedProperties();
    }
Ejemplo n.º 3
0
//--> ADd new sound on a specific surface
    private void AddSound(footstepSystem myScript, int i, int j)
    {
        Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
        listFootstepSystem.GetArrayElementAtIndex(i).FindPropertyRelative("footstepSamples").InsertArrayElementAtIndex(j);
        listFootstepSystem.GetArrayElementAtIndex(i).FindPropertyRelative("footstepSamples").GetArrayElementAtIndex(j + 1).objectReferenceValue = null;
    }