Exemplo n.º 1
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty clipsProp    = prop.FindPropertyRelative("clips");
            SerializedProperty is2D         = prop.FindPropertyRelative("is2D");
            SerializedProperty showAdvanced = prop.FindPropertyRelative("showAdvanced");

            pos.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.LabelField(pos, label, GUITools.boldLabel);

            float h = CalculateHeight(clipsProp, is2D, showAdvanced);

            GUITools.Box(new Rect(pos.x, pos.y, pos.width, h + EditorGUIUtility.singleLineHeight * .1f), GUITools.shade);

            pos.y += GUITools.singleLineHeight;

            pos.x     += GUITools.iconButtonWidth;
            pos.width -= GUITools.iconButtonWidth;

            EditorGUI.PropertyField(pos, clipsProp, true);
            pos.y     += EditorGUI.GetPropertyHeight(clipsProp, true);
            pos.height = GUITools.singleLineHeight;

            SerializedProperty oneShot = prop.FindPropertyRelative("oneShot");

            float x = pos.x;

            if (!oneShot.boolValue)
            {
                GUITools.DrawToggleButton(prop.FindPropertyRelative("loop"), unloopedContent, x, pos.y, GUITools.blue, GUITools.white);
                x += GUITools.iconButtonWidth;
            }

            GUITools.DrawToggleButton(oneShot, oneShotContent, x, pos.y, GUITools.blue, GUITools.white);
            x += GUITools.iconButtonWidth;

            GUITools.DrawToggleButton(is2D, spatialContent, x, pos.y, GUITools.white, GUITools.blue);
            x += GUITools.iconButtonWidth;

            if (!is2D.boolValue)
            {
                GUITools.DrawToggleButton(prop.FindPropertyRelative("useLinearRolloff"), linearRolloffContent, x, pos.y, GUITools.blue, GUITools.white);
                x += GUITools.iconButtonWidth;
            }
            GUITools.DrawToggleButton(showAdvanced, advancedSettingsContent, x, pos.y, GUITools.blue, GUITools.white);
            pos.y += GUITools.singleLineHeight;

            GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("volume"), volumeContent, GUITools.white);
            pos.y += GUITools.singleLineHeight;

            GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("pitchRange"), pitchRangeContent, GUITools.white);
            pos.y += GUITools.singleLineHeight;

            if (!is2D.boolValue)
            {
                GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("minMaxDistance"), minMaxDistanceContent, GUITools.white);
                pos.y += GUITools.singleLineHeight;
            }

            if (showAdvanced.boolValue)
            {
                pos.height = EditorGUIUtility.singleLineHeight;

                EditorGUI.LabelField(pos, "Advanced Settings:", GUITools.boldLabel);
                pos.y += EditorGUIUtility.singleLineHeight;

                if (!is2D.boolValue)
                {
                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("spread"), true);
                    pos.y += EditorGUIUtility.singleLineHeight;

                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("doppler"), true);
                    pos.y += EditorGUIUtility.singleLineHeight;
                }

                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("priority"), true);
                pos.y += EditorGUIUtility.singleLineHeight;

                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("stereoPan"), true);
            }
        }