Exemple #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            position.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(position, property);
            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;
                position = DrawNextProperty(position, property.FindPropertyRelative("enableBob"));
                GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enableBob"), () =>
                {
                    position = DrawNextProperty(position, property.FindPropertyRelative("unscaledTime"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("bobFrequency"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("bobHeight"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("swayAngle"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("sideMovement"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("heightMultiplier"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("strideMultiplier"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("landMove"));
                    position = DrawNextProperty(position, property.FindPropertyRelative("landTilt"));

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("enableStrafeTilting"));
                    GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enableStrafeTilting"), () =>
                    {
                        position = DrawNextProperty(position, property.FindPropertyRelative("strafeTilt"));
                    });

                    position = DrawSpace(position);

                    position = DrawNextProperty(position, property.FindPropertyRelative("bobTarget"));
                });
                EditorGUI.indentLevel--;
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Set 'doGUI' to true as we want to bae it of the GUI.
            doGUI = true;
            // Begin the property GUI.
            EditorGUI.BeginProperty(position, label, property);
            // Set the full rect to the provided position.
            fullRect = position;
            // Set the full rect height to the line height.
            fullRect.height = lineHeight;
            // Set the field rect to the provided position.
            fieldRect = position;
            // Set the field rect height to the line height.
            fieldRect.height = lineHeight;
            // The property foldout.
            EditorGUI.PropertyField(fieldRect, property, label, false);
            // Only draw the rest if the property is expanded.
            if (property.isExpanded)
            {
                //Indent the GUI one step.
                EditorGUI.indentLevel++;
                // Add to the rect.
                AddToRect();
                // The 'Enabled' field.
                EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("enabled"));

                GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("enabled"), () =>
                {
                    // Add to the rect.
                    AddToRect();
                    // The 'Random Pitch' field.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("randomPitch"));
                    // Add to the rect.
                    AddToRect();
                    // If random pitch is enabled, draw min max fields.
                    // Else just draw one field.
                    if (property.FindPropertyRelative("randomPitch").boolValue)
                    {
                        GoldPlayerUIHelper.DrawCustomVector2Field(fieldRect,
                                                                  property.FindPropertyRelative("minPitch"),
                                                                  property.FindPropertyRelative("maxPitch"),
                                                                  30, new GUIContent("Pitch"), true, new GUIContent("Min"), new GUIContent("Max"));
                    }
                    else
                    {
                        // The 'Pitch' field.
                        EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("pitch"));
                    }
                    // Add to the rect.
                    AddToRect();
                    // The 'Change Volume' field.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("changeVolume"));
                    // If change volume is true, draw the volume field.
                    GoldPlayerUIHelper.DrawElementsConditional(property.FindPropertyRelative("changeVolume"), () =>
                    {
                        // Add to the rect.
                        AddToRect();
                        // The volume slider field.
                        EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("volume"));
                    });
                    // Add to the rect.
                    AddToRect();
                    // The audio clips array.
                    EditorGUI.PropertyField(fieldRect, property.FindPropertyRelative("audioClips"), true);
                    // If the audio clips array is expanded, add to the rect to make sure everything is shown.
                    if (property.FindPropertyRelative("audioClips").isExpanded)
                    {
                        // Add a rect for the size field.
                        AddToRect();
                        // For every clip, add a size for every field.
                        for (int i = 0; i < property.FindPropertyRelative("audioClips").arraySize; i++)
                        {
                            AddToRect();
                        }
                    }
                });

                // Remove the indent.
                EditorGUI.indentLevel--;
            }
            // End the property GUI.
            EditorGUI.EndProperty();
        }