Beispiel #1
0
        public void DrawItem(Rect position, int index)
        {
            Command command = this[index].objectReferenceValue as Command;

            if (command == null)
            {
                return;
            }

            CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(command.GetType());

            if (commandInfoAttr == null)
            {
                return;
            }

            var flowchart = (Flowchart)command.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            bool isComment = command.GetType() == typeof(Comment);
            bool isLabel   = (command.GetType() == typeof(Label));

            bool   error   = false;
            string summary = command.GetSummary();

            if (summary == null)
            {
                summary = "";
            }
            else
            {
                summary = summary.Replace("\n", "").Replace("\r", "");
            }
            if (summary.StartsWith("Error:"))
            {
                error = true;
            }

            if (isComment || isLabel)
            {
                summary = "<b> " + summary + "</b>";
            }
            else
            {
                summary = "<i>" + summary + "</i>";
            }

            bool commandIsSelected = false;

            foreach (Command selectedCommand in flowchart.SelectedCommands)
            {
                if (selectedCommand == command)
                {
                    commandIsSelected = true;
                    break;
                }
            }

            string commandName = commandInfoAttr.CommandName;

            GUIStyle commandLabelStyle = new GUIStyle(GUI.skin.box);

            commandLabelStyle.normal.background = FungusEditorResources.CommandBackground;
            int borderSize = 5;

            commandLabelStyle.border.top    = borderSize;
            commandLabelStyle.border.bottom = borderSize;
            commandLabelStyle.border.left   = borderSize;
            commandLabelStyle.border.right  = borderSize;
            commandLabelStyle.alignment     = TextAnchor.MiddleLeft;
            commandLabelStyle.richText      = true;
            commandLabelStyle.fontSize      = 11;
            commandLabelStyle.padding.top  -= 1;

            float indentSize = 20;

            for (int i = 0; i < command.IndentLevel; ++i)
            {
                Rect indentRect = position;
                indentRect.x       += i * indentSize - 21;
                indentRect.width    = indentSize + 1;
                indentRect.y       -= 2;
                indentRect.height  += 5;
                GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f, 1f);
                GUI.Box(indentRect, "", commandLabelStyle);
            }

            float commandNameWidth = Mathf.Max(commandLabelStyle.CalcSize(new GUIContent(commandName)).x, 90f);
            float indentWidth      = command.IndentLevel * indentSize;

            Rect commandLabelRect = position;

            commandLabelRect.x      += indentWidth - 21;
            commandLabelRect.y      -= 2;
            commandLabelRect.width  -= (indentSize * command.IndentLevel - 22);
            commandLabelRect.height += 5;

            // There's a weird incompatibility between the Reorderable list control used for the command list and
            // the UnityEvent list control used in some commands. In play mode, if you click on the reordering grabber
            // for a command in the list it causes the UnityEvent list to spew null exception errors.
            // The workaround for now is to hide the reordering grabber from mouse clicks by extending the command
            // selection rectangle to cover it. We are planning to totally replace the command list display system.
            Rect clickRect = position;

            clickRect.x     -= 20;
            clickRect.width += 20;

            // Select command via left click
            if (Event.current.type == EventType.MouseDown &&
                Event.current.button == 0 &&
                clickRect.Contains(Event.current.mousePosition))
            {
                if (flowchart.SelectedCommands.Contains(command) && Event.current.button == 0)
                {
                    // Left click on already selected command
                    // Command key and shift key is not pressed
                    if (!EditorGUI.actionKey && !Event.current.shift)
                    {
                        BlockEditor.actionList.Add(delegate {
                            flowchart.SelectedCommands.Remove(command);
                            flowchart.ClearSelectedCommands();
                        });
                    }

                    // Command key pressed
                    if (EditorGUI.actionKey)
                    {
                        BlockEditor.actionList.Add(delegate {
                            flowchart.SelectedCommands.Remove(command);
                        });
                        Event.current.Use();
                    }
                }
                else
                {
                    bool shift = Event.current.shift;

                    // Left click and no command key
                    if (!shift && !EditorGUI.actionKey && Event.current.button == 0)
                    {
                        BlockEditor.actionList.Add(delegate {
                            flowchart.ClearSelectedCommands();
                        });
                        Event.current.Use();
                    }

                    BlockEditor.actionList.Add(delegate {
                        flowchart.AddSelectedCommand(command);
                    });

                    // Find first and last selected commands
                    int firstSelectedIndex = -1;
                    int lastSelectedIndex  = -1;
                    if (flowchart.SelectedCommands.Count > 0)
                    {
                        if (flowchart.SelectedBlock != null)
                        {
                            for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++)
                            {
                                Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
                                foreach (Command selectedCommand in flowchart.SelectedCommands)
                                {
                                    if (commandInBlock == selectedCommand)
                                    {
                                        firstSelectedIndex = i;
                                        break;
                                    }
                                }
                            }
                            for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >= 0; i--)
                            {
                                Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
                                foreach (Command selectedCommand in flowchart.SelectedCommands)
                                {
                                    if (commandInBlock == selectedCommand)
                                    {
                                        lastSelectedIndex = i;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (shift)
                    {
                        int currentIndex = command.CommandIndex;
                        if (firstSelectedIndex == -1 ||
                            lastSelectedIndex == -1)
                        {
                            // No selected command found - select entire list
                            firstSelectedIndex = 0;
                            lastSelectedIndex  = currentIndex;
                        }
                        else
                        {
                            if (currentIndex < firstSelectedIndex)
                            {
                                firstSelectedIndex = currentIndex;
                            }
                            if (currentIndex > lastSelectedIndex)
                            {
                                lastSelectedIndex = currentIndex;
                            }
                        }

                        for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i)
                        {
                            var selectedCommand = flowchart.SelectedBlock.CommandList[i];
                            BlockEditor.actionList.Add(delegate {
                                flowchart.AddSelectedCommand(selectedCommand);
                            });
                        }
                    }

                    Event.current.Use();
                }
                GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus)
            }

            Color commandLabelColor = Color.white;

            if (flowchart.ColorCommands)
            {
                commandLabelColor = command.GetButtonColor();
            }

            if (commandIsSelected)
            {
                commandLabelColor = Color.green;
            }
            else if (!command.enabled)
            {
                commandLabelColor = Color.grey;
            }
            else if (error)
            {
                // TODO: Show warning icon
            }

            GUI.backgroundColor = commandLabelColor;

            if (isComment)
            {
                GUI.Label(commandLabelRect, "", commandLabelStyle);
            }
            else
            {
                string commandNameLabel;
                if (flowchart.ShowLineNumbers)
                {
                    commandNameLabel = command.CommandIndex.ToString() + ": " + commandName;
                }
                else
                {
                    commandNameLabel = commandName;
                }

                GUI.Label(commandLabelRect, commandNameLabel, commandLabelStyle);
            }

            if (command.ExecutingIconTimer > Time.realtimeSinceStartup)
            {
                Rect iconRect = new Rect(commandLabelRect);
                iconRect.x     += iconRect.width - commandLabelRect.width - 20;
                iconRect.width  = 20;
                iconRect.height = 20;

                Color storeColor = GUI.color;

                float alpha = (command.ExecutingIconTimer - Time.realtimeSinceStartup) / FungusConstants.ExecutingIconFadeTime;
                alpha = Mathf.Clamp01(alpha);

                GUI.color = new Color(1f, 1f, 1f, alpha);
                GUI.Label(iconRect, FungusEditorResources.PlaySmall, new GUIStyle());

                GUI.color = storeColor;
            }

            Rect summaryRect = new Rect(commandLabelRect);

            if (isComment)
            {
                summaryRect.x += 5;
            }
            else
            {
                summaryRect.x     += commandNameWidth + 5;
                summaryRect.width -= commandNameWidth + 5;
            }

            GUIStyle summaryStyle = new GUIStyle();

            summaryStyle.fontSize       = 10;
            summaryStyle.padding.top   += 5;
            summaryStyle.richText       = true;
            summaryStyle.wordWrap       = false;
            summaryStyle.clipping       = TextClipping.Clip;
            commandLabelStyle.alignment = TextAnchor.MiddleLeft;
            GUI.Label(summaryRect, summary, summaryStyle);

            if (error)
            {
                GUISkin editorSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
                Rect    errorRect  = new Rect(summaryRect);
                errorRect.x    += errorRect.width - 20;
                errorRect.y    += 2;
                errorRect.width = 20;
                GUI.Label(errorRect, editorSkin.GetStyle("CN EntryError").normal.background);
                summaryRect.width -= 20;
            }

            GUI.backgroundColor = Color.white;
        }
Beispiel #2
0
    public void OnGUI()
    {
        StringBuilder str = new StringBuilder();

        void Fix(GUISkin skin)
        {
            Font f = selected;

            //Font bold = Resources.Load<Font>(f.name + "b");
            //Font italic = Resources.Load<Font>(f.name + "i");
            //Font boldItalic = Resources.Load<Font>(f.name + "z");
            //if (bold == null) { bold = f; }
            //if (italic == null) { italic = f; }
            //if (boldItalic == null) { boldItalic = f; }

            skin.font                                = f;
            skin.box.font                            = f;
            skin.label.font                          = f;
            skin.button.font                         = f;
            skin.horizontalSlider.font               = f;
            skin.horizontalSliderThumb.font          = f;
            skin.horizontalScrollbar.font            = f;
            skin.horizontalScrollbarLeftButton.font  = f;
            skin.horizontalScrollbarRightButton.font = f;
            skin.horizontalScrollbarThumb.font       = f;
            skin.verticalSlider.font                 = f;
            skin.verticalSliderThumb.font            = f;
            skin.verticalScrollbar.font              = f;
            skin.verticalScrollbarUpButton.font      = f;
            skin.verticalScrollbarDownButton.font    = f;
            skin.verticalScrollbarThumb.font         = f;
            skin.toggle.font                         = f;
            skin.scrollView.font                     = f;
            skin.textArea.font                       = f;
            skin.textField.font                      = f;
            skin.window.font                         = f;

            foreach (var s in skin.customStyles)
            {
                if (go)
                {
                    str.Append($"Style {s} in {skin}\n");
                }

                if (s.name.ToLower().Contains("bold"))
                {
                    s.fontStyle = FontStyle.Bold;
                }
                s.font = f;
            }
        }

        Vector2 size = minSize;

        size.y  = 24;
        minSize = size;

        selected = (Font)EditorGUILayout.ObjectField("Font: ", selected, typeof(Font), false);
        go       = GUILayout.Toggle(go, "Dump font styles to './dump.txt' ");

        if (selected != null)
        {
            GUISkin skin;
            // this method may only be called during OnGUI()...
            skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
            Fix(skin);
            skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Game);
            Fix(skin);
            skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            Fix(skin);
        }

        if (go)
        {
            go = false;
            File.WriteAllText("Dump.txt", str.ToString());
            Debug.Log(str);
        }
    }
Beispiel #3
0
        static Styles()
        {
            ManagerFamily.alignment = TextAnchor.MiddleCenter;

            ManagerChild.fontSize    = 10;
            ManagerChild.fixedHeight = 20;
            foreach (var gui in ManagerHeader)
            {
                gui.fontSize = 10;
            }
            ImporterPresetArea.wordWrap       = true;
            ImporterOptionFontStyle.alignment = TextAnchor.MiddleCenter;
            FontPreviewEnabled.alignment      = TextAnchor.MiddleCenter;
            FontPreviewSymbols.alignment      = TextAnchor.MiddleCenter;
            FontPreviewRelation.alignment     = TextAnchor.MiddleCenter;
            FontPreviewDisabled.alignment     = TextAnchor.MiddleCenter;
            FontPreviewRelation.fixedHeight   = 0;
            FontPreviewRelation.onActive      = FontPreviewEnabled.onActive;
            FontPreviewRelation.onNormal      = FontPreviewRelation.focused;
            FontPreviewRelation.focused       = FontPreviewEnabled.focused;

            SetterTitle.fontStyle      = FontStyle.Bold;
            SetterTitle.fontSize       = 16;
            SetterTitle.fixedHeight    = 25;
            SetterFont.richText        = true;
            SetterPreview.fontSize     = 34;
            SetterPreview.alignment    = TextAnchor.MiddleCenter;
            SetterNextLarger.fontSize  = 24;
            SetterNextLarger.alignment = TextAnchor.MiddleCenter;

            SetterExtendTop.fontSize     = 24;
            SetterExtendTop.alignment    = TextAnchor.MiddleCenter;
            SetterExtendMiddle.fontSize  = 24;
            SetterExtendMiddle.alignment = TextAnchor.MiddleCenter;
            SetterExtendBottom.fontSize  = 24;
            SetterExtendBottom.alignment = TextAnchor.MiddleCenter;
            SetterExtendRepeat.fontSize  = 24;
            SetterExtendRepeat.alignment = TextAnchor.MiddleCenter;

            for (int i = 0; i < 33; i++)
            {
                SetterCharMap[i]    = new GUIContent(new string(TexChar.possibleCharMaps[i], 1));
                SetterCharMapInt[i] = i;
            }
            SetterCharMap[0].text  = "(Unassigned)"; //Yeah, just space isn't funny
            SetterCharMap[4].text  = "\\\\";         //It can't be rendered correctly using actual character
            SetterCharMap[27].text = "&&";           //The ampersand character need to be done like this
            HeaderTitles           = new GUIContent[4]
            {
                new GUIContent("Characters"),
                new GUIContent("Configurations"),
                new GUIContent("Materials"),
                new GUIContent("Glue Matrix")
            };
            for (int i = 0; i < 4; i++)
            {
                HeaderStyles[i].fontSize    = 12;
                HeaderStyles[i].fixedHeight = 24;
            }

            GlueLabelH.alignment = TextAnchor.MiddleRight;
            GlueLabelV.alignment = TextAnchor.MiddleLeft;

            GlueProgBack           = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("ProgressBarBack");
            GlueProgBar            = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("ProgressBarBar");
            GlueProgText           = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("ProgressBarText");
            GlueProgText.alignment = TextAnchor.MiddleCenter;
            Buttons.alignment      = TextAnchor.MiddleCenter;
            Buttons.fontSize       = 11;
        }
Beispiel #4
0
 public static GUIStyle GetEditorStyle(string name)
 {
     return(EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).GetStyle(name));
 }
        public static bool SplineCPSelector(Vector3[] positions,
                                            bool[] selectionStatus)
        {
            Matrix4x4 cachedMatrix = Handles.matrix;

            int  controlID              = GUIUtility.GetControlID(splineSelectorHash, FocusType.Passive);
            int  selectedCPIndex        = -1;
            bool selectionStatusChanged = false;

            // select vertex on mouse click:
            switch (Event.current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown: {
                if ((Event.current.modifiers & EventModifiers.Control) == 0 &&
                    (HandleUtility.nearestControl != controlID || Event.current.button != 0))
                {
                    break;
                }

                startPos = Event.current.mousePosition;
                marquee.Set(0, 0, 0, 0);

                // If the user is pressing shift, accumulate selection.
                if ((Event.current.modifiers & EventModifiers.Shift) == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
                {
                    for (int i = 0; i < selectionStatus.Length; i++)
                    {
                        selectionStatus[i] = false;
                    }
                }

                // If the user is holding down control, dont allow selection of other objects and use marquee tool.
                if ((Event.current.modifiers & EventModifiers.Control) != 0)
                {
                    GUIUtility.hotControl = controlID;
                }

                float minSqrDistance = System.Single.MaxValue;

                for (int i = 0; i < positions.Length; i++)
                {
                    // get particle position in gui space:
                    Vector2 pos = HandleUtility.WorldToGUIPoint(positions[i]);

                    // get distance from mouse position to particle position:
                    float sqrDistance = Vector2.SqrMagnitude(startPos - pos);

                    // check if this control point is closer to the cursor that any previously considered point.
                    if (sqrDistance < 100 && sqrDistance < minSqrDistance)              //magic number 100 = 10*10, where 10 is min distance in pixels to select a particle.
                    {
                        minSqrDistance  = sqrDistance;
                        selectedCPIndex = i;
                    }
                }

                if (selectedCPIndex >= 0)          // toggle particle selection status.

                {
                    selectionStatus[selectedCPIndex] = !selectionStatus[selectedCPIndex];
                    selectionStatusChanged           = true;

                    // Prevent spline deselection if we have selected a particle:
                    GUIUtility.hotControl = controlID;
                    Event.current.Use();
                }
                else if (Event.current.modifiers == EventModifiers.None)          // deselect all particles:
                {
                    for (int i = 0; i < selectionStatus.Length; i++)
                    {
                        selectionStatus[i] = false;
                    }

                    selectionStatusChanged = true;
                }
            } break;

            case EventType.MouseDrag:

                if (GUIUtility.hotControl == controlID)
                {
                    currentPos = Event.current.mousePosition;
                    if (!dragging && Vector2.Distance(startPos, currentPos) > 5)
                    {
                        dragging = true;
                    }
                    else
                    {
                        GUIUtility.hotControl = controlID;
                        Event.current.Use();
                    }

                    //update marquee rect:
                    float left   = Mathf.Min(startPos.x, currentPos.x);
                    float right  = Mathf.Max(startPos.x, currentPos.x);
                    float bottom = Mathf.Min(startPos.y, currentPos.y);
                    float top    = Mathf.Max(startPos.y, currentPos.y);

                    marquee = new Rect(left, bottom, right - left, top - bottom);
                }

                break;

            case EventType.MouseUp:

                if (GUIUtility.hotControl == controlID)
                {
                    dragging = false;

                    for (int i = 0; i < positions.Length; i++)
                    {
                        // get particle position in gui space:
                        Vector2 pos = HandleUtility.WorldToGUIPoint(positions[i]);

                        if (pos.x > marquee.xMin && pos.x < marquee.xMax && pos.y > marquee.yMin && pos.y < marquee.yMax)
                        {
                            selectionStatus[i]     = true;
                            selectionStatusChanged = true;
                        }
                    }

                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }

                break;

            case EventType.Repaint:

                Handles.matrix = Matrix4x4.identity;

                if (dragging)
                {
                    GUISkin oldSkin = GUI.skin;
                    GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
                    Handles.BeginGUI();
                    GUI.Box(new Rect(marquee.xMin, marquee.yMin, marquee.width, marquee.height), "");
                    Handles.EndGUI();
                    GUI.skin = oldSkin;
                }

                Handles.matrix = cachedMatrix;

                break;


            case EventType.Layout: {
                Handles.matrix = Matrix4x4.identity;

                float minSqrDistance = System.Single.MaxValue;

                for (int i = 0; i < positions.Length; i++)
                {
                    // get particle position in gui space:
                    Vector2 pos = HandleUtility.WorldToGUIPoint(positions[i]);

                    // get distance from mouse position to particle position:
                    float sqrDistance = Vector2.SqrMagnitude(Event.current.mousePosition - pos);

                    // check if this control point is closer to the cursor that any previously considered point.
                    if (sqrDistance < 100 && sqrDistance < minSqrDistance)              //magic number 100 = 10*10, where 10 is min distance in pixels to select a particle.
                    {
                        minSqrDistance = sqrDistance;
                    }
                }

                HandleUtility.AddControl(controlID, Mathf.Sqrt(minSqrDistance));
                Handles.matrix = cachedMatrix;
            } break;
            }

            return(selectionStatusChanged);
        }
Beispiel #6
0
        /// <summary> Main GUI Function </summary>
        /// <param name="position">Rect to draw this property in</param>
        /// <param name="property">Property to edit</param>
        /// <param name="label">Display GUIContent of Property</param>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            bool hasChanged          = false;
            int  originalIndentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            EditorGUI.BeginProperty(position, label, property);
            GUISkin editorSkin = null;

            if (Event.current.type == EventType.Repaint)
            {
                editorSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            }

            SerializedProperty nameProp         = property.FindPropertyRelative("m_name");
            SerializedProperty startProp        = property.FindPropertyRelative("m_min");
            SerializedProperty endProp          = property.FindPropertyRelative("m_max");
            SerializedProperty startFalloffProp = property.FindPropertyRelative("m_minFalloff");
            SerializedProperty endFalloffProp   = property.FindPropertyRelative("m_maxFalloff");
            SerializedProperty invertProp       = property.FindPropertyRelative("m_invert");

            Vector2 nameSize = new Vector2(EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight);
            Rect    nameRect = new Rect(position.position, nameSize);

            nameRect.xMin += originalIndentLevel * 15f;
            float minMaxWidth = Mathf.Min(80f, ((position.width - nameRect.width) * 0.3f + 10f) * 0.5f);
            Rect  minRect     = new Rect(nameRect.xMax, position.y, minMaxWidth, nameSize.y);
            Rect  maxRect     = new Rect(position.xMax - minMaxWidth, position.y, minMaxWidth, nameSize.y);

            EditorGUI.BeginChangeCheck();
            string newName = EditorGUI.TextField(nameRect, nameProp.stringValue);

            if (string.IsNullOrEmpty(newName))
            {
                EditorGUI.LabelField(nameRect, "Name", EditorStyles.centeredGreyMiniLabel);
            }
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged           = true;
                nameProp.stringValue = newName;
            }
            float start = startProp.floatValue, end = endProp.floatValue;

            EditorGUI.BeginChangeCheck();
            start = EditorGUI.FloatField(minRect, start);
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
                if (start > end)
                {
                    start = end;
                }
                startProp.floatValue = Mathf.Clamp01(start);
            }
            EditorGUI.BeginChangeCheck();
            end = EditorGUI.FloatField(maxRect, end);
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
                if (end < start)
                {
                    end = start;
                }
                endProp.floatValue = Mathf.Clamp01(end);
            }
            #region Slider
            Rect  barRect     = new Rect(minRect.xMax + 5f, position.y, maxRect.xMin - minRect.xMax - 10f, nameSize.y);
            float totalWidth  = barRect.width - 11f;
            float totalHeight = barRect.height;
            Rect  drawRect    = new Rect(barRect.x + totalWidth * startProp.floatValue, barRect.y + totalHeight * 0.165f, totalWidth * (endProp.floatValue - startProp.floatValue) + 10f, totalHeight * 0.67f);
            //Check for Events
            Rect sliderPanRect   = new Rect(drawRect.xMin + 5f, drawRect.y, drawRect.width - 10f, totalHeight * 0.67f);
            Rect sliderEndRect   = new Rect(drawRect.xMax - 5f, drawRect.y, 5f, totalHeight * 0.67f);
            Rect sliderBeginRect = new Rect(drawRect.xMin, drawRect.y, 5f, totalHeight * 0.67f);
            #region Mouse Events
            EditorGUIUtility.AddCursorRect(sliderEndRect, MouseCursor.SplitResizeLeftRight);
            EditorGUIUtility.AddCursorRect(sliderBeginRect, MouseCursor.SplitResizeLeftRight);
            //check for drag of either ends or slider
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if (sliderEndRect.Contains(Event.current.mousePosition))
                {
                    isDraggingThis           = true;
                    curSliderEditingStartPos = Event.current.mousePosition.x;
                    curSliderEditingStartMax = endProp.floatValue;
                    curSliderEditingType     = 3;
                    Event.current.Use();
                }
                else if (sliderBeginRect.Contains(Event.current.mousePosition))
                {
                    isDraggingThis           = true;
                    curSliderEditingStartPos = Event.current.mousePosition.x;
                    curSliderEditingStartMin = startProp.floatValue;
                    curSliderEditingType     = 2;
                    Event.current.Use();
                }
                else if (sliderPanRect.Contains(Event.current.mousePosition))
                {
                    isDraggingThis           = true;
                    curSliderEditingStartPos = Event.current.mousePosition.x;
                    curSliderEditingStartMin = startProp.floatValue;
                    curSliderEditingStartMax = endProp.floatValue;
                    curSliderEditingType     = 1;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDrag && isDraggingThis)
            {
                hasChanged = true;
                float moveAmount = (Event.current.mousePosition.x - curSliderEditingStartPos) / totalWidth;
                switch (curSliderEditingType)
                {
                case 1:
                    moveAmount           = Mathf.Clamp(moveAmount, -curSliderEditingStartMin, 1f - curSliderEditingStartMax);
                    startProp.floatValue = Mathf.Clamp(curSliderEditingStartMin + moveAmount, 0f, 1f);
                    endProp.floatValue   = Mathf.Clamp(curSliderEditingStartMax + moveAmount, 0f, 1f);
                    break;

                case 2:
                    startProp.floatValue = Mathf.Clamp(curSliderEditingStartMin + moveAmount, 0f, endProp.floatValue);
                    break;

                case 3:
                    endProp.floatValue = Mathf.Clamp(curSliderEditingStartMax + moveAmount, startProp.floatValue, 1f);
                    break;

                default:
                    break;
                }
                Event.current.Use();
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                isDraggingThis           = false;
                curSliderEditingType     = 0;
                curSliderEditingStartPos = 0f;
                curSliderEditingStartMin = 0f;
                curSliderEditingStartMax = 0f;
            }
            #endregion
            //Draw slider (Repaint event only)
            if (Event.current.type == EventType.Repaint)
            {
                editorSkin.horizontalSlider.Draw(barRect, false, false, false, false);
                if (!invertProp.boolValue)   //normal display
                {
                    editorSkin.button.Draw(drawRect, false, false, false, false);
                }
                else     //invert display
                {
                    GUIStyle leftButton  = editorSkin.GetStyle("ButtonLeft") ?? editorSkin.button;
                    GUIStyle rightButton = editorSkin.GetStyle("ButtonRight") ?? editorSkin.button;
                    Rect     drawRect2   = drawRect;
                    drawRect2.xMin = drawRect.xMax - 5f;
                    drawRect2.xMax = barRect.xMax + 4f;
                    drawRect.xMax  = drawRect.xMin + 5f;
                    drawRect.xMin  = barRect.xMin - 5f;
                    if (startProp.floatValue > 0f)
                    {
                        rightButton.Draw(drawRect, false, false, false, false);
                    }
                    if (endProp.floatValue < 1f)
                    {
                        leftButton.Draw(drawRect2, false, false, false, false);
                    }
                }
            }
            #endregion

            nameRect.y += nameRect.height + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.BeginChangeCheck();
            invertProp.boolValue = EditorGUI.ToggleLeft(nameRect, invertProp.displayName, invertProp.boolValue);
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
            }
            minRect.y = nameRect.y;
            GUI.Label(minRect, "Falloff");
            Rect falloffRect = new Rect(minRect.xMax, nameRect.y, (maxRect.xMax - minRect.xMax - EditorGUIUtility.standardVerticalSpacing) / 2f, nameSize.y);
            EditorGUI.BeginChangeCheck();
            startFalloffProp.floatValue = Mathf.Clamp01(EditorGUI.FloatField(falloffRect, startFalloffProp.floatValue));
            falloffRect.x            += falloffRect.width + EditorGUIUtility.standardVerticalSpacing;
            endFalloffProp.floatValue = Mathf.Clamp01(EditorGUI.FloatField(falloffRect, endFalloffProp.floatValue));
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
            }
            EditorGUI.EndProperty();
            EditorGUI.indentLevel = originalIndentLevel;
            if (hasChanged && MainWindowEditor.Instance != null)
            {
                MainWindowEditor.Instance.Repaint();
            }
        }
Beispiel #7
0
 public static GUIStyle GetEditorStyle(string style)
 {
     return(EditorGUIUtility.GetBuiltinSkin(EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector).GetStyle(style));
 }
Beispiel #8
0
 public override void OnInspectorGUI()
 {
     GUI.skin =
         EditorGUIUtility.GetBuiltinSkin(UnityEditor.EditorSkin.Inspector);
     DrawDefaultInspector();
 }
    public override void OnEditorGui()
    {
#if UNITY_EDITOR
        if (gui.Button("Clean Editor SKin"))
        {
            foreach (GUIStyle a in editorSkin)
            {
                GetValue(a.focused);
                GetValue(a.active);
                GetValue(a.hover);
                GetValue(a.normal);
                GetValue(a.onActive);
                GetValue(a.onFocused);
                GetValue(a.onHover);
                GetValue(a.onNormal);
            }
        }

        //if (GUILayout.Button("Fix Skin"))
        //{
        //    foreach (GUIStyle a in skin)
        //    {
        //        print(a.name);
        //        a.onNormal.background = a.normal.background;
        //    }
        //    UnityEditor.EditorUtility.SetDirty(skin);
        //    foreach (SkinSet a in resEditor.skins)
        //    {
        //        foreach (GUIStyle b in a.skin)
        //            b.onNormal.background = b.normal.background;
        //        UnityEditor.EditorUtility.SetDirty(a.skin);
        //    }

        //}
        if (gui.Button("Save Skin"))
        {
            var builtinSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            var instantiate = (GUISkin)Instantiate(builtinSkin);

            var dps = EditorUtility.CollectDependencies(new Object[] { instantiate });
            foreach (var a in dps)
            {
                print(a);

                if (a is Texture2D)
                {
                    //Texture2D texture2D = (a as Texture2D);
                    //texture2D.Apply(false,false);
                    //texture2D.LoadImage()
                    AssetDatabase.CreateAsset(Instantiate(a), "Assets/EditorSkin/" + a.name + ".asset");
                    //File.WriteAllBytes("Assets/EditorSkin/" + a.name + ".png", texture2D.EncodeToPNG());
                }
            }
            //print(dps.Length);
            //foreach (GUIStyle a in instantiate)
            //{
            //    SaveStyle(a);
            //}
            //AssetDatabase.CreateAsset(instantiate, "Assets/EditorSkin.guiskin");
        }
        base.OnEditorGui();
#endif
    }
        void DrawSingleGroup()
        {
            EditorGUILayout.LabelField("Group Template Description");
            m_AddressableAssetGroupTarget.Description = EditorGUILayout.TextArea(m_AddressableAssetGroupTarget.Description);

            int objectCount = m_AddressableAssetGroupTarget.SchemaObjects.Count;

            if (m_FoldoutState == null || m_FoldoutState.Length != objectCount)
            {
                m_FoldoutState = new bool[objectCount];
            }

            for (int i = 0; i < objectCount; i++)
            {
                var schema       = m_AddressableAssetGroupTarget.SchemaObjects[i];
                int currentIndex = i;

                DrawDivider();
                EditorGUILayout.BeginHorizontal();
                m_FoldoutState[i] = EditorGUILayout.Foldout(m_FoldoutState[i], AddressableAssetUtility.GetCachedTypeDisplayName(m_AddressableAssetGroupTarget.SchemaObjects[i].GetType()));

                GUILayout.FlexibleSpace();
                GUIStyle gearIconStyle = UnityEngine.GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton");

                if (EditorGUILayout.DropdownButton(EditorGUIUtility.IconContent("_Popup"), FocusType.Keyboard, gearIconStyle))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(AddressableAssetGroup.RemoveSchemaContent, false, () =>
                    {
                        var schemaName = AddressableAssetUtility.GetCachedTypeDisplayName(m_AddressableAssetGroupTarget.SchemaObjects[currentIndex].GetType());
                        if (EditorUtility.DisplayDialog("Remove selected schema?", "Are you sure you want to remove " + schemaName + " schema?\n\nYou cannot undo this action.", "Yes", "No"))
                        {
                            m_AddressableAssetGroupTarget.RemoveSchema(currentIndex);
                            var newFoldoutstate = new bool[objectCount - 1];
                            for (int j = 0; j < newFoldoutstate.Length; j++)
                            {
                                if (j < i)
                                {
                                    newFoldoutstate[j] = m_FoldoutState[j];
                                }
                                else
                                {
                                    newFoldoutstate[j] = m_FoldoutState[currentIndex + 1];
                                }
                            }

                            m_FoldoutState = newFoldoutstate;
                        }
                    });
                    menu.AddItem(AddressableAssetGroup.MoveSchemaUpContent, false, () =>
                    {
                        if (currentIndex > 0)
                        {
                            m_AddressableAssetGroupTarget.SchemaObjects[currentIndex]     = m_AddressableAssetGroupTarget.SchemaObjects[currentIndex - 1];
                            m_AddressableAssetGroupTarget.SchemaObjects[currentIndex - 1] = schema;
                            return;
                        }
                    });
                    menu.AddItem(AddressableAssetGroup.MoveSchemaDownContent, false, () =>
                    {
                        if (currentIndex < m_AddressableAssetGroupTarget.SchemaObjects.Count - 1)
                        {
                            m_AddressableAssetGroupTarget.SchemaObjects[currentIndex]     = m_AddressableAssetGroupTarget.SchemaObjects[currentIndex + 1];
                            m_AddressableAssetGroupTarget.SchemaObjects[currentIndex + 1] = schema;
                            return;
                        }
                    });
                    menu.AddSeparator("");
                    menu.AddItem(AddressableAssetGroup.ExpandSchemaContent, false, () =>
                    {
                        m_FoldoutState[currentIndex] = true;
                        m_AddressableAssetGroupTarget.SchemaObjects[currentIndex].ShowAllProperties();
                    });
                    menu.ShowAsContext();
                }

                EditorGUILayout.EndHorizontal();

                if (m_FoldoutState[i])
                {
                    try
                    {
                        EditorGUI.indentLevel++;
                        m_AddressableAssetGroupTarget.SchemaObjects[i].OnGUI();
                        EditorGUI.indentLevel--;
                    }
                    catch (Exception se)
                    {
                        Debug.LogException(se);
                    }
                }
            }

            DrawDivider();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUIStyle addSchemaButton = new GUIStyle(UnityEngine.GUI.skin.button);

            addSchemaButton.fontSize    = 12;
            addSchemaButton.fixedWidth  = 225;
            addSchemaButton.fixedHeight = 22;

            if (EditorGUILayout.DropdownButton(new GUIContent("Add Schema", "Add new schema to this group."), FocusType.Keyboard, addSchemaButton))
            {
                var menu = new GenericMenu();
                for (int i = 0; i < m_SchemaTypes.Count; i++)
                {
                    var type = m_SchemaTypes[i];

                    if (Array.IndexOf(m_AddressableAssetGroupTarget.GetTypes(), type) == -1)
                    {
                        menu.AddItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), false, () => OnAddSchema(type));
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), true);
                    }
                }

                menu.ShowAsContext();
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Beispiel #11
0
        public override void OnInspectorGUI()
        {
            xFur = (XFur_System)target;



            if (xFur.coatingModule != null)
            {
                xFur.coatingModule.Module_StartUI(pidiSkin2);
            }


            if (xFur.lodModule != null)
            {
                xFur.lodModule.Module_StartUI(pidiSkin2);
            }


            if (xFur.physicsModule != null)
            {
                xFur.physicsModule.Module_StartUI(pidiSkin2);
            }


            if (xFur.fxModule != null)
            {
                xFur.fxModule.Module_StartUI(pidiSkin2);
            }

            Undo.RecordObject(xFur, "XFUR_" + xFur.GetInstanceID());



            var tSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

            GUI.skin = pidiSkin;



            var buffDatabase = xFur.database;

            GUILayout.BeginHorizontal(); GUILayout.BeginVertical(pidiSkin2.box);
            AssetLogoAndVersion();
            GUILayout.Space(8);
            GUILayout.BeginHorizontal(); GUILayout.Space(12); GUILayout.BeginVertical();
            xFur.database = ObjectField <XFur_DatabaseModule>(new GUIContent("XFUR DATABASE ASSET", "The XFur Database asset, required for LOD management, mesh handling and most other internal features"), xFur.database, false);
            GUILayout.Space(8);

            if (buffDatabase != xFur.database && xFur.database != null)
            {
                xFur.XFur_UpdateMeshData();
                xFur.XFur_Start();
            }

            var tempTarget = xFur.manualMeshIndex;

            xFur.manualMeshIndex = EnableDisableToggle(new GUIContent("EXPLICIT MODEL INDEX", "Use an explicit index on the database to get the mesh data from instead of automatically linking XFur to the database through Mesh ID. In most cases, you should leave this toggle disabled"), xFur.manualMeshIndex != -1)?Mathf.Max(xFur.manualMeshIndex, 0):-1;

            if (xFur.manualMeshIndex != -1)
            {
                if (xFur.database.meshData.Length < 1)
                {
                    xFur.manualMeshIndex = -1;
                }
                xFur.manualMeshIndex = PopupField(new GUIContent("EXPLICIT DATABASE INDEX"), xFur.manualMeshIndex, xFur.database.GetMeshNames());
                xFur.manualMeshIndex = Mathf.Clamp(xFur.manualMeshIndex, 0, xFur.database.meshData.Length - 1);
            }

            if (tempTarget != xFur.manualMeshIndex)
            {
                xFur.XFur_UpdateMeshData();
            }

            if (!xFur.database)
            {
                GUILayout.BeginHorizontal(); GUILayout.Space(12);
                EditorGUILayout.HelpBox("Please assign the XFur Database Asset to this component. It is required for internal functions and its absence can make this software unstable", MessageType.Error);
                GUILayout.Space(12); GUILayout.EndHorizontal();
                GUILayout.Space(8);

                GUILayout.EndVertical(); GUILayout.Space(12);
                GUILayout.EndHorizontal();
            }
            else
            {
                if (xFur.database.XFur_ContainsMeshData(xFur.OriginalMesh) != -1)
                {
                    if (xFur.database.meshData[xFur.database.XFur_ContainsMeshData(xFur.OriginalMesh)].XFurVersion != xFur.Version)
                    {
                        GUILayout.BeginHorizontal(); GUILayout.Space(12);
                        EditorGUILayout.HelpBox("The current XFur version you are using does not match the version of the data stored in the database asset. You need to rebuild this data", MessageType.Error);
                        GUILayout.Space(12); GUILayout.EndHorizontal();
                        GUILayout.Space(8);

                        if (CenteredButton("REBUILD DATA", 200))
                        {
                            xFur.database.XFur_DeleteMeshData(xFur.database.XFur_ContainsMeshData(xFur.OriginalMesh));
                            xFur.XFur_UpdateMeshData();
                        }

                        GUILayout.Space(8);
                    }
                    else
                    {
                        GUILayout.Space(8);
                        if (CenteredButton("REBUILD DATA", 200))
                        {
                            xFur.database.XFur_DeleteMeshData(xFur.database.XFur_ContainsMeshData(xFur.OriginalMesh));
                            xFur.XFur_UpdateMeshData();
                        }

                        GUILayout.Space(8);
                    }
                }

                GUILayout.EndVertical(); GUILayout.Space(12);
                GUILayout.EndHorizontal();

                if (BeginCenteredGroup("XFUR - MAIN SETTINGS", ref xFur.folds[0]))
                {
                    GUILayout.Space(16);

                    xFur.updateDynamically = EnableDisableToggle(new GUIContent("DYNAMIC UPDATES", "Enable this if you plan on making dynamic changes to the fur at runtime. If you are using the FX or Physics module, disable it for better performance."), xFur.updateDynamically);

                    xFur.materialProfileIndex = PopupField(new GUIContent("MATERIAL SLOT", "The material we are currently editing"), xFur.materialProfileIndex, xFur.FurMatGUIS);

                    GUILayout.Space(8);
                    xFur.materialProfiles[xFur.materialProfileIndex].originalMat = ObjectField <Material>(new GUIContent("BASE FUR MATERIAL", "The fur material that will be used as a reference by this instance"), xFur.materialProfiles[xFur.materialProfileIndex].originalMat, false);
                    GUILayout.Space(8);

                    if (xFur.materialProfiles[xFur.materialProfileIndex].buffOriginalMat != xFur.materialProfiles[xFur.materialProfileIndex].originalMat || xFur.GetComponent <Renderer>().sharedMaterials[xFur.materialProfileIndex] == null || !xFur.GetComponent <Renderer>().sharedMaterials[xFur.materialProfileIndex].name.Contains(xFur.materialProfiles[xFur.materialProfileIndex].originalMat.name) || !xFur.GetComponent <Renderer>().sharedMaterials[xFur.materialProfileIndex].shader.name.Contains("XFUR"))
                    {
                        xFur.UpdateSharedData(xFur.materialProfiles[xFur.materialProfileIndex]);
                        xFur.materialProfiles[xFur.materialProfileIndex].SynchToOriginalMat();
                        xFur.XFur_UpdateMeshData();
                    }

                    GUILayout.Space(4);
                    if (xFur.materialProfiles[xFur.materialProfileIndex].originalMat && xFur.materialProfiles[xFur.materialProfileIndex].furmatType == 2)
                    {
                        if ((!Application.isPlaying || !xFur.instancedMode) && xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode == 0)
                        {
                            if (XFur_System.materialReferences.ContainsKey(xFur.materialProfiles[xFur.materialProfileIndex].originalMat))
                            {
                                var samples = new List <GUIContent>();


                                for (int i = 0; i < xFur.database.highQualityShaders.Length; i++)
                                {
                                    var shaderName = XFur_System.materialReferences[xFur.materialProfiles[xFur.materialProfileIndex].originalMat][i].shader.name.ToUpper();
                                    samples.Add(new GUIContent(shaderName.Split("/"[0])[shaderName.Split("/"[0]).Length - 1]));
                                }

                                if (xFur.lodModule.State == XFurModuleState.Enabled)
                                {
                                    samples.Clear();
                                    samples.Add(new GUIContent("LOD DRIVEN"));
                                    var n = 0;
                                    n = PopupField(new GUIContent("FUR SAMPLES", "The amount of samples to use on this shader"), n, new GUIContent[] { new GUIContent("LOD Driven") });

                                    if (!Application.isPlaying)
                                    {
                                        xFur.materialProfiles[xFur.materialProfileIndex].furmatSamples = 2;
                                    }
                                }
                                else
                                {
                                    xFur.materialProfiles[xFur.materialProfileIndex].furmatSamples = PopupField(new GUIContent("FUR SAMPLES", "The amount of samples to use on this shader"), xFur.materialProfiles[xFur.materialProfileIndex].furmatSamples, samples.ToArray());
                                }
                            }
                        }
                        else
                        {
                            if ((xFur.lodModule == null || (xFur.lodModule != null && xFur.lodModule.State != XFurModuleState.Enabled)) && xFur.runMaterialReferences.ContainsKey(xFur.materialProfiles[xFur.materialProfileIndex].originalMat))
                            {
                                var samples = new List <GUIContent>();


                                if (xFur.lodModule.State == XFurModuleState.Enabled)
                                {
                                    samples.Clear();
                                    samples.Add(new GUIContent("LOD DRIVEN"));
                                }

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatSamples = PopupField(new GUIContent("FUR SAMPLES", "The amount of samples to use on this shader"), xFur.materialProfiles[xFur.materialProfileIndex].furmatSamples, samples.ToArray());
                            }
                            else
                            {
                                var n = 0;
                                n = PopupField(new GUIContent("FUR SAMPLES", "The amount of samples to use on this shader"), n, new GUIContent[] { new GUIContent("LOD Driven") });
                            }
                        }

                        var s = xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode;

                        xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode = PopupField(new GUIContent("SHADOWS MODE", "Switches between the different shadow modes for the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode, new GUIContent[] { new GUIContent("STANDARD SHADOWS", "Simple shadow casting on forward and deferred with full shadow reception enabled only for deferred rendering"), new GUIContent("(BETA) FULL SHADOWS", "Expensive method of full shadowing in forward and deferred that adds accurate shadows in casting and receiving mode based on each fur strand and layer") });

                        if (s == 1)
                        {
                            GUILayout.BeginHorizontal(); GUILayout.Space(12);
                            EditorGUILayout.HelpBox("Full shadows generate additional geometry and sub renderers, making it VERY expensive to compute. DO NOT use them on scenes with more than a couple characters nor in models with more than 6-10k polygons", MessageType.Warning);
                            GUILayout.Space(12); GUILayout.EndHorizontal();
                            GUILayout.Space(8);

                            var tempF = (int)xFur.materialProfiles[xFur.materialProfileIndex].fullShadowLayers;
                            tempF = IntSliderField(new GUIContent("FUR SAMPLES"), tempF, 6, 32);
                            xFur.materialProfiles[xFur.materialProfileIndex].fullShadowLayers = tempF;
                        }

                        if (s != xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode && xFur.materialProfiles[xFur.materialProfileIndex].furmatShadowsMode == 1)
                        {
                            xFur.XFur_GenerateShadowMesh(xFur.materialProfiles[xFur.materialProfileIndex]);
                        }


                        if (xFur.FurMaterials == 1
#if UNITY_2018_1_OR_NEWER
                            || true
#endif
                            )
                        {
                            GUILayout.Space(8);

                            //EnableDisableToggle( new GUIContent("Static Material", "If this fur material will not change its length, thickness, color, etc. at runtime it is recommended to toggle this value to handle the material as a static instance for better performance" ), ref xFur.instancedMode );
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatCollision        = EnableDisableToggle(new GUIContent("BASIC SELF-COLLISION", "Performs a basic self-collision algorithm on the shader to avoid (with a low precision) the fur from going inside the mesh"), xFur.materialProfiles[xFur.materialProfileIndex].furmatCollision == 1) ? 1 : 0;
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatRenderSkin       = EnableDisableToggle(new GUIContent("BASE SKIN PASS", "Render the skin layer under the fur for this material"), xFur.materialProfiles[xFur.materialProfileIndex].furmatRenderSkin == 1) ? 1 : 0;
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanar        = EnableDisableToggle(new GUIContent("TRIPLANAR MODE", "Render fur using triplanar coordinates generated at runtime instead of the secondary UV channel of this mesh"), xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanar == 1) ? 1 : 0;
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatForceUV2Grooming = EnableDisableToggle(new GUIContent("GROOM MAP ON UV2", "Forces triplanar coordinates to be used for fur projection, using the secondary UV map as coordinates for grooming instead"), xFur.materialProfiles[xFur.materialProfileIndex].furmatForceUV2Grooming == 1) ? 1 : 0;

                            if (xFur.materialProfiles[xFur.materialProfileIndex].furmatForceUV2Grooming == 1)
                            {
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanar = 1;
                            }

                            GUILayout.Space(8);

                            if (xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanar == 1)
                            {
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanarScale = SliderField(new GUIContent("TRIPLANAR SCALE", "The scale used for the triplanar projection of the fur, multiplied by the fur UV1 and UV2 channels' sizes"), xFur.materialProfiles[xFur.materialProfileIndex].furmatTriplanarScale, 0.0f, 1.0f);
                            }


                            GUILayout.Space(8);

                            xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseSkin = PopupField(new GUIContent("BASE SKIN MODE", "The mode in which the skin color and specularity are controlled for this instance"), xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseSkin, new GUIContent[] { new GUIContent("FROM MATERIAL"), new GUIContent("FROM INSTANCE") });
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseFur  = PopupField(new GUIContent("FUR SETTINGS MODE", "The mode in which the fur parameters are controlled for this instance"), xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseFur, new GUIContent[] { new GUIContent("FROM MATERIAL"), new GUIContent("FROM INSTANCE") });
                            xFur.materialProfiles[xFur.materialProfileIndex].furmatReadFurNoise = PopupField(new GUIContent("FUR GEN MAP", "The mode in which the fur noise map is controlled for this instance"), xFur.materialProfiles[xFur.materialProfileIndex].furmatReadFurNoise, new GUIContent[] { new GUIContent("FROM MATERIAL"), new GUIContent("FROM INSTANCE") });

                            GUILayout.Space(8);

                            XFur_CoatingProfile t = null;
                            t = ObjectField <XFur_CoatingProfile>(new GUIContent("LOAD FUR PROFILE", "Allows you to assign a pre-made fur profile to easily load existing settings, colors, etc"), t, false);

                            if (t != null)
                            {
                                xFur.LoadXFurProfileAsset(t, xFur.materialProfileIndex);
                            }

                            GUILayout.Space(16);
                            if (CenteredButton("EXPORT FUR SETTINGS", 200))
                            {
                                var k = xFur.XFur_ExportMaterialProfile(xFur.materialProfiles[xFur.materialProfileIndex]);
                                if (k)
                                {
                                    var path = EditorUtility.SaveFilePanelInProject("Save Fur Profile", "New Fur Profile", "asset", "");
                                    AssetDatabase.CreateAsset(k, path);
                                    AssetDatabase.SaveAssets();
                                    AssetDatabase.Refresh();
                                }
                            }
                            GUILayout.Space(16);

                            if (xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseSkin != 0)
                            {
                                GUILayout.Space(4);
                                SmallGroup("BASE SKIN");
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatBaseColor = ColorField(new GUIContent("MAIN COLOR", "Final tint to be applied to the skin under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatBaseColor);

                                if (!xFur.materialProfiles[xFur.materialProfileIndex].furmatGlossSpecular)
                                {
                                    xFur.materialProfiles[xFur.materialProfileIndex].furmatSpecular = ColorField(new GUIContent("SPECULAR COLOR", "Specular color to be applied to the skin under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatSpecular);
                                }

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatBaseTex = ObjectField <Texture2D>(new GUIContent("MAIN TEXTURE", "Texture to be applied to the mesh under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatBaseTex, false);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatGlossSpecular = ObjectField <Texture2D>(new GUIContent("SPECULAR MAP", "Base Specular (RGB) and Smoothness (A) map to be used under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatGlossSpecular, false);
                                GUILayout.Space(4);

                                if (!xFur.materialProfiles[xFur.materialProfileIndex].furmatGlossSpecular)
                                {
                                    xFur.materialProfiles[xFur.materialProfileIndex].furmatSmoothness = SliderField(new GUIContent("SMOOTHNESS", "Smoothness to be applied to the skin under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatSmoothness, 0.0f, 1.0f);
                                }

                                GUILayout.Space(4);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatNormalmap = ObjectField <Texture2D>(new GUIContent("NORMALMAP", "The normalmap to be applied to the skin under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatNormalmap, false);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatOcclusion = ObjectField <Texture2D>(new GUIContent("OCCLUSION MAP", "The occlusion map to be applied to the skin under the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatOcclusion, false);

                                GUILayout.Space(8);
                                EndSmallGroup();
                            }

                            GUILayout.Space(16);

                            if (xFur.materialProfiles[xFur.materialProfileIndex].furmatReadBaseFur != 0)
                            {
                                GUILayout.Space(4);
                                SmallGroup("FUR SETTINGS");
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorA = ColorField(new GUIContent("FUR COLOR A", "Main tint to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorA);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorB = ColorField(new GUIContent("FUR COLOR B", "Main tint to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorB);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurRim    = ColorField(new GUIContent("FUR RIM COLOR", "Main tint to be applied to the fur's rim"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurRim);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurSpecular = ColorField(new GUIContent("SPECULAR COLOR", "Specular color to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurSpecular);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorMap = ObjectField <Texture2D>(new GUIContent("FUR COLOR MAP", "Texture to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurColorMap, false);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatData0       = ObjectField <Texture2D>(new GUIContent("FUR DATA 0", "Main fur Data map (fur mask, length, thickness and occlusion)"), xFur.materialProfiles[xFur.materialProfileIndex].furmatData0, false);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatData1       = ObjectField <Texture2D>(new GUIContent("FUR DATA 1", "Secondary fur Data map (grooming and stiffness)"), xFur.materialProfiles[xFur.materialProfileIndex].furmatData1, false);

                                if (xFur.materialProfiles[xFur.materialProfileIndex].furmatReadFurNoise > 0)
                                {
                                    xFur.materialProfiles[xFur.materialProfileIndex].furmatFurNoiseMap = ObjectField <Texture2D>(new GUIContent("FUR NOISE GEN", "Multi-layer noise map used as reference to generate the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurNoiseMap, false);
                                }
                                GUILayout.Space(4);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurOcclusion  = SliderField(new GUIContent("FUR OCCLUSION", "Shadowing and Occlusion to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurOcclusion, 0.0f, 1.0f);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurSmoothness = SliderField(new GUIContent("FUR SMOOTHNESS", "Smoothness to be applied to the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurSmoothness, 0.0f, 1.0f);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurLength     = SliderField(new GUIContent("FUR LENGTH", "Length of the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurLength, 0.0f, 4.0f);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurThickness  = SliderField(new GUIContent("FUR THICKNESS", "Thickness of the fur"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurThickness, 0.0f, 1.0f);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurRimPower   = SliderField(new GUIContent("FUR RIM POWER", "The power of the rim lighting effect"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurRimPower, 0.0f, 1.0f);
                                GUILayout.Space(4);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurUV1 = FloatField(new GUIContent("FUR UV 0 SCALE", "Scale of the first fur specific UV channel"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurUV1);
                                xFur.materialProfiles[xFur.materialProfileIndex].furmatFurUV2 = FloatField(new GUIContent("FUR UV 1 SCALE", "Scale of the second fur specific UV channel"), xFur.materialProfiles[xFur.materialProfileIndex].furmatFurUV2);

                                Vector3 furDir         = xFur.materialProfiles[xFur.materialProfileIndex].furmatDirection;
                                int     groomAlgorithm = (int)xFur.materialProfiles[xFur.materialProfileIndex].furmatDirection.w;

                                groomAlgorithm = PopupField(new GUIContent("GROOMING ALGORITHM", "The grooming algorithm to use when adding fur direction to this model"), groomAlgorithm, new GUIContent[] { new GUIContent("Original", "The original grooming algorithm adds a bit of length to the fur as you groom allowing more creativity. Please use small fur direction values for best results"), new GUIContent("Accurate", "The new algorithm for grooming is more accurate, bending the fur without adding any length. It allows for a more controlled, predictable grooming. Please make sure to use high fur direction values for best results") });
                                furDir         = Vector3Field(new GUIContent("FUR DIRECTION"), furDir);

                                xFur.materialProfiles[xFur.materialProfileIndex].furmatDirection = new Vector4(furDir.x, furDir.y, furDir.z, groomAlgorithm);



                                GUILayout.Space(8);
                                EndSmallGroup();

                                GUILayout.Space(8);
                            }
                        }
                        else
                        {
                            GUILayout.Space(6);

                            GUILayout.BeginHorizontal(); GUILayout.Space(12);
                            EditorGUILayout.HelpBox("Per Instance parameters are not supported on models with more than 1 fur based material on Unity versions older than Unity 2018.1", MessageType.Warning);
                            GUILayout.Space(12); GUILayout.EndHorizontal();

                            GUILayout.Space(6);
                        }
                    }
                    else
                    {
                        GUILayout.BeginHorizontal(); GUILayout.Space(12);
                        EditorGUILayout.HelpBox("This material is not a fur enabled material, no settings will be available for it.", MessageType.Warning);
                        GUILayout.Space(12); GUILayout.EndHorizontal();
                    }
                    GUILayout.Space(16);
                }
                EndCenteredGroup();


                if (BeginCenteredGroup(xFur.coatingModule != null ? "XFUR - " + xFur.coatingModule.ModuleName : "XFur - Coating Module (ERROR)", ref xFur.folds[1]))
                {
                    GUILayout.Space(16);
                    xFur.coatingModule.Module_UI(xFur);
                    GUILayout.Space(16);
                }
                EndCenteredGroup();


                if (BeginCenteredGroup(xFur.lodModule != null ? "XFUR - " + xFur.lodModule.ModuleName : "XFur - Lod Module (ERROR)", ref xFur.folds[2]))
                {
                    GUILayout.Space(16);
                    xFur.lodModule.Module_UI(xFur);
                    GUILayout.Space(16);
                }
                EndCenteredGroup();


                if (BeginCenteredGroup(xFur.physicsModule != null ? "XFUR - " + xFur.physicsModule.ModuleName : "XFur - Physics Module (ERROR)", ref xFur.folds[3]))
                {
                    GUILayout.Space(16);
                    xFur.physicsModule.Module_UI(xFur);
                    GUILayout.Space(16);
                }
                EndCenteredGroup();


                if (BeginCenteredGroup(xFur.fxModule != null ? "XFUR - " + xFur.fxModule.ModuleName : "XFur - FX Module (ERROR)", ref xFur.folds[4]))
                {
                    GUILayout.Space(16);
                    xFur.fxModule.Module_UI(xFur);
                    GUILayout.Space(16);
                }
                EndCenteredGroup();

                if (BeginCenteredGroup("HELP & SUPPORT", ref xFur.folds[6]))
                {
                    GUILayout.Space(16);
                    CenteredLabel("SUPPORT AND ASSISTANCE");
                    GUILayout.Space(10);

                    EditorGUILayout.HelpBox("Please make sure to include the following information with your request :\n - Invoice number\n - Screenshots of the XFur_System component and its settings\n - Steps to reproduce the issue.\n\nOur support service usually takes 2-4 business days to reply, so please be patient. We always reply to all emails.", MessageType.Info);

                    GUILayout.Space(8);
                    GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace();
                    GUILayout.Label("For support, contact us at : [email protected]", pidiSkin2.label);
                    GUILayout.FlexibleSpace(); GUILayout.EndHorizontal();

                    GUILayout.Space(8);

                    GUILayout.Space(16);
                    CenteredLabel("ONLINE TUTORIALS");
                    GUILayout.Space(10);
                    if (CenteredButton("QUICK START GUIDE", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#quick_start_guide");
                    }
                    if (CenteredButton("PREPARING YOUR 3D MODELS", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#preparing_your_3d_models");
                    }
                    if (CenteredButton("XFUR PAINTER", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#xfur_painter");
                    }
                    if (CenteredButton("XFUR SYSTEM COMPONENTS", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#xfur_studio_-_components");
                    }
                    if (CenteredButton("XFUR SYSTEM MODULES", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#xfur_studio_-_system_modules");
                    }

                    if (CenteredButton("XFUR STUDIO API", 200))
                    {
                        Help.BrowseURL("https://pidiwiki.irreverent-software.com/wiki/doku.php?id=xfur_studio_legacy#xfur_studio_api");
                    }

                    GUILayout.Space(24);
                    CenteredLabel("ABOUT PIDI : XFUR STUDIO™");
                    GUILayout.Space(12);

                    EditorGUILayout.HelpBox("PIDI : XFur Studio™ has been integrated in dozens of projects by hundreds of users.\nYour use and support to this tool is what keeps it growing, evolving and adapting to better suit your needs and keep providing you with the best quality fur for Unity.\n\nIf this tool has been useful for your project, please consider taking a minute to rate and review it, to help us to continue its development for a long time.", MessageType.Info);

                    GUILayout.Space(8);
                    if (CenteredButton("REVIEW XFUR STUDIO™", 200))
                    {
                        Help.BrowseURL("https://assetstore.unity.com/packages/vfx/shaders/pidi-xfur-studio-113361");
                    }
                    GUILayout.Space(8);
                    if (CenteredButton("ABOUT THIS VERSION", 200))
                    {
                        Help.BrowseURL("https://assetstore.unity.com/packages/vfx/shaders/pidi-xfur-studio-113361");
                    }
                    GUILayout.Space(8);
                }
                EndCenteredGroup();
            }

            GUILayout.Space(16);

            var tempStyle = new GUIStyle();
            tempStyle.normal.textColor = new Color(0.75f, 0.75f, 0.75f);
            tempStyle.fontSize         = 9;
            tempStyle.fontStyle        = FontStyle.Italic;
            GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace();
            GUILayout.Label("Copyright© 2018-2019, Jorge Pinal N.", tempStyle);
            GUILayout.FlexibleSpace(); GUILayout.EndHorizontal();

            GUILayout.Space(16);
            GUILayout.EndVertical(); GUILayout.Space(8); GUILayout.EndHorizontal();


            GUI.skin = tSkin;
        }
        void DrawSchemas(List <AddressableAssetGroupSchema> schemas)
        {
            GUILayout.Space(6);

            EditorGUILayout.BeginHorizontal();
            var activeProfileName = m_GroupTarget.Settings.profileSettings.GetProfileName(m_GroupTarget.Settings.activeProfileId);

            if (string.IsNullOrEmpty(activeProfileName))
            {
                m_GroupTarget.Settings.activeProfileId = null; //this will reset it to default.
                activeProfileName = m_GroupTarget.Settings.profileSettings.GetProfileName(m_GroupTarget.Settings.activeProfileId);
            }
            EditorGUILayout.PrefixLabel("Active Profile: " + activeProfileName);
            if (GUILayout.Button("Inspect Top Level Settings"))
            {
                EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings);
                Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings;
            }

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(6);


            if (m_FoldoutState == null || m_FoldoutState.Length != schemas.Count)
            {
                m_FoldoutState = new bool[schemas.Count];
            }

            EditorGUILayout.BeginVertical();
            for (int i = 0; i < schemas.Count; i++)
            {
                var schema       = schemas[i];
                int currentIndex = i;

                DrawDivider();
                EditorGUILayout.BeginHorizontal();
                m_FoldoutState[i] = EditorGUILayout.Foldout(m_FoldoutState[i], AddressableAssetUtility.GetCachedTypeDisplayName(schema.GetType()));
                if (!m_GroupTarget.ReadOnly)
                {
                    GUILayout.FlexibleSpace();
                    GUIStyle gearIconStyle = UnityEngine.GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton");

                    if (EditorGUILayout.DropdownButton(EditorGUIUtility.IconContent("_Popup"), FocusType.Keyboard, gearIconStyle))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(AddressableAssetGroup.RemoveSchemaContent, false, () =>
                        {
                            if (EditorUtility.DisplayDialog("Remove selected schema?", "Are you sure you want to remove " + AddressableAssetUtility.GetCachedTypeDisplayName(schema.GetType()) + " schema?\n\nYou cannot undo this action.", "Yes", "No"))
                            {
                                m_GroupTarget.RemoveSchema(schema.GetType());
                                var newFoldoutstate = new bool[schemas.Count];
                                for (int j = 0; j < newFoldoutstate.Length; j++)
                                {
                                    if (j < i)
                                    {
                                        newFoldoutstate[j] = m_FoldoutState[j];
                                    }
                                    else
                                    {
                                        newFoldoutstate[j] = m_FoldoutState[i + 1];
                                    }
                                }

                                m_FoldoutState = newFoldoutstate;
                            }
                        });
                        menu.AddItem(AddressableAssetGroup.MoveSchemaUpContent, false, () =>
                        {
                            if (currentIndex > 0)
                            {
                                m_GroupTarget.Schemas[currentIndex]     = m_GroupTarget.Schemas[currentIndex - 1];
                                m_GroupTarget.Schemas[currentIndex - 1] = schema;
                                return;
                            }
                        });
                        menu.AddItem(AddressableAssetGroup.MoveSchemaDownContent, false, () =>
                        {
                            if (currentIndex < m_GroupTarget.Schemas.Count - 1)
                            {
                                m_GroupTarget.Schemas[currentIndex]     = m_GroupTarget.Schemas[currentIndex + 1];
                                m_GroupTarget.Schemas[currentIndex + 1] = schema;
                                return;
                            }
                        });
                        menu.AddSeparator("");
                        menu.AddItem(AddressableAssetGroup.ExpandSchemaContent, false, () =>
                        {
                            m_FoldoutState[currentIndex] = true;
                            foreach (var targetSchema in m_GroupTarget.Schemas)
                            {
                                targetSchema.ShowAllProperties();
                            }
                        });
                        menu.ShowAsContext();
                    }
                }

                EditorGUILayout.EndHorizontal();
                if (m_FoldoutState[i])
                {
                    try
                    {
                        EditorGUI.indentLevel++;
                        if (m_GroupTargets.Length == 1)
                        {
                            schema.OnGUI();
                        }
                        else
                        {
                            schema.OnGUIMultiple(GetSchemasForOtherTargets(schema));
                        }
                        EditorGUI.indentLevel--;
                    }
                    catch (Exception se)
                    {
                        Debug.LogException(se);
                    }
                }
            }

            if (schemas.Count > 0)
            {
                DrawDivider();
            }
            GUILayout.Space(4);
            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            GUIStyle addSchemaButton = new GUIStyle(UnityEngine.GUI.skin.button);

            addSchemaButton.fontSize    = 12;
            addSchemaButton.fixedWidth  = 225;
            addSchemaButton.fixedHeight = 22;

            if (!m_GroupTarget.ReadOnly)
            {
                if (EditorGUILayout.DropdownButton(new GUIContent("Add Schema", "Add new schema to this group."), FocusType.Keyboard, addSchemaButton))
                {
                    var menu = new GenericMenu();
                    for (int i = 0; i < m_SchemaTypes.Count; i++)
                    {
                        var type = m_SchemaTypes[i];

                        if (m_GroupTarget.GetSchema(type) == null)
                        {
                            menu.AddItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), false, () => OnAddSchema(type));
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(AddressableAssetUtility.GetCachedTypeDisplayName(type), ""), true);
                        }
                    }

                    menu.ShowAsContext();
                }
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
Beispiel #13
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            GUISkin  skin  = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            GUIStyle style = skin.GetStyle("PaneOptions");

            var  constantProperty    = property.FindPropertyRelative("ConstantValue");
            var  useConstantProperty = property.FindPropertyRelative("UseConstant");
            var  variableProperty    = property.FindPropertyRelative("Variable");
            Rect pos = position;

            pos.width = 15;
            pos.x    += EditorGUIUtility.labelWidth - 17;
            pos.y    += 4;

            if (GUI.Button(pos, "", style))
            {
                GenerateMenu(property, useConstantProperty, variableProperty).DropDown(pos);
            }

            if (useConstantProperty.boolValue)
            {
                EditorGUI.PropertyField(position, constantProperty, new GUIContent(property.displayName));
            }
            else
            {
                Rect pos1 = new Rect(position.x, position.y, (position.width + EditorGUIUtility.labelWidth) / 2, position.height);
                Rect pos2 = new Rect(position.x + pos1.width, position.y, position.width - pos1.width, position.height);
                if (variableProperty.objectReferenceValue != null)
                {
                    if (variableProperty.objectReferenceValue != null)
                    {
                        SerializedObject   variable             = new SerializedObject(variableProperty.objectReferenceValue);
                        SerializedProperty persistentProperty   = variable.FindProperty("Persistent");
                        SerializedProperty valueProperty        = variable.FindProperty("Value");
                        SerializedProperty defaultValueProperty = variable.FindProperty("DefaultValue");
                        if (valueProperty.propertyType != SerializedPropertyType.Generic)
                        {
                            EditorGUI.PropertyField(pos1, variableProperty, new GUIContent(property.displayName));
                            EditorGUI.BeginChangeCheck();
                            if (persistentProperty.boolValue || Application.isPlaying)
                            {
                                EditorGUI.PropertyField(pos2, valueProperty, new GUIContent(), true);
                            }
                            else
                            {
                                EditorGUI.PropertyField(pos2, defaultValueProperty, new GUIContent(), true);
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                variable.ApplyModifiedProperties();
                            }
                        }
                        else
                        {
                            EditorGUI.PropertyField(position, variableProperty, new GUIContent(property.displayName), true);
                        }
                    }
                }
                else
                {
                    EditorGUI.PropertyField(position, variableProperty, new GUIContent(property.displayName), true);
                }
            }
        }
    public override void OnInspectorGUI()
    {
        GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
        serializedObject.Update();
        EditorGUI.BeginChangeCheck();

        var tSize = EditorGUILayout.IntField("Terrain size:", Mathf.RoundToInt(terrainData.size.x));

        if (tSize != Mathf.RoundToInt(terrainData.size.x))
        {
            if (tSize > 31 && tSize < 20480)
            {
                terrainData.heightmapResolution = tSize + 1;
                terrainData.size = new Vector3(tSize, terrainData.size.y, tSize);
                terrainData.alphamapResolution = tSize;
                grid.SampleHeights();
                Undo.RecordObjects(new Object[] { grid, terrainData }, "Changed terrain size");
            }
        }
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Visualize:");
        EditorGUILayout.BeginHorizontal();
        showTerrainLines.boolValue = GUILayout.Toggle(showTerrainLines.boolValue, "Terrain", "Button");
        showWalkability.boolValue  = GUILayout.Toggle(showWalkability.boolValue, "Walkability", "Button");
        showPrefabs.boolValue      = GUILayout.Toggle(showPrefabs.boolValue, "Prefabs", "Button");
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.IntSlider(gridDist, 0, 25);
        if (!showPrefabs.boolValue)
        {
            grid.HidePrefabsAll();
        }
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Terrain Painting:");
        editWalkability.boolValue = GUILayout.Toggle(editWalkability.boolValue, "Paint Walkability", "Button");
        if (editWalkability.boolValue)
        {
            setUnwalkable.boolValue = GUILayout.Toggle(setUnwalkable.boolValue, setUnwalkable.boolValue ? "Set Unwalkable" : "Set Walkable", "Button");
            paintPrefabs.boolValue  = false;
        }
        paintPrefabs.boolValue = GUILayout.Toggle(paintPrefabs.boolValue, "Paint Prefabs", "Button");
        if (paintPrefabs.boolValue)
        {
            editWalkability.boolValue = false;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.ObjectField(paintedPrefab, GUILayout.ExpandWidth(false));
            prefabAdd.boolValue = GUILayout.Toggle(prefabAdd.boolValue, "Add", "Button");
            if (prefabAdd.boolValue)
            {
                prefabReplace.boolValue = false;
                prefabRemove.boolValue  = false;
            }
            else if (!prefabReplace.boolValue && !prefabRemove.boolValue)
            {
                prefabAdd.boolValue = true;
            }
            prefabReplace.boolValue = GUILayout.Toggle(prefabReplace.boolValue, "Replace", "Button");
            if (prefabReplace.boolValue)
            {
                prefabAdd.boolValue    = false;
                prefabRemove.boolValue = false;
            }
            prefabRemove.boolValue = GUILayout.Toggle(prefabRemove.boolValue, "Remove", "Button");
            if (prefabRemove.boolValue)
            {
                prefabAdd.boolValue     = false;
                prefabReplace.boolValue = false;
            }
            EditorGUILayout.EndHorizontal();
        }

        serializedObject.ApplyModifiedProperties();
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "Changed terrain helper settings.");
        }

        GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
    }
Beispiel #15
0
        void DrawCreateNode()
        {
            float closeWidth          = 25;
            float searchPaddingX      = 10;
            float searchPaddingTop    = 1;
            float searchPaddingBottom = 2;
            Rect  closeRect           = new Rect(menuRect.width - closeWidth, 0, closeWidth, menuRect.height);
            Rect  searchRect          = new Rect(searchPaddingX, searchPaddingTop, menuRect.width - closeRect.width - (searchPaddingX * 2), menuRect.height - (searchPaddingTop + searchPaddingBottom));

            GUILayout.BeginArea(menuRect, EditorStyles.toolbar);

            GUILayout.BeginArea(closeRect);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("X", EditorStyles.toolbarButton))
            {
                isCreatingNode = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUILayout.BeginArea(searchRect);
            GUILayout.BeginHorizontal();
            GUISkin builtinSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

            search = GUILayout.TextField(search, builtinSkin.FindStyle("ToolbarSeachTextField"));
            if (GUILayout.Button("", builtinSkin.FindStyle("ToolbarSeachCancelButton")))
            {
                // Remove focus if cleared
                search = "";
                GUI.FocusControl(null);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUILayout.EndArea();

            GUILayout.BeginArea(contentRect);
            nodeScroll = GUILayout.BeginScrollView(nodeScroll);

            List <Node> compositeNodes = NodeFactory.GetPrototypes(typeof(CompositeNode), false);
            List <Node> decoratorNodes = NodeFactory.GetPrototypes(typeof(DecoratorNode), false);
            List <Node> leafNodes      = NodeFactory.GetPrototypes(typeof(LeafNode), false);
            //Debug.Log(compositeNodes.Count);

            //			compositites.Sort ();
            //			decorators.Sort ();
            //			leaves.Sort ();


            List <string> leafNames      = NodeFactory.GetDisplayNames(leafNodes);
            List <string> compositeNames = NodeFactory.GetDisplayNames(compositeNodes);
            List <string> decoratorNames = NodeFactory.GetDisplayNames(decoratorNodes);

            if (search != null && search != "")
            {
                leafNames      = FilterNames(leafNames, search);
                compositeNames = FilterNames(compositeNames, search);
                decoratorNames = FilterNames(decoratorNames, search);
            }

            if (compositeNames.Count > 0)
            {
                showComposites = EditorGUILayout.Foldout(showComposites, "Composites");
            }

            if (showComposites)
            {
                for (int i = 0; i < compositeNames.Count; i++)
                {
                    if (GUILayout.Button(NodeFactory.GetDisplayName(compositeNames[i]), EditorStyles.toolbarButton))
                    {
                        //						NodeTypes.Create (compositeNames [i]);
                        CreateNode(compositeNames[i]);
                        isCreatingNode = false;
                    }
                }
            }

            if (decoratorNames.Count > 0)
            {
                showDecorators = EditorGUILayout.Foldout(showDecorators, "Decorators", EditorStyles.foldout);
            }

            if (showDecorators)
            {
                for (int i = 0; i < decoratorNames.Count; i++)
                {
                    if (GUILayout.Button(NodeFactory.GetDisplayName(decoratorNames[i]), EditorStyles.toolbarButton))
                    {
                        CreateNode(decoratorNames[i]);
                        isCreatingNode = false;
                    }
                }
            }

            if (leafNames.Count > 0)
            {
                showLeaves = EditorGUILayout.Foldout(showLeaves, "Leaves", EditorStyles.foldout);
            }

            if (showLeaves)
            {
                for (int i = 0; i < leafNames.Count; i++)
                {
                    if (GUILayout.Button(NodeFactory.GetDisplayName(leafNames[i]), EditorStyles.toolbarButton))
                    {
                        CreateNode(leafNames[i]);
                        isCreatingNode = false;
                    }
                }
            }

            //			createNodeIndex = GUILayout.SelectionGrid(createNodeIndex, NodeTypes.GetDisplayNames(leaves).ToArray(), 1, EditorStyles.toolbarButton);

            GUILayout.EndScrollView();
            //			if (GUILayout.Button ("Close", EditorStyles.toolbarButton)) {
            //				Debug.Log ("Close");
            //			}
            GUILayout.EndArea();
        }
Beispiel #16
0
        public void ApplyMain(Theme theme)
        {
            if (this.skin.IsNull())
            {
                return;
            }
            var skin       = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            var isFragment = this.path.Contains("#");
            var isDefault  = this.skinset.name == "Default";
            var main       = this.skin;
            var palette    = theme.palette;

            if (!isDefault)
            {
                main = theme.fontset.Apply(main);
                theme.palette.Apply(main);
                ThemeSkin.RemoveHover(main);
            }
            skin.Use(main, !isFragment, true);
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Game).Use(skin, !isFragment, true);
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene).Use(skin, !isFragment, true);
            var collabStyle = isDefault ? skin.Get("DropDown").Padding(24, 14, 2, 3) : skin.Get("DropDown");

            Reflection.GetUnityType("Toolbar.Styles").GetVariable <GUIStyle>("collabButtonStyle").Use(collabStyle);
            Reflection.GetUnityType("AppStatusBar").ClearVariable("background");
            Reflection.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sMenuItem", skin.Get("MenuItem"));
            Reflection.GetUnityType("SceneRenderModeWindow.Styles").SetVariable("sSeparator", skin.Get("sv_iconselector_sep"));
            Reflection.GetUnityType("GameView.Styles").SetVariable("gizmoButtonStyle", skin.Get("GV Gizmo DropDown"));
            typeof(SceneView).SetVariable <GUIStyle>("s_DropDownStyle", skin.Get("GV Gizmo DropDown"));
            var hostView = Reflection.GetUnityType("HostView");

            if (palette.Has("Cursor"))
            {
                skin.settings.cursorColor = palette.Get("Cursor");
            }
            if (palette.Has("Selection"))
            {
                skin.settings.selectionColor = palette.Get("Selection");
            }
            if (palette.Has("Curve"))
            {
                typeof(EditorGUI).SetVariable("kCurveColor", palette.Get("Curve"));
            }
            if (palette.Has("CurveBackground"))
            {
                typeof(EditorGUI).SetVariable("kCurveBGColor", palette.Get("CurveBackground"));
            }
            if (palette.Has("Window"))
            {
                typeof(EditorGUIUtility).SetVariable("kDarkViewBackground", palette.Get("Window"));
                hostView.SetVariable("kViewColor", palette.Get("Window"));
            }
            foreach (var view in Resources.FindObjectsOfTypeAll(hostView))
            {
                view.ClearVariable("background");
            }
            foreach (var window in Locate.GetAssets <EditorWindow>())
            {
                window.minSize = new Vector2(100, 20);
            }
            Reflection.GetUnityType("PreferencesWindow").InstanceVariable("constants").SetVariable("sectionHeader", skin.Get("HeaderLabel"));
            Reflection.GetUnityType("BuildPlayerWindow").InstanceVariable("styles").SetVariable("toggleSize", new Vector2(24, 16));
        }
        public void OnSceneGUI()
        {
            if (!editMode)
            {
                return;
            }

            CreateParticleMaterials();

            ResizeParticleArrays();

            if (!actor.Initialized)
            {
                return;
            }

            if (Camera.current != null)
            {
                camup      = Camera.current.transform.up;
                camright   = Camera.current.transform.right;
                camforward = Camera.current.transform.forward;
            }

            if (Event.current.type == EventType.Repaint)
            {
                // Update camera facing status and world space positions array:
                UpdateParticleEditorInformation();

                // Generate sorted indices for back-to-front rendering:
                for (int i = 0; i < sortedIndices.Length; i++)
                {
                    sortedIndices[i] = i;
                }

                Array.Sort <int>(sortedIndices, (a, b) => sqrDistanceToCamera[b].CompareTo(sqrDistanceToCamera[a]));

                // Draw custom actor stuff.
                DrawActorInfo();
            }

            // Draw tool handles:
            if (Camera.current != null)
            {
                if (paintBrush)
                {
                    if (ObiClothParticleHandles.ParticleBrush(wsPositions, faceCulling, facingCamera, brushRadius,
                                                              () => {
                        // As RecordObject diffs with the end of the current frame,
                        // and this is a multi-frame operation, we need to use RegisterCompleteObjectUndo instead.
                        Undo.RegisterCompleteObjectUndo(actor, "Paint particles");
                    },
                                                              PaintbrushStampCallback,
                                                              () => {
                        EditorUtility.SetDirty(actor);
                    },
                                                              Resources.Load <Texture2D>("BrushHandle")))
                    {
                        ParticlePropertyChanged();
                    }
                }
                else if (selectionBrush)
                {
                    if (ObiClothParticleHandles.ParticleBrush(wsPositions, faceCulling, facingCamera, brushRadius, null,
                                                              (List <ParticleStampInfo> stampInfo, bool modified) => {
                        foreach (ParticleStampInfo info in stampInfo)
                        {
                            if (actor.active[info.index])
                            {
                                selectionStatus[info.index] = !modified;
                            }
                        }
                    }, null,
                                                              Resources.Load <Texture2D>("BrushHandle")))
                    {
                        SelectionChanged();
                    }
                }
                else
                {
                    if (ObiClothParticleHandles.ParticleSelector(wsPositions, selectionStatus, faceCulling, facingCamera))
                    {
                        SelectionChanged();
                    }
                }
            }

            // Sceneview GUI:
            Handles.BeginGUI();

            GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);

            if (Event.current.type == EventType.Repaint)
            {
                uirect   = GUILayout.Window(0, uirect, DrawUIWindow, "Particle editor");
                uirect.x = Screen.width / EditorGUIUtility.pixelsPerPoint - uirect.width - 10;               //10 and 28 are magic values, since Screen size is not exactly right.
                uirect.y = Screen.height / EditorGUIUtility.pixelsPerPoint - uirect.height - 28;
            }

            GUILayout.Window(0, uirect, DrawUIWindow, "Particle editor");

            Handles.EndGUI();
        }
Beispiel #18
0
 public GUISkinScope(EditorSkin editorSkin)
 {
     skin     = GUI.skin;
     GUI.skin = EditorGUIUtility.GetBuiltinSkin(editorSkin);
 }
Beispiel #19
0
        // PAINT METHODS: -------------------------------------------------------------------------

        private static void OnPaintToolbar(SceneView sceneview)
        {
            GUISkin prevSkin = GUI.skin;

            GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);

            bool registeredItem = false;

            while (REGISTER_ITEMS.Count > 0)
            {
                registeredItem = true;
                Item item = REGISTER_ITEMS.Pop();
                ITEMS.Add(item);
            }

            if (registeredItem)
            {
                ITEMS.Sort((Item x, Item y) => x.priority.CompareTo(y.priority));
            }
            if (ITEMS.Count == 0)
            {
                return;
            }

            Rect rect = new Rect(
                MOVE_OFFSET_X,
                MOVE_OFFSET_Y,
                BUTTONS_WIDTH * ITEMS.Count,
                TOOLBAR_HEIGHT
                );

            bool mouseInRect = rect.Contains(UnityEngine.Event.current.mousePosition);

            if (UnityEngine.Event.current.type == EventType.MouseUp)
            {
                DRAGGING = false;
            }
            if (UnityEngine.Event.current.type == EventType.MouseDown && mouseInRect)
            {
                MOUSE_POSITION = UnityEngine.Event.current.mousePosition;
                DRAGGING       = true;
            }

            if (DRAGGING)
            {
                Vector2 delta = UnityEngine.Event.current.mousePosition - MOUSE_POSITION;

                MOVE_OFFSET_X += delta.x;
                MOVE_OFFSET_Y += delta.y;
                SceneView.currentDrawingSceneView.Repaint();
            }

            MOUSE_POSITION = UnityEngine.Event.current.mousePosition;

            Handles.BeginGUI();
            GUILayout.BeginArea(rect);
            EditorGUILayout.BeginHorizontal();

            for (int i = 0; i < ITEMS.Count - 1; ++i)
            {
                BTN_POS position = (i == 0 ? BTN_POS.L : BTN_POS.M);
                PaintButton(ITEMS[i], position);
            }

            int panIndex = ITEMS.Count - 1;

            PaintButton(ITEMS[panIndex], BTN_POS.R, MouseCursor.Pan);

            EditorGUILayout.EndHorizontal();
            GUILayout.EndArea();
            Handles.EndGUI();

            GUI.skin = prevSkin;
        }
Beispiel #20
0
    override public void OnInspectorGUI()
    {
        DrawDefaultInspector();
        GUI.enabled = true;

        if (meshPath == null)
        {
            mesh      = (UnityEngine.Mesh)target;
            assetPath = AssetDatabase.GetAssetPath(target);
            assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
            GameObject asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
            meshPath = KrablMesh.UnityEditorUtils.MeshPathInAsset(mesh, asset);
        }

        if (prog == null && searchedForProgram == false)
        {
            _initializeProgram();
            searchedForProgram = true;
        }

        // Mesh information on top.
        // Mesh path
        string path = "";

        if (assetPath != null && assetPath != "")
        {
            path += assetPath.Replace("Assets/", "") + " - ";
        }
        GUILayout.BeginHorizontal();
        GUILayout.Label("Mesh Path: ", GUILayout.Width(80.0f)); GUILayout.Label(path + meshPath);
        GUILayout.EndHorizontal();

        // Mesh description
        string desc;

        if (prog != null)
        {
            desc = prog.inMeshDescription;
            if (desc == null || desc == "")
            {
                desc = "n/a";
            }
        }
        else
        {
            desc = KMProcessorProgram.MeshDescription(mesh);
        }
        GUILayout.BeginHorizontal();
        GUILayout.Label("Description: ", GUILayout.Width(80.0f)); GUILayout.Label(desc);
        GUILayout.EndHorizontal();


        GUI.enabled = true;

        if (prog != null && progGUI != null)
        {
            // The program object draws all the processors etc.
            progGUI.DrawImporterGUI(this);
        }
        // prog and progGUI might have disappeared from delete, so check again
        if (prog != null && progGUI != null)
        {
            // Draw the part below the processors with Apply and Revert
            if (progGUI.modifiedDuringLastUpdate)
            {
                hasChanges = true;
            }

            GUI.enabled = hasChanges;
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Revert", GUILayout.ExpandWidth(false)))
            {
                _revertProgramChanges();
                return;
            }

            if (GUILayout.Button("Apply", GUILayout.ExpandWidth(false)))
            {
                GUI.FocusControl("");                 // make sure text editor field get committed
                _applyProgramChanges();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
        }
        else
        {
            // Draw the Add mesh import program section.
            EditorGUILayout.Separator();

            bool canUseProgram = (assetPath != null && assetPath != "");
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5
            if (mesh.blendShapeCount > 0)
            {
                canUseProgram = false;
            }
#endif

            if (canUseProgram)
            {
                GUIStyle largeButtonStyle = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).GetStyle("LargeButton");
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add Mesh Import Program", largeButtonStyle))
                {
                    AddProgram();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else
            {
                bool specialError = false;

#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5
                if (mesh.blendShapeCount > 0)
                {
                    EditorGUILayout.HelpBox(
                        "Meshes with blendshapes can not yet be processed by Krabl Mesh Processors.\n\n" +
                        "Support will be added as soon as Unity exposes blendshape access in the API.",
                        MessageType.Info);
                    specialError = true;
                }
#endif
                if (specialError == false)
                {
                    EditorGUILayout.HelpBox(
                        "Only meshes inside the project folder can have mesh import programs.\n\n"
                        + "Built-In meshes and scene meshes are never imported by Unity.",
                        MessageType.Info);
                }
            }
        }
    }
Beispiel #21
0
 static GUISkin GetEditorSkin()
 {
     return(EditorGUIUtility.isProSkin ?
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene) :
            EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector));
 }
Beispiel #22
0
        public static bool DoSelection(Vector3[] positions,
                                       bool[] selectionStatus,
                                       bool[] facingCamera)
        {
            Matrix4x4 cachedMatrix = Handles.matrix;

            int  controlID              = GUIUtility.GetControlID(particleSelectorHash, FocusType.Passive);
            int  selectedParticleIndex  = -1;
            bool selectionStatusChanged = false;

            // select vertex on mouse click:
            switch (Event.current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:

                if (Event.current.button != 0)
                {
                    break;
                }

                startPos = Event.current.mousePosition;
                marquee.Set(0, 0, 0, 0);

                // If the user is not pressing shift, clear selection.
                if ((Event.current.modifiers & EventModifiers.Shift) == 0 && (Event.current.modifiers & EventModifiers.Alt) == 0)
                {
                    for (int i = 0; i < selectionStatus.Length; i++)
                    {
                        selectionStatus[i] = false;
                    }
                }

                // Allow use of marquee selection
                if (Event.current.modifiers == EventModifiers.None || (Event.current.modifiers & EventModifiers.Shift) != 0)
                {
                    GUIUtility.hotControl = controlID;
                }

                float minSqrDistance = System.Single.MaxValue;

                for (int i = 0; i < positions.Length; i++)
                {
                    // skip not selectable particles:
                    //if (!facingCamera[i] && (selectBackfaces & ObiActorBlueprintEditor.ParticleCulling.Back) != 0) continue;
                    //if (facingCamera[i] && (selectBackfaces & ObiActorBlueprintEditor.ParticleCulling.Front) != 0) continue;

                    // get particle position in gui space:
                    Vector2 pos = HandleUtility.WorldToGUIPoint(positions[i]);

                    // get distance from mouse position to particle position:
                    float sqrDistance = Vector2.SqrMagnitude(startPos - pos);

                    // check if this particle is closer to the cursor that any previously considered particle.
                    if (sqrDistance < 100 && sqrDistance < minSqrDistance)
                    {     //magic number 100 = 10*10, where 10 is min distance in pixels to select a particle.
                        minSqrDistance        = sqrDistance;
                        selectedParticleIndex = i;
                    }
                }

                if (selectedParticleIndex >= 0)
                {     // toggle particle selection status.
                    selectionStatus[selectedParticleIndex] = !selectionStatus[selectedParticleIndex];
                    selectionStatusChanged = true;
                    GUIUtility.hotControl  = controlID;
                    Event.current.Use();
                }
                else if (Event.current.modifiers == EventModifiers.None)
                {     // deselect all particles:
                    for (int i = 0; i < selectionStatus.Length; i++)
                    {
                        selectionStatus[i] = false;
                    }

                    selectionStatusChanged = true;
                }

                break;

            case EventType.MouseMove:
                SceneView.RepaintAll();
                break;

            case EventType.MouseDrag:

                if (GUIUtility.hotControl == controlID)
                {
                    currentPos = Event.current.mousePosition;
                    if (!dragging && Vector2.Distance(startPos, currentPos) > 5)
                    {
                        dragging = true;
                    }
                    else
                    {
                        GUIUtility.hotControl = controlID;
                        Event.current.Use();
                    }

                    //update marquee rect:
                    float left   = Mathf.Min(startPos.x, currentPos.x);
                    float right  = Mathf.Max(startPos.x, currentPos.x);
                    float bottom = Mathf.Min(startPos.y, currentPos.y);
                    float top    = Mathf.Max(startPos.y, currentPos.y);

                    marquee = new Rect(left, bottom, right - left, top - bottom);
                }

                break;

            case EventType.MouseUp:

                if (GUIUtility.hotControl == controlID)
                {
                    dragging = false;

                    for (int i = 0; i < positions.Length; i++)
                    {
                        // skip not selectable particles:
                        //switch (selectBackfaces)
                        {
                            //case ObiActorBlueprintEditor.ParticleCulling.Back: if (!facingCamera[i]) continue; break;
                            //case ObiActorBlueprintEditor.ParticleCulling.Front: if (facingCamera[i]) continue; break;
                        }

                        // get particle position in gui space:
                        Vector2 pos = HandleUtility.WorldToGUIPoint(positions[i]);

                        if (pos.x > marquee.xMin && pos.x < marquee.xMax && pos.y > marquee.yMin && pos.y < marquee.yMax)
                        {
                            selectionStatus[i]     = true;
                            selectionStatusChanged = true;
                        }
                    }

                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }

                break;

            case EventType.Repaint:

                Handles.matrix = Matrix4x4.identity;

                if (dragging)
                {
                    GUISkin oldSkin = GUI.skin;
                    GUI.skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
                    Handles.BeginGUI();
                    GUI.Box(new Rect(marquee.xMin, marquee.yMin, marquee.width, marquee.height), "");
                    Handles.EndGUI();
                    GUI.skin = oldSkin;
                }

                Handles.matrix = cachedMatrix;

                break;
            }

            return(selectionStatusChanged);
        }
Beispiel #23
0
    void InitGUISkin()
    {
        string guiSkinToUse;

        if (EditorGUIUtility.isProSkin || FORCE_USE_DARK_SKIN)
        {
            guiSkinToUse = BuildReportTool.Window.Settings.DARK_GUI_SKIN_FILENAME;
        }
        else
        {
            guiSkinToUse = BuildReportTool.Window.Settings.DEFAULT_GUI_SKIN_FILENAME;
        }

        // try default path
        _usedSkin = AssetDatabase.LoadAssetAtPath(string.Format("{0}/GUI/{1}", BuildReportTool.Options.BUILD_REPORT_TOOL_DEFAULT_PATH, guiSkinToUse), typeof(GUISkin)) as GUISkin;

        if (_usedSkin == null)
        {
#if BRT_SHOW_MINOR_WARNINGS
            Debug.LogWarning(BuildReportTool.Options.BUILD_REPORT_PACKAGE_MOVED_MSG);
#endif

            string folderPath = BuildReportTool.Util.FindAssetFolder(Application.dataPath, BuildReportTool.Options.BUILD_REPORT_TOOL_DEFAULT_FOLDER_NAME);
            if (!string.IsNullOrEmpty(folderPath))
            {
                folderPath = folderPath.Replace('\\', '/');
                int assetsIdx = folderPath.IndexOf("/Assets/", StringComparison.OrdinalIgnoreCase);
                if (assetsIdx != -1)
                {
                    folderPath = folderPath.Substring(assetsIdx + 8, folderPath.Length - assetsIdx - 8);
                }
                //Debug.Log(folderPath);

                _usedSkin = AssetDatabase.LoadAssetAtPath(string.Format("Assets/{0}/GUI/{1}", folderPath, guiSkinToUse), typeof(GUISkin)) as GUISkin;
            }
            else
            {
                Debug.LogError(BuildReportTool.Options.BUILD_REPORT_PACKAGE_MISSING_MSG);
            }
            //Debug.Log("_usedSkin " + (_usedSkin != null));
        }

        if (_usedSkin != null)
        {
            // weirdo enum labels used to get either light or dark skin
            // (https://forum.unity.com/threads/editorguiutility-getbuiltinskin-not-working-correctly-in-unity-4-3.211504/#post-1430038)
            GUISkin nativeSkin =
                EditorGUIUtility.GetBuiltinSkin(EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector);

            if (!(EditorGUIUtility.isProSkin || FORCE_USE_DARK_SKIN))
            {
                _usedSkin.verticalScrollbar           = nativeSkin.verticalScrollbar;
                _usedSkin.verticalScrollbarThumb      = nativeSkin.verticalScrollbarThumb;
                _usedSkin.verticalScrollbarUpButton   = nativeSkin.verticalScrollbarUpButton;
                _usedSkin.verticalScrollbarDownButton = nativeSkin.verticalScrollbarDownButton;

                _usedSkin.horizontalScrollbar            = nativeSkin.horizontalScrollbar;
                _usedSkin.horizontalScrollbarThumb       = nativeSkin.horizontalScrollbarThumb;
                _usedSkin.horizontalScrollbarLeftButton  = nativeSkin.horizontalScrollbarLeftButton;
                _usedSkin.horizontalScrollbarRightButton = nativeSkin.horizontalScrollbarRightButton;

                // change the toggle skin to use the Unity builtin look, but keep our settings
                GUIStyle toggleSaved = new GUIStyle(_usedSkin.toggle);

                // make our own copy of the native skin toggle so that editing it won't affect the rest of the editor GUI
                GUIStyle nativeToggleCopy = new GUIStyle(nativeSkin.toggle);

                _usedSkin.toggle               = nativeToggleCopy;
                _usedSkin.toggle.border        = toggleSaved.border;
                _usedSkin.toggle.margin        = toggleSaved.margin;
                _usedSkin.toggle.padding       = toggleSaved.padding;
                _usedSkin.toggle.overflow      = toggleSaved.overflow;
                _usedSkin.toggle.contentOffset = toggleSaved.contentOffset;

                _usedSkin.box       = nativeSkin.box;
                _usedSkin.label     = nativeSkin.label;
                _usedSkin.textField = nativeSkin.textField;
                _usedSkin.button    = nativeSkin.button;

                _usedSkin.label.wordWrap = true;
            }

            // ----------------------------------------------------
            // Add styles we need

            var hasBreadcrumbLeftStyle = _usedSkin.HasStyle("GUIEditor.BreadcrumbLeft");
            var hasBreadcrumbMidStyle  = _usedSkin.HasStyle("GUIEditor.BreadcrumbMid");

            if (!hasBreadcrumbLeftStyle || !hasBreadcrumbMidStyle)
            {
                var newStyles = new List <GUIStyle>(_usedSkin.customStyles);

                if (!hasBreadcrumbLeftStyle)
                {
                    newStyles.Add(nativeSkin.GetStyle("GUIEditor.BreadcrumbLeft"));
                }

                if (!hasBreadcrumbMidStyle)
                {
                    newStyles.Add(nativeSkin.GetStyle("GUIEditor.BreadcrumbMid"));
                }

                _usedSkin.customStyles = newStyles.ToArray();
            }

            // ----------------------------------------------------

            _toolbarIconLog     = _usedSkin.GetStyle("Icon-Toolbar-Log").normal.background;
            _toolbarIconOpen    = _usedSkin.GetStyle("Icon-Toolbar-Open").normal.background;
            _toolbarIconSave    = _usedSkin.GetStyle("Icon-Toolbar-Save").normal.background;
            _toolbarIconOptions = _usedSkin.GetStyle("Icon-Toolbar-Options").normal.background;
            _toolbarIconHelp    = _usedSkin.GetStyle("Icon-Toolbar-Help").normal.background;

            _toolbarLabelLog     = new GUIContent(Labels.REFRESH_LABEL, _toolbarIconLog);
            _toolbarLabelOpen    = new GUIContent(Labels.OPEN_LABEL, _toolbarIconOpen);
            _toolbarLabelSave    = new GUIContent(Labels.SAVE_LABEL, _toolbarIconSave);
            _toolbarLabelOptions = new GUIContent(Labels.OPTIONS_CATEGORY_LABEL, _toolbarIconOptions);
            _toolbarLabelHelp    = new GUIContent(Labels.HELP_CATEGORY_LABEL, _toolbarIconHelp);
        }
    }
Beispiel #24
0
    public void OnGUI()
    {
        if (!guiInitialized)
        {
            GUISkin t_skin = EditorGUIUtility.GetBuiltinSkin(EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector);
            pbStyle.padding           = new RectOffset(2, 2, 1, 1);
            pbStyle.border            = new RectOffset(6, 6, 4, 4);
            pbStyle.normal.background = t_skin.GetStyle("Button").normal.background;
            pbStyle.margin            = new RectOffset(4, 2, 2, 2);
            pbStyle.contentOffset     = new Vector2(0, 0);
        }

        if (!EditorGUIUtility.isProSkin)
        {
            oldColor            = GUI.backgroundColor;
            GUI.backgroundColor = pgButtonColor;
        }

        EditorGUI.BeginChangeCheck();
        t_snapValue = EditorGUILayout.FloatField("", t_snapValue,
                                                 GUILayout.MinWidth(BUTTON_SIZE),
                                                 GUILayout.MaxWidth(BUTTON_SIZE));
        if (EditorGUI.EndChangeCheck())
        {
                        #if PRO
            SetSnapValue(snapUnit, t_snapValue);
                        #endif
        }

        gc_SnapEnabled.image = snapEnabled ? gui_SnapEnabled_on : gui_SnapEnabled_off;
        if (GUILayout.Button(gc_SnapEnabled, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetSnapEnabled(!snapEnabled);
        }

        gc_GridEnabled.image = drawGrid ? gui_GridEnabled_on : gui_GridEnabled_off;
        if (GUILayout.Button(gc_GridEnabled, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetGridEnabled(!drawGrid);
        }

        // if(!ortho)	GUI.enabled = false;
        gc_AngleEnabled.image = drawAngles ? gui_AngleEnabled_on : gui_AngleEnabled_off;
        if (GUILayout.Button(gc_AngleEnabled, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetDrawAngles(!drawAngles);
        }

        EditorGUI.BeginChangeCheck();
        angleValue = EditorGUILayout.FloatField(gc_AngleValue, angleValue,
                                                GUILayout.MinWidth(BUTTON_SIZE),
                                                GUILayout.MaxWidth(BUTTON_SIZE));
        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
        // GUI.enabled = true;

        if (GUILayout.Button(gc_SnapToGrid, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))       //, GUILayout.MaxWidth(50), GUILayout.MinHeight(16)))
        {
            SnapToGrid(Selection.transforms);
        }

        GUILayout.Label(gui_Divider, GUILayout.MaxWidth(BUTTON_SIZE));

        gc_RenderPlaneX.image = (renderPlane & Axis.X) == Axis.X && !fullGrid ? gui_PlaneX_on : gui_PlaneX_off;
        if (GUILayout.Button(gc_RenderPlaneX, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetRenderPlane(Axis.X);
        }

        gc_RenderPlaneY.image = (renderPlane & Axis.Y) == Axis.Y && !fullGrid ? gui_PlaneY_on : gui_PlaneY_off;
        if (GUILayout.Button(gc_RenderPlaneY, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetRenderPlane(Axis.Y);
        }

        gc_RenderPlaneZ.image = (renderPlane & Axis.Z) == Axis.Z && !fullGrid ? gui_PlaneZ_on : gui_PlaneZ_off;
        if (GUILayout.Button(gc_RenderPlaneZ, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            SetRenderPlane(Axis.Z);
        }

        gc_RenderPerspectiveGrid.image = fullGrid ? gui_fullGrid_on : gui_fullGrid_off;
        if (GUILayout.Button(gc_RenderPerspectiveGrid, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            fullGrid = !fullGrid;
            SceneView.RepaintAll();
        }

        gc_LockGrid.image = lockGrid ? gui_LockGrid_on : gui_LockGrid_off;
        if (GUILayout.Button(gc_LockGrid, pbStyle, GUILayout.MaxWidth(BUTTON_SIZE)))
        {
            lockGrid = !lockGrid;
            EditorPrefs.SetBool(pg_Constant.LockGrid, lockGrid);

            // if we've modified the nudge value, reset the pivot here
            if (!lockGrid)
            {
                offset = 0f;
            }

            SceneView.RepaintAll();
        }

                #if PROFILE_TIMES
        if (GUILayout.Button("Times"))
        {
            profiler.DumpTimes();
        }
        if (GUILayout.Button("Reset"))
        {
            profiler.ClearValues();
        }
                #endif

        if (!EditorGUIUtility.isProSkin)
        {
            GUI.backgroundColor = oldColor;
        }
    }
        public void GameViewStatsGUI()
        {
            GUI.skin  = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);
            GUI.color = new Color(1f, 1f, 1f, 0.75f);
            var num  = 300.0f;
            var num2 = 204.0f;

            // int num3 = Network.connections.Length;
            // if (num3 != 0)
            // {
            //     num2 += 220f;
            // }
            GUILayout.BeginArea(new Rect(Screen.width * position - num - 10f, 27f, num, num2), "Statistics", GUI.skin.window);
            GUILayout.Label("Audio:", sectionHeaderStyle, new GUILayoutOption[0]);
            var stringBuilder = new StringBuilder(400);
            var audioLevel    = UnityStats.audioLevel;

            stringBuilder.Append($"  Level: " + FormatDb(audioLevel) + ((!EditorUtility.audioMasterMute) ? "\n" : " (MUTED)\n"));
            stringBuilder.Append($"  Clipping: {100f * UnityStats.audioClippingAmount:F1}%");
            GUILayout.Label(stringBuilder.ToString(), new GUILayoutOption[0]);
            GUI.Label(new Rect(170f, 40f, 120f, 20f),
                      $"DSP load: {100f * UnityStats.audioDSPLoad:F1}%");
            GUI.Label(new Rect(170f, 53f, 120f, 20f),
                      $"Stream load: {100f * UnityStats.audioStreamLoad:F1}%");
            GUILayout.Label("Graphics:", sectionHeaderStyle, new GUILayoutOption[0]);
            UpdateFrameTime();
            var text = $"{1f / Mathf.Max(m_MaxFrameTime, 1E-05f):F1} FPS ({m_MaxFrameTime * 1000f:F1}ms)";

            GUI.Label(new Rect(170f, 75f, 120f, 20f), text);
            var screenBytes    = UnityStats.screenBytes;
            var num4           = UnityStats.dynamicBatchedDrawCalls - UnityStats.dynamicBatches;
            var num5           = UnityStats.staticBatchedDrawCalls - UnityStats.staticBatches;
            var stringBuilder2 = new StringBuilder(400);

            if (m_ClientFrameTime > m_RenderFrameTime)
            {
                stringBuilder2.Append(
                    $"  CPU: main <b>{m_ClientFrameTime * 1000f:F1}</b>ms  render thread {m_RenderFrameTime * 1000f:F1}ms\n");
            }
            else
            {
                stringBuilder2.Append(
                    $"  CPU: main {m_ClientFrameTime * 1000f:F1}ms  render thread <b>{m_RenderFrameTime * 1000f:F1}</b>ms\n");
            }
            stringBuilder2.Append($"  Batches: <b>{UnityStats.batches}</b> \tSaved by batching: {num4 + num5}\n");
            stringBuilder2.Append(
                $"  Tris: {FormatNumber(UnityStats.triangles)} \tVerts: {FormatNumber(UnityStats.vertices)} \n");
            stringBuilder2.Append($"  Screen: {UnityStats.screenRes} - {EditorUtility.FormatBytes(screenBytes)}\n");
            stringBuilder2.Append(
                $"  SetPass calls: {UnityStats.setPassCalls} \tShadow casters: {UnityStats.shadowCasters} \n");
            stringBuilder2.Append(
                $"  Visible skinned meshes: {UnityStats.visibleSkinnedMeshes}  Animations: {UnityStats.visibleAnimations}");
            GUILayout.Label(stringBuilder2.ToString(), labelStyle, new GUILayoutOption[0]);
            // if (num3 != 0)
            // {
            //     GUILayout.Label("Network:", sectionHeaderStyle, new GUILayoutOption[0]);
            //     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            //     for (int i = 0; i < num3; i++)
            //     {
            //         GUILayout.Label(UnityStats.GetNetworkStats(i), new GUILayoutOption[0]);
            //     }
            //     GUILayout.EndHorizontal();
            // }
            // else
            // {
            //     GUILayout.Label("Network: (no players connected)", sectionHeaderStyle, new GUILayoutOption[0]);
            // }
            GUILayout.EndArea();
        }
    void InitGUISkin()
    {
        string guiSkinToUse = BuildReportTool.Window.Settings.DEFAULT_GUI_SKIN_FILENAME;

        if (EditorGUIUtility.isProSkin)
        {
            guiSkinToUse = BuildReportTool.Window.Settings.DARK_GUI_SKIN_FILENAME;
        }

        // try default path
        _usedSkin = AssetDatabase.LoadAssetAtPath(BuildReportTool.Options.BUILD_REPORT_TOOL_DEFAULT_PATH + "/GUI/" + guiSkinToUse, typeof(GUISkin)) as GUISkin;

        if (_usedSkin == null)
        {
#if BRT_SHOW_MINOR_WARNINGS
            Debug.LogWarning(BuildReportTool.Options.BUILD_REPORT_PACKAGE_MOVED_MSG);
#endif

            string folderPath = BuildReportTool.Util.FindAssetFolder(Application.dataPath, BuildReportTool.Options.BUILD_REPORT_TOOL_DEFAULT_FOLDER_NAME);
            if (!string.IsNullOrEmpty(folderPath))
            {
                folderPath = folderPath.Replace('\\', '/');
                int assetsIdx = folderPath.IndexOf("/Assets/");
                if (assetsIdx != -1)
                {
                    folderPath = folderPath.Substring(assetsIdx + 8, folderPath.Length - assetsIdx - 8);
                }
                //Debug.Log(folderPath);

                _usedSkin = AssetDatabase.LoadAssetAtPath("Assets/" + folderPath + "/GUI/" + guiSkinToUse, typeof(GUISkin)) as GUISkin;
            }
            else
            {
                Debug.LogError(BuildReportTool.Options.BUILD_REPORT_PACKAGE_MISSING_MSG);
            }
            //Debug.Log("_usedSkin " + (_usedSkin != null));
        }

        if (_usedSkin != null)
        {
            if (!EditorGUIUtility.isProSkin)
            {
                GUISkin nativeSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

                _usedSkin.verticalScrollbar           = nativeSkin.verticalScrollbar;
                _usedSkin.verticalScrollbarThumb      = nativeSkin.verticalScrollbarThumb;
                _usedSkin.verticalScrollbarUpButton   = nativeSkin.verticalScrollbarUpButton;
                _usedSkin.verticalScrollbarDownButton = nativeSkin.verticalScrollbarDownButton;

                _usedSkin.horizontalScrollbar            = nativeSkin.horizontalScrollbar;
                _usedSkin.horizontalScrollbarThumb       = nativeSkin.horizontalScrollbarThumb;
                _usedSkin.horizontalScrollbarLeftButton  = nativeSkin.horizontalScrollbarLeftButton;
                _usedSkin.horizontalScrollbarRightButton = nativeSkin.horizontalScrollbarRightButton;

                // change the toggle skin to use the Unity builtin look, but keep our settings
                GUIStyle toggleSaved = new GUIStyle(_usedSkin.toggle);

                // make our own copy of the native skin toggle so that editing it won't affect the rest of the editor GUI
                GUIStyle nativeToggleCopy = new GUIStyle(nativeSkin.toggle);

                _usedSkin.toggle               = nativeToggleCopy;
                _usedSkin.toggle.border        = toggleSaved.border;
                _usedSkin.toggle.margin        = toggleSaved.margin;
                _usedSkin.toggle.padding       = toggleSaved.padding;
                _usedSkin.toggle.overflow      = toggleSaved.overflow;
                _usedSkin.toggle.contentOffset = toggleSaved.contentOffset;

                _usedSkin.box       = nativeSkin.box;
                _usedSkin.label     = nativeSkin.label;
                _usedSkin.textField = nativeSkin.textField;
                _usedSkin.button    = nativeSkin.button;


                _usedSkin.label.wordWrap = true;
            }

            // ----------------------------------------------------

            _toolbarIconLog     = _usedSkin.GetStyle("Icon-Toolbar-Log").normal.background;
            _toolbarIconOpen    = _usedSkin.GetStyle("Icon-Toolbar-Open").normal.background;
            _toolbarIconSave    = _usedSkin.GetStyle("Icon-Toolbar-Save").normal.background;
            _toolbarIconOptions = _usedSkin.GetStyle("Icon-Toolbar-Options").normal.background;
            _toolbarIconHelp    = _usedSkin.GetStyle("Icon-Toolbar-Help").normal.background;

            _toolbarLabelLog     = new GUIContent(Labels.REFRESH_LABEL, _toolbarIconLog);
            _toolbarLabelOpen    = new GUIContent(Labels.OPEN_LABEL, _toolbarIconOpen);
            _toolbarLabelSave    = new GUIContent(Labels.SAVE_LABEL, _toolbarIconSave);
            _toolbarLabelOptions = new GUIContent(Labels.OPTIONS_CATEGORY_LABEL, _toolbarIconOptions);
            _toolbarLabelHelp    = new GUIContent(Labels.HELP_CATEGORY_LABEL, _toolbarIconHelp);
        }
    }
Beispiel #27
0
 public static EditorGUILayout.VerticalScope EffectBox(out GUISkin skin)
 {
     skin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
     return(new EditorGUILayout.VerticalScope(skin.box));
 }
        public static void InitStyles()
        {
            if (stylesInitialized)
            {
                return;
            }

            var oldSkin = GUI.skin;

            stylesInitialized = true;
            SetDefaultGUISkin();

            var whiteTexture = MaterialUtility.CreateSolidColorTexture(8, 8, Color.white);

            sceneTextLabel                                 = new GUIStyle(GUI.skin.textArea);
            sceneTextLabel.richText                        = true;
            sceneTextLabel.onActive.background             =
                sceneTextLabel.onFocused.background        =
                    sceneTextLabel.onHover.background      =
                        sceneTextLabel.onNormal.background = whiteTexture;
            sceneTextLabel.onActive.textColor              =
                sceneTextLabel.onFocused.textColor         =
                    sceneTextLabel.onHover.textColor       =
                        sceneTextLabel.onNormal.textColor  = Color.black;


            var toolTipStyle = new GUIStyle(GUI.skin.textArea);

            toolTipStyle.richText       = true;
            toolTipStyle.wordWrap       = true;
            toolTipStyle.stretchHeight  = true;
            toolTipStyle.padding.left  += 4;
            toolTipStyle.padding.right += 4;
            toolTipStyle.clipping       = TextClipping.Overflow;

            toolTipTitleStyle                 = new GUIStyle(toolTipStyle);
            toolTipTitleStyle.padding.top    += 4;
            toolTipTitleStyle.padding.bottom += 2;
            toolTipContentsStyle              = new GUIStyle(toolTipStyle);
            toolTipKeycodesStyle              = new GUIStyle(toolTipStyle);
            toolTipKeycodesStyle.padding.top += 2;


            rightAlignedLabel           = new GUIStyle();
            rightAlignedLabel.alignment = TextAnchor.MiddleRight;

            unpaddedWindow = new GUIStyle(GUI.skin.window);
            unpaddedWindow.padding.left   = 2;
            unpaddedWindow.padding.bottom = 2;


            emptyMaterialStyle = new GUIStyle(GUIStyle.none);
            emptyMaterialStyle.normal.background = MaterialUtility.CreateSolidColorTexture(2, 2, Color.black);


            selectionRectStyle = GetStyle("selectionRect");


            var redToolbarDropDown = GetStyle("toolbarDropDown");

            Pro.redToolbarDropDown = new GUIStyle(redToolbarDropDown);
            //Pro.redToolbarDropDown.normal.background = MaterialUtility.CreateSolidColorTexture(2, 2, Color.red);
            Pro.redToolbarDropDown.normal.textColor   = Color.Lerp(Color.red, redToolbarDropDown.normal.textColor, 0.5f);
            Pro.redToolbarDropDown.onNormal.textColor = Color.Lerp(Color.red, redToolbarDropDown.onNormal.textColor, 0.125f);
            Personal.redToolbarDropDown = new GUIStyle(redToolbarDropDown);
            //Personal.redToolbarDropDown.normal.background = MaterialUtility.CreateSolidColorTexture(2, 2, Color.red);
            Personal.redToolbarDropDown.normal.textColor   = Color.Lerp(Color.red, redToolbarDropDown.normal.textColor, 0.5f);
            Personal.redToolbarDropDown.onNormal.textColor = Color.Lerp(Color.red, redToolbarDropDown.onNormal.textColor, 0.125f);


            Pro.menuItem      = GetStyle("MenuItem");
            Personal.menuItem = GetStyle("MenuItem");

            Pro.lockedBackgroundColor = Color.Lerp(Color.white, Color.red, 0.5f);

            Pro.xToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Pro.xToolbarButton.normal.textColor   = Color.Lerp(Handles.xAxisColor, Color.gray, 0.75f);
            Pro.xToolbarButton.onNormal.textColor = Color.Lerp(Handles.xAxisColor, Color.white, 0.125f);

            Pro.yToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Pro.yToolbarButton.normal.textColor   = Color.Lerp(Handles.yAxisColor, Color.gray, 0.75f);
            Pro.yToolbarButton.onNormal.textColor = Color.Lerp(Handles.yAxisColor, Color.white, 0.125f);

            Pro.zToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Pro.zToolbarButton.normal.textColor   = Color.Lerp(Handles.zAxisColor, Color.gray, 0.75f);
            Pro.zToolbarButton.onNormal.textColor = Color.Lerp(Handles.zAxisColor, Color.white, 0.125f);

            Personal.lockedBackgroundColor = Color.Lerp(Color.black, Color.red, 0.5f);

            Personal.xToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Personal.xToolbarButton.normal.textColor   = Color.Lerp(Handles.xAxisColor, Color.white, 0.75f);
            Personal.xToolbarButton.onNormal.textColor = Color.Lerp(Handles.xAxisColor, Color.black, 0.25f);

            Personal.yToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Personal.yToolbarButton.normal.textColor   = Color.Lerp(Handles.yAxisColor, Color.white, 0.75f);
            Personal.yToolbarButton.onNormal.textColor = Color.Lerp(Handles.yAxisColor, Color.black, 0.25f);

            Personal.zToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
            Personal.zToolbarButton.normal.textColor   = Color.Lerp(Handles.zAxisColor, Color.white, 0.75f);
            Personal.zToolbarButton.onNormal.textColor = Color.Lerp(Handles.zAxisColor, Color.black, 0.25f);

            redTextArea = new GUIStyle(GUI.skin.textArea);
            redTextArea.normal.textColor = Color.red;

            redTextLabel = new GUIStyle(GUI.skin.label);
            redTextLabel.normal.textColor = Color.red;
            redTextLabel.richText         = true;
            redTextLabel.wordWrap         = true;

            redButton = new GUIStyle(GUI.skin.button);
            redButton.normal.textColor = Color.red;

            wrapLabel          = new GUIStyle(GUI.skin.label);
            wrapLabel.wordWrap = true;



            versionLabelStyle           = new GUIStyle(EditorStyles.label);
            versionLabelStyle.alignment = TextAnchor.MiddleRight;
            //versionLabelStyle.fontSize = versionLabelStyle.font.fontSize - 1;
            var original_color = versionLabelStyle.normal.textColor;

            original_color.a = 0.4f;
            versionLabelStyle.normal.textColor = original_color;

            BottomToolBarStyle = new GUIStyle(EditorStyles.toolbar);
            //BottomToolBarStyle.fixedHeight = BottomToolBarHeight;


            brushEditModeContent = new GUIContent[]
            {
                new GUIContent("Place"),
                new GUIContent("Generate"),
                new GUIContent("Edit"),
                new GUIContent("Clip"),
                new GUIContent("Surfaces")
            };

            brushEditModeTooltips = new ToolTip[]
            {
                new ToolTip("Place mode", "In this mode you can place, rotate and scale brushes", Keys.SwitchToObjectEditMode),
                new ToolTip("Generate mode", "In this mode you can create brushes using several generators", Keys.SwitchToGenerateEditMode),
                new ToolTip("Edit mode", "In this mode you can edit the shapes of brushes", Keys.SwitchToMeshEditMode),
                new ToolTip("Clip mode", "In this mode you can split or clip brushes", Keys.SwitchToClipEditMode),
                new ToolTip("Surfaces mode", "In this mode you can modify the texturing and everything else related to brush surfaces", Keys.SwitchToSurfaceEditMode)
            };

            var enum_type = typeof(ToolEditMode);

            brushEditModeNames  = (from name in System.Enum.GetNames(enum_type) select ObjectNames.NicifyVariableName(name)).ToArray();
            brushEditModeValues = System.Enum.GetValues(enum_type).Cast <ToolEditMode>().ToArray();
            for (int i = 0; i < brushEditModeNames.Length; i++)
            {
                if (brushEditModeContent[i].text != brushEditModeNames[i])
                {
                    Debug.LogError("Fail!");
                }
            }

            var pro_skin      = CSG_GUIStyleUtility.Pro;
            var personal_skin = CSG_GUIStyleUtility.Personal;

            for (int i = 0; i < clipTypeCount; i++)
            {
                pro_skin.clipNames[i]   = new GUIContent(proInActiveClipTypes[i]);
                pro_skin.clipNamesOn[i] = new GUIContent(proActiveClipTypes[i]);

                pro_skin.clipNames[i].text   = clipText[i];
                pro_skin.clipNamesOn[i].text = clipText[i];

                personal_skin.clipNames[i]   = new GUIContent(personalActiveClipTypes[i]);
                personal_skin.clipNamesOn[i] = new GUIContent(personalInActiveClipTypes[i]);

                personal_skin.clipNames[i].text   = clipText[i];
                personal_skin.clipNamesOn[i].text = clipText[i];
            }

            pro_skin.passThrough          = new GUIContent(proPassThrough);
            pro_skin.passThroughOn        = new GUIContent(proPassThroughOn);
            pro_skin.hierarchyPassThrough = new GUIContent(proPassThroughOn);
            pro_skin.passThrough.text     = passThroughText;
            pro_skin.passThroughOn.text   = passThroughText;


            personal_skin.passThrough          = new GUIContent(personalPassThrough);
            personal_skin.passThroughOn        = new GUIContent(personalPassThroughOn);
            personal_skin.hierarchyPassThrough = new GUIContent(personalPassThroughOn);
            personal_skin.passThrough.text     = passThroughText;
            personal_skin.passThroughOn.text   = passThroughText;


            pro_skin.wireframe           = new GUIContent(proWireframe);
            pro_skin.wireframeOn         = new GUIContent(proWireframeOn);
            pro_skin.wireframe.tooltip   = wireframeTooltip;
            pro_skin.wireframeOn.tooltip = wireframeTooltip;

            personal_skin.wireframe           = new GUIContent(personalWireframe);
            personal_skin.wireframeOn         = new GUIContent(personalWireframeOn);
            personal_skin.wireframe.tooltip   = wireframeTooltip;
            personal_skin.wireframeOn.tooltip = wireframeTooltip;



            for (int i = 0; i < shapeModeCount; i++)
            {
                pro_skin.shapeModeNames[i]   = new GUIContent(proInActiveShapeModes[i]);
                pro_skin.shapeModeNamesOn[i] = new GUIContent(proActiveShapeModes[i]);

                personal_skin.shapeModeNames[i]   = new GUIContent(personalActiveShapeModes[i]);
                personal_skin.shapeModeNamesOn[i] = new GUIContent(personalInActiveShapeModes[i]);

                pro_skin.shapeModeNames[i].text   = shapeModeText[i];
                pro_skin.shapeModeNamesOn[i].text = shapeModeText[i];

                personal_skin.shapeModeNames[i].text   = shapeModeText[i];
                personal_skin.shapeModeNamesOn[i].text = shapeModeText[i];
            }


            for (int i = 0; i < operationTypeCount; i++)
            {
                pro_skin.operationNames[i]      = new GUIContent(proInActiveOperationTypes[i]);
                pro_skin.operationNamesOn[i]    = new GUIContent(proActiveOperationTypes[i]);
                pro_skin.hierarchyOperations[i] = new GUIContent(proActiveOperationTypes[i]);

                personal_skin.operationNames[i]      = new GUIContent(personalActiveOperationTypes[i]);
                personal_skin.operationNamesOn[i]    = new GUIContent(personalInActiveOperationTypes[i]);
                personal_skin.hierarchyOperations[i] = new GUIContent(personalInActiveOperationTypes[i]);

                pro_skin.operationNames[i].text   = operationText[i];
                pro_skin.operationNamesOn[i].text = operationText[i];

                personal_skin.operationNames[i].text   = operationText[i];
                personal_skin.operationNamesOn[i].text = operationText[i];
            }

            pro_skin.rebuildIcon    = proRebuildIcon;
            pro_skin.gridIcon       = proGridIcon;
            pro_skin.gridIconOn     = proGridIconOn;
            pro_skin.gridSnapIcon   = proGridSnapIcon;
            pro_skin.gridSnapIconOn = proGridSnapIconOn;
            pro_skin.relSnapIcon    = proRelSnapIcon;
            pro_skin.relSnapIconOn  = proRelSnapIconOn;
            pro_skin.noSnapIcon     = proNoSnapIcon;
            pro_skin.noSnapIconOn   = proNoSnapIconOn;

            //pro_skin.rebuildIcon.tooltip	= rebuildTooltip;
            //pro_skin.gridIcon.tooltip		= gridTooltip;
            //pro_skin.gridIconOn.tooltip		= gridOnTooltip;
            //pro_skin.snappingIcon.tooltip	= snappingTooltip;
            //pro_skin.snappingIconOn.tooltip	= snappingOnTooltip;

            personal_skin.rebuildIcon    = personalRebuildIcon;
            personal_skin.gridIcon       = personalGridIcon;
            personal_skin.gridIconOn     = personalGridIconOn;
            personal_skin.gridSnapIcon   = personalGridSnapIcon;
            personal_skin.gridSnapIconOn = personalGridSnapIconOn;
            personal_skin.relSnapIcon    = personalRelSnapIcon;
            personal_skin.relSnapIconOn  = personalRelSnapIconOn;
            personal_skin.noSnapIcon     = personalNoSnapIcon;
            personal_skin.noSnapIconOn   = personalNoSnapIconOn;

            //personal_skin.rebuildIcon.tooltip		= rebuildTooltip;
            //personal_skin.gridIcon.tooltip			= gridTooltip;
            //personal_skin.gridIconOn.tooltip		= gridOnTooltip;
            //personal_skin.snappingIcon.tooltip		= snappingTooltip;
            //personal_skin.snappingIconOn.tooltip	= snappingOnTooltip;

            var skin2 = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);

            personal_skin.messageStyle        = new GUIStyle(skin2.textArea);
            personal_skin.messageWarningStyle = new GUIStyle(personal_skin.messageStyle);

            pro_skin.messageStyle        = new GUIStyle(skin2.textArea);
            pro_skin.messageWarningStyle = new GUIStyle(pro_skin.messageStyle);


            unselectedIconLabelStyle          = new GUIStyle(GUI.skin.label);
            unselectedIconLabelStyle.richText = true;
            var color = unselectedIconLabelStyle.normal.textColor;

            color.r *= 232.0f / 255.0f;
            color.g *= 232.0f / 255.0f;
            color.b *= 232.0f / 255.0f;
            color.a  = 153.0f / 255.0f;
            unselectedIconLabelStyle.normal.textColor = color;

            selectedIconLabelStyle          = new GUIStyle(GUI.skin.label);
            selectedIconLabelStyle.richText = true;

            GUI.skin = oldSkin;
        }
        public override void OnInspectorGUI()
        {
            //Update our list
            serializedObject.Update();

            if (logo == null)
            {
                if (EditorGUIUtility.isProSkin)
                {
                    logo = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Digicrafts/IAPManager/Editor/logo_pro.png");
                }
                else
                {
                    logo = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Digicrafts/IAPManager/Editor/logo.png");
                }
            }
            if (logoStyle == null)
            {
                logoStyle                   = new GUIStyle(GUI.skin.GetStyle("Label"));
                logoStyle.alignment         = TextAnchor.UpperCenter;
                logoStyle.normal.background = logo;
                logoBackgroundStyle         = new  GUIStyle(GUI.skin.label);
                _titleStyle                 = new GUIStyle(GUI.skin.label);
                _titleStyle.fontSize        = 14;
                _titleStyle.fixedHeight     = 20;


                listHeader = "RL Header";

                _addButtonStyle = new GUIStyle(GUI.skin.button);

                if (EditorGUIUtility.isProSkin)
                {
                    _addButtonStyle.normal.textColor = Color.yellow;
                }
                else
                {
                    _addButtonStyle.normal.textColor = Color.black;
                }

                _deleteButtonIcon = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Digicrafts/IAPManager/Editor/delete.png");

                GUISkin editorSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
                listFoldout = new GUIStyle(GUI.skin.toggle);
                listFoldout.normal.background    = listFoldout.focused.background = listFoldout.active.background = editorSkin.GetStyle("Foldout").normal.background;
                listFoldout.onFocused.background = listFoldout.onActive.background = listFoldout.onNormal.background = listFoldout.onHover.background = editorSkin.GetStyle("PaneOptions").normal.background;
            }

            EditorGUILayout.Space();

            //// Logo
            EditorGUILayout.BeginHorizontal(logoBackgroundStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("", logoStyle, GUILayout.Width(300), GUILayout.Height(50));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            //// Logo


            EditorGUI.BeginChangeCheck();

            EditorGUILayout.Separator();

            /////////////////////////////////////////////////////////////////////////////////
            /// Package
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("In App Products", _titleStyle);
            EditorGUILayout.Space();

            SerializedProperty arraySizeProp = _productSettings.FindPropertyRelative("Array.size");

            EditorGUILayout.BeginVertical(GUI.skin.box);

            //Header
            EditorGUILayout.BeginHorizontal(listHeader);
            EditorGUILayout.LabelField(" ", GUILayout.Width(15));
            EditorGUILayout.LabelField("Identify", GUILayout.MinWidth(15));
            EditorGUILayout.LabelField("Type", GUILayout.Width(110));
            EditorGUILayout.EndHorizontal();
            //Header

//			EditorGUI.indentLevel=1;
//			EditorGUILayout.BeginHorizontal();
//			_packageFoldout=EditorGUILayout.Foldout(_packageFoldout,"Product List");

//			if(_packageFoldout){

//				if(GUILayout.Button("+ Add New In App Purchase",_addButtonStyle)){
//					_productSettings.InsertArrayElementAtIndex(_productSettings.arraySize);
//					_packageFoldoutIds.Add(false);
//					_packageFoldoutObjects.Add(false);
//				}
//				EditorGUILayout.EndHorizontal();
//				EditorGUI.indentLevel=1;
//				EditorGUILayout.BeginVertical();
            for (int i = 0; i < arraySizeProp.intValue; i++)
            {
                if (_packageFoldouts.Count < i + 1)
                {
                    _packageFoldouts.Add(false);
                }
                if (_packageFoldoutIds.Count < i + 1)
                {
                    _packageFoldoutIds.Add(false);
                }
                if (_packageFoldoutObjects.Count < i + 1)
                {
                    _packageFoldoutObjects.Add(false);
                }

                EditorGUI.indentLevel = 0;
                SerializedProperty objRef      = _productSettings.GetArrayElementAtIndex(i);
                SerializedProperty productId   = objRef.FindPropertyRelative("productId");
                SerializedProperty productType = objRef.FindPropertyRelative("productType");
                bool isSubscription            = (productType.enumNames[productType.enumValueIndex] == "Subscription");

//					if(i != 0) GUILayout.Box("",GUILayout.Height(2),GUILayout.ExpandWidth(true));
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                _packageFoldouts[i] = EditorGUILayout.Toggle(GUIContent.none, _packageFoldouts[i], listFoldout, GUILayout.Width(15));
//					EditorGUILayout.LabelField("ID:",GUILayout.MaxWidth(20));
                productId.stringValue      = EditorGUILayout.TextField(GUIContent.none, productId.stringValue, GUILayout.MinWidth(15));
                productType.enumValueIndex = (int)(IAPProductType)EditorGUILayout.EnumPopup((IAPProductType)Enum.GetValues(typeof(IAPProductType)).GetValue(productType.enumValueIndex), GUILayout.Width(90));
                if (GUILayout.Button(_deleteButtonIcon, GUIStyle.none, GUILayout.Width(20)))
                {
                    _productSettings.DeleteArrayElementAtIndex(i);
                    _packageFoldoutIds.RemoveAt(i);
                    _packageFoldoutObjects.RemoveAt(i);
                }
                EditorGUILayout.EndHorizontal();

                if (_packageFoldouts[i])
                {
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = 1;
                    if (i < _packageFoldoutIds.Count)
                    {
                        _packageFoldoutIds[i] = EditorGUILayout.Foldout(_packageFoldoutIds[i], "Override Product Ids");
                        //
                        if (_packageFoldoutIds[i])
                        {
                            SerializedProperty appleProductId   = objRef.FindPropertyRelative("appleProductId");
                            SerializedProperty googleProductId  = objRef.FindPropertyRelative("googleProductId");
                            SerializedProperty amazonProductId  = objRef.FindPropertyRelative("amazonProductId");
                            SerializedProperty macProductId     = objRef.FindPropertyRelative("macProductId");
                            SerializedProperty samsungProductId = objRef.FindPropertyRelative("samsungProductId");
                            SerializedProperty tizenProductId   = objRef.FindPropertyRelative("tizenProductId");
                            SerializedProperty moolahProductId  = objRef.FindPropertyRelative("moolahProductId");
                            EditorGUILayout.PropertyField(appleProductId);
                            EditorGUILayout.PropertyField(googleProductId);
                            EditorGUILayout.PropertyField(amazonProductId);
                            EditorGUILayout.PropertyField(macProductId);
                            EditorGUILayout.PropertyField(samsungProductId);
                            EditorGUILayout.PropertyField(tizenProductId);
                            EditorGUILayout.PropertyField(moolahProductId);
                            EditorGUILayout.Space();
                        }
                        _packageFoldoutObjects[i] = EditorGUILayout.Foldout(_packageFoldoutObjects[i], "UI Connections");
                        if (_packageFoldoutObjects[i])
                        {
                            SerializedProperty buyButton          = objRef.FindPropertyRelative("buyButton");
                            SerializedProperty priceLabel         = objRef.FindPropertyRelative("priceLabel");
                            SerializedProperty titleLabel         = objRef.FindPropertyRelative("titleLabel");
                            SerializedProperty descriptionLabel   = objRef.FindPropertyRelative("descriptionLabel");
                            SerializedProperty buyButtonText      = objRef.FindPropertyRelative("buyButtonText");
                            SerializedProperty disabledButtonText = objRef.FindPropertyRelative("disabledButtonText");

                            EditorGUILayout.PropertyField(buyButtonText);
                            EditorGUILayout.PropertyField(disabledButtonText);
                            EditorGUILayout.PropertyField(buyButton);
                            EditorGUILayout.PropertyField(priceLabel);
                            EditorGUILayout.PropertyField(titleLabel);
                            EditorGUILayout.PropertyField(descriptionLabel);
                            if (isSubscription)
                            {
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("purchaseDateLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("remainingTimeLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("cancelDateLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("expireDateLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("freeTrialPeriodLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("introductoryPriceLabel"));
                                EditorGUILayout.PropertyField(objRef.FindPropertyRelative("introductoryPricePeriodLabel"));
                            }

                            EditorGUILayout.Space();
                        }
                    }
                }

//				EditorGUILayout.EndVertical();

//			} else {
//
//				EditorGUILayout.EndHorizontal();
//
//			}
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("+ Add New In App Purchase", _addButtonStyle))
            {
                _productSettings.InsertArrayElementAtIndex(_productSettings.arraySize);
                _packageFoldoutIds.Add(false);
                _packageFoldoutObjects.Add(false);
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            EditorGUI.indentLevel = 0;
            /// Package
            /////////////////////////////////////////////////////////////////////////////////



            /////////////////////////////////////////////////////////////////////////////////
            /// General
            EditorGUILayout.LabelField("General", _titleStyle);
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(GUI.skin.box);
//			[Header ("The target contains script handle the events", order = 3)]
            EditorGUILayout.LabelField("Target contains script handle the events");
            EditorGUILayout.PropertyField(_eventTarget);
            EditorGUILayout.LabelField("Target object for restore button");
            EditorGUILayout.PropertyField(_restoreButton);
            EditorGUILayout.EndVertical();
            /// Events
            /////////////////////////////////////////////////////////////////////////////////

            EditorGUILayout.Separator();


            /////////////////////////////////////////////////////////////////////////////////
            /// Events
            EditorGUILayout.LabelField("Events", _titleStyle);
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.indentLevel = 1;
            _eventFoldout         = EditorGUILayout.Foldout(_eventFoldout, "Events List");
            EditorGUI.indentLevel = 0;
            if (_eventFoldout)
            {
                SerializedProperty OnInitialized          = serializedObject.FindProperty("OnInitialized");
                SerializedProperty OnInitializeFailed     = serializedObject.FindProperty("OnInitializeFailed");
                SerializedProperty OnPurchaseStart        = serializedObject.FindProperty("OnPurchaseStart");
                SerializedProperty OnProcessPurchase      = serializedObject.FindProperty("OnProcessPurchase");
                SerializedProperty OnPurchaseFailed       = serializedObject.FindProperty("OnPurchaseFailed");
                SerializedProperty OnPurchaseDeferred     = serializedObject.FindProperty("OnPurchaseDeferred");
                SerializedProperty OnTransactionsRestored = serializedObject.FindProperty("OnTransactionsRestored");
                EditorGUILayout.PropertyField(OnInitialized);
                EditorGUILayout.PropertyField(OnInitializeFailed);
                EditorGUILayout.PropertyField(OnPurchaseStart);
                EditorGUILayout.PropertyField(OnProcessPurchase);
                EditorGUILayout.PropertyField(OnPurchaseFailed);
                EditorGUILayout.PropertyField(OnPurchaseDeferred);
                EditorGUILayout.PropertyField(OnTransactionsRestored);
            }
            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel = 0;
            /// Events
            /////////////////////////////////////////////////////////////////////////////////

            EditorGUILayout.Separator();

            /////////////////////////////////////////////////////////////////////////////////
            /// Advanced
            SerializedProperty testMode          = _advancedSetting.FindPropertyRelative("testMode");
            SerializedProperty receiptValidation = _advancedSetting.FindPropertyRelative("receiptValidation");
            SerializedProperty GooglePublicKey   = _advancedSetting.FindPropertyRelative("GooglePublicKey");
            SerializedProperty MoolahAppKey      = _advancedSetting.FindPropertyRelative("MoolahAppKey");
            SerializedProperty MoolahHashKey     = _advancedSetting.FindPropertyRelative("MoolahHashKey");
            SerializedProperty TizenGroupId      = _advancedSetting.FindPropertyRelative("TizenGroupId");

            EditorGUILayout.LabelField("Advanced", _titleStyle);
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            testMode.boolValue          = EditorGUILayout.Toggle("Enable Test Mode", testMode.boolValue);
            receiptValidation.boolValue = EditorGUILayout.Toggle("Enable Receipt Validation", receiptValidation.boolValue);
            EditorGUILayout.PropertyField(GooglePublicKey);
            EditorGUILayout.PropertyField(MoolahAppKey);
            EditorGUILayout.PropertyField(MoolahHashKey);
            EditorGUILayout.PropertyField(TizenGroupId);
            EditorGUILayout.EndVertical();
            /// Advanced
            /////////////////////////////////////////////////////////////////////////////////


            if (receiptValidation.boolValue)
            {
                AddCompileDefine("RECEIPT_VALIDATION");
            }
            else
            {
                RemoveCompileDefine("RECEIPT_VALIDATION");
            }

            //Apply the changes to our list
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Beispiel #30
0
    void OnGUI()
    {
        objects.RemoveAll(o => o == null);

        GUILayout.BeginHorizontal("Box");

        if (GUILayout.Button("Add selected"))
        {
            AddSelection();
        }

        if (GUILayout.Button("Use selected"))
        {
            UseSelection();
        }

        columnWidth = EditorGUILayout.IntField("Column width", columnWidth);

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        if (objects == null)
        {
            return;
        }

        scrollViewPos = GUILayout.BeginScrollView(scrollViewPos);

        GUILayout.BeginHorizontal();

        Object removedObject = null;

        foreach (var o in objects)
        {
            if (o == null)
            {
                continue;
            }

            var selected = Selection.objects.Contains(o);

            var skin              = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector);
            var selectColor       = skin.settings.selectionColor;
            var objectHeaderStyle = new GUIStyle(GUI.skin.box);

            var objectHeaderSelectedStyle = new GUIStyle(GUI.skin.box);
            objectHeaderSelectedStyle.normal.background = CreateTexture2D(2, 2, selectColor);

            GUILayout.BeginVertical("Box", GUILayout.MaxWidth(columnWidth), GUILayout.Width(columnWidth), GUILayout.ExpandWidth(false));

            // Object header
            var objectEditor = GetOrCreateEditor(o);

            var headerStyle = selected ? objectHeaderSelectedStyle : objectHeaderStyle;
            var headerRect  = EditorGUILayout.BeginHorizontal(headerStyle);

            objectEditor.DrawHeader();

            if (GUILayout.Button("-"))
            {
                removedObject = o;
            }

            GUILayout.EndHorizontal();

            var cev = Event.current;
            if (headerRect.Contains(cev.mousePosition))
            {
                var mouseLeftClick  = (cev.type == EventType.MouseUp) && cev.button == 0 && cev.clickCount == 1;
                var mouseRightClick = (cev.type == EventType.MouseUp) && cev.button == 1 && cev.clickCount == 1;
                var mouseStartDrag  = (cev.type == EventType.MouseDrag) && cev.button == 0;

                if (mouseStartDrag)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.StartDrag(o.name);
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { o };
                    Event.current.Use();
                }
                else if (mouseRightClick)
                {
                    EditorGUIUtility.PingObject(o);
                    Event.current.Use();
                }
                else if (mouseLeftClick)
                {
                    if (Event.current.control)
                    {
                        var list = new List <Object>(Selection.objects);
                        if (list.Contains(o))
                        {
                            list.Remove(o);
                        }
                        else
                        {
                            list.Add(o);
                        }
                        Selection.objects = list.ToArray();
                    }
                    else
                    {
                        Selection.activeObject = o;
                    }
                    Event.current.Use();
                }
            }


            //gameObjectEditor.DrawDefaultInspector();
            //gameObjectEditor.OnInspectorGUI();

            var gameObject = o as GameObject;
            if (gameObject != null)
            {
                var components = gameObject.GetComponents <Component>();
                foreach (var component in components)
                {
                    EditorGUIUtility.wideMode = true;
                    GUILayout.Label(component.GetType().Name, EditorStyles.boldLabel);

                    var componentEditor = GetOrCreateEditor(component);
                    componentEditor.OnInspectorGUI();

                    EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                }
            }
            else
            {
                objectEditor.OnInspectorGUI();
            }

            GUILayout.EndVertical();
        }

        GUILayout.EndHorizontal();

        GUILayout.EndScrollView();

        if (removedObject != null)
        {
            objects.Remove(removedObject);
            editors.Remove(removedObject);
        }
    }