Example #1
0
        protected bool DrawDisplayedToggle(Rect pos, SerializedProperty prop)
        {
            GUIContent gui = BuiltInIcons.GetIcon("animationvisibilitytoggle" + (prop.isExpanded ? "on" : "off"), prop.isExpanded ? "Hide" : "Show");

            if (GUITools.IconButton(pos.x, pos.y, gui, GUITools.white))
            {
                prop.isExpanded = !prop.isExpanded;
            }
            return(prop.isExpanded);
        }
Example #2
0
        void InitializeGUI()
        {
            if (icons == null)
            {
                icons = new GUIContent[BuiltInIcons.iconsCount];
                for (int i = 0; i < BuiltInIcons.iconsCount; i++)
                {
                    icons[i] = BuiltInIcons.GetIcon(BuiltInIcons.allIcons[i], BuiltInIcons.allIcons[i]);
                }
            }
            if (layoutOptions == null)
            {
                layoutOptions = new GUILayoutOption[] { GUILayout.Width(64) }
            }
            ;

            if (blackButtonStyle == null)
            {
                blackButtonStyle = new GUIStyle(GUITools.toolbarButton);
                blackButtonStyle.normal.background = null;
            }
        }

        void DrawButtonRow(GUIStyle style, Color32 color, int i)
        {
            GUI.color = color;
            EditorGUILayout.BeginHorizontal(GUITools.toolbar);
            GUI.color = GUITools.white;
            for (int x = 0; x < columns; x++)
            {
                if (i + x < icons.Length && GUILayout.Button(icons[i + x], style, layoutOptions))
                {
                    ProjectTools.CopyStringToClipBoard(icons[i + x].tooltip);
                    Debug.Log("Copied to clipboard: " + icons[i + x].tooltip);
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        int columns = 7;

        void OnGUI()
        {
            InitializeGUI();
            scroll_pos = EditorGUILayout.BeginScrollView(scroll_pos);
            for (int i = 0; i < icons.Length; i += columns)
            {
                DrawButtonRow(GUITools.toolbarButton, GUITools.white, i);
                DrawButtonRow(blackButtonStyle, GUITools.black, i);
                GUITools.Space(2);
            }
            EditorGUILayout.EndScrollView();
        }
    }
        static void OnToolbarGUI()
        {
            if (Application.isPlaying)
            {
                return;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(BuiltInIcons.GetIcon("PlayButtonProfile", "Play From Main Menu"), ToolbarExtender.commandButtonStyle))
            {
                loadMainMenuOnEditorPlay    = true;
                EditorApplication.isPlaying = true;
            }
        }
        void DrawToolbar(float x, float y, SerializedProperty prop, SerializedProperty oneShot, SerializedProperty is2D)
        {
            GUITools.DrawIconToggle(oneShot, BuiltInIcons.GetIcon("AudioListener Icon", "One Shot"), x, y);
            x += GUITools.iconButtonWidth;

            GUI.enabled = !oneShot.boolValue;
            GUITools.DrawIconToggle(prop.FindPropertyRelative("loop"), BuiltInIcons.GetIcon("preAudioLoopOff", "Looped"), x, y);
            x          += GUITools.iconButtonWidth;
            GUI.enabled = true;

            GUITools.DrawIconToggle(is2D, BuiltInIcons.GetIcon("Prefab Icon", "3D Sound"), x, y, GUITools.white, GUITools.blue);
            x += GUITools.iconButtonWidth;

            GUI.enabled = !is2D.boolValue;
            GUITools.DrawIconToggle(prop.FindPropertyRelative("useLinearRolloff"), BuiltInIcons.GetIcon("DefaultSorting", "Linear Roloff"), x, y);
            x          += GUITools.iconButtonWidth;
            GUI.enabled = true;

            prop.isExpanded = GUITools.DrawIconToggle(prop.isExpanded, BuiltInIcons.GetIcon("_Popup", "Advanced Settings"), x, y);
        }
Example #5
0
        void InitializeIcons(bool manual)
        {
            if (icons == null || manual)
            {
                icons = new GUIContent[colors.Length];

                for (int i = 0; i < colors.Length; i++)
                {
                    icons[i] = BuiltInIcons.GetIcon(BuiltInIcons.allIcons[Random.Range(0, BuiltInIcons.iconsCount)], "");
                }

                colors = new Color32[6] {
                    GUITools.blue,
                    GUITools.red,
                    GUITools.green,
                    GUITools.darkGray,
                    GUITools.gray,
                    GUITools.liteGray,
                };
            }
        }
Example #6
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginHorizontal();

            GUITools.StringFieldWithDefault(serializedObject.FindProperty("valueName"), "Value Name");

            SerializedProperty behaviorProp = serializedObject.FindProperty("behavior");

            EditorGUILayout.PropertyField(behaviorProp, GUITools.noContent, true);
            GameValueModifierBehavior behavior = (GameValueModifierBehavior)behaviorProp.enumValueIndex;

            SerializedProperty componentProp = serializedObject.FindProperty("componentToModify");

            EditorGUILayout.PropertyField(componentProp, GUITools.noContent, true);
            GameValueModifierComponent component = (GameValueModifierComponent)componentProp.enumValueIndex;

            SerializedProperty byTimeProp = serializedObject.FindProperty("byTime");

            // cant modify by delta time if modifying base modifier or setting values
            if (component == GameValueModifierComponent.BaseMod || behavior == GameValueModifierBehavior.Set)
            {
                byTimeProp.boolValue = false;
            }
            else
            {
                GUITools.DrawIconToggle(byTimeProp, BuiltInIcons.GetIcon("UnityEditor.AnimationWindow", "Magnitude is multiplied by delta time when updated"));
            }

            EditorGUILayout.EndHorizontal();

            if (component == GameValueModifierComponent.BaseMod && behavior == GameValueModifierBehavior.Set)
            {
                EditorGUILayout.HelpBox("Cant set base value modifier.  Changes need to be able to be unmodified...", MessageType.Error);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("conditions"), new GUIContent("Conditions"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("keywords"), new GUIContent("Keywords"), true);

            serializedObject.ApplyModifiedProperties();
        }
Example #7
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            UnityEngine.Object oldClip = prop.objectReferenceValue;

            Rect rect = new Rect(pos.x, pos.y, pos.width - fullToolbarSize, EditorGUIUtility.singleLineHeight);

            if ((attribute as PreviewedAudioAttribute).useAssetSelector)
            {
                AssetSelector.Draw(typeof(AudioClip), rect, prop, label, null, null);
            }
            else
            {
                EditorGUI.PropertyField(rect, prop, label);
            }

            float toolbarStart = pos.x + pos.width - fullToolbarSize;

            if (oldClip != prop.objectReferenceValue)
            {
                EditorAudioTools.StopClip(oldClip as AudioClip);
            }

            GUITools.DrawToolbarDivider(toolbarStart, pos.y);
            GUI.enabled = prop.objectReferenceValue != null;

            AudioClip newClip = prop.objectReferenceValue as AudioClip;

            AudioSource source;
            bool        isPlaying = EditorAudioTools.IsClipPlaying(newClip, out source);

            float xStart = toolbarStart + GUITools.toolbarDividerSize;

            UnityEngine.Object targetObject = prop.serializedObject.targetObject;
            DrawPlayStopButton(newClip, xStart + GUITools.iconButtonWidth * 0, pos.y, isPlaying, isPlaying && !source.loop, BuiltInIcons.GetIcon("preAudioPlayOff", "Play Clip"), false, targetObject);
            DrawPlayStopButton(newClip, xStart + GUITools.iconButtonWidth * 1, pos.y, isPlaying, isPlaying && source.loop, BuiltInIcons.GetIcon("preAudioLoopOff", "Play Clip Looped"), true, targetObject);

            GUI.enabled = true;
        }
Example #8
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            prop = prop.FindPropertyRelative(NeatArrayAttributeDrawer.listName);

            GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel);

            if (GUITools.IconButton(pos.x + pos.width - GUITools.iconButtonWidth, pos.y, new GUIContent("", "Unselect All"), GUITools.red))
            {
                for (int i = 0; i < prop.arraySize; i++)
                {
                    prop.GetArrayElementAtIndex(i).FindPropertyRelative("selected").boolValue = false;
                }
            }

            int indexToDelete = -1;

            float fieldsY = pos.y + GUITools.singleLineHeight;

            Rect fieldRect = new Rect(
                pos.x + GUITools.iconButtonWidth + GUITools.toolbarDividerSize,
                fieldsY,
                pos.width - (GUITools.iconButtonWidth * 3 + GUITools.toolbarDividerSize * 2),
                EditorGUIUtility.singleLineHeight
                );
            Rect colorAreaRect = new Rect(
                pos.x + GUITools.iconButtonWidth,
                fieldsY,
                pos.width - (GUITools.iconButtonWidth * 3),
                GUITools.singleLineHeight
                );

            Rect hoverAreaRect = new Rect(pos.x, fieldsY, pos.width, GUITools.singleLineHeight);

            float selectX = pos.x + pos.width - GUITools.iconButtonWidth;
            float rotateX = selectX - GUITools.iconButtonWidth;

            Rect rotateRect = new Rect(rotateX, fieldsY, GUITools.iconButtonWidth, GUITools.singleLineHeight);


            bool focus = false;

            Event   e        = Event.current;
            Vector2 mousePos = e.mousePosition;

            if (isRotating)
            {
                if (e.type == EventType.MouseUp)
                {
                    isRotating = false;
                    rotateProp = null;
                }
                else if (e.type == EventType.MouseDrag)
                {
                    SerializedProperty rotationProp = rotateProp.FindPropertyRelative("rotation");
                    rotationProp.floatValue = rotationProp.floatValue + e.delta.x;
                }
            }

            else
            {
                if (!LocationPainter.drawing)
                {
                    if ((EventType.KeyUp == e.type || EventType.KeyDown == e.type) && KeyCode.F == e.keyCode)
                    {
                        focus = EventType.KeyUp == e.type;
                        e.Use();
                    }
                }
            }

            for (int i = 0; i < prop.arraySize; i++)
            {
                if (GUITools.IconButton(pos.x, fieldsY, BuiltInIcons.GetIcon("Toolbar Minus", "Delete Element"), GUITools.red))
                {
                    indexToDelete = i;
                }

                SerializedProperty p = prop.GetArrayElementAtIndex(i);

                SerializedProperty hovered = p.FindPropertyRelative("hovered");

                if (!isRotating)
                {
                    hovered.boolValue = false;
                    if (hoverAreaRect.Contains(mousePos))
                    {
                        hovered.boolValue = true;

                        if (focus)
                        {
                            SceneView.lastActiveSceneView.Frame(new Bounds(p.FindPropertyRelative("position").vector3Value, Vector3.one * 3), false);
                        }
                    }
                }

                if (hovered.boolValue)
                {
                    GUITools.Box(colorAreaRect, GUITools.blue);
                }
                else
                {
                    if (p.FindPropertyRelative("isError").boolValue)
                    {
                        GUITools.Box(colorAreaRect, GUITools.red);
                    }
                }

                SerializedProperty nameProp = p.FindPropertyRelative("name");
                if (string.IsNullOrEmpty(nameProp.stringValue))
                {
                    nameProp.stringValue = "SubLcoation_" + i.ToString();
                }
                EditorGUI.PropertyField(fieldRect, nameProp, GUITools.noContent, true);

                GUITools.DrawIconToggle(p.FindPropertyRelative("selected"), new GUIContent("", "Select For Movement"), selectX, fieldsY);

                if (!isRotating)
                {
                    if (Event.current.type == EventType.MouseDown)
                    {
                        if (rotateRect.Contains(mousePos))
                        {
                            hovered.boolValue = true;
                            rotateProp        = p;
                            isRotating        = true;
                        }
                    }
                }
                GUITools.DrawIconToggle(isRotating && hovered.boolValue, rotateGUI, rotateX, fieldsY);


                fieldsY        += GUITools.singleLineHeight;
                fieldRect.y     = fieldsY;
                colorAreaRect.y = fieldsY;
                hoverAreaRect.y = fieldsY;
                rotateRect.y    = fieldsY;
            }

            if (indexToDelete != -1)
            {
                prop.DeleteArrayElementAtIndex(indexToDelete);
            }
        }