Exemple #1
0
    public override bool PeiceInspectorGUI()
    {
        bool   flag = base.PeiceInspectorGUI();
        string str  = base.peiceID;

        if (AuthorShared.StringField("Title", ref str, new GUILayoutOption[0]))
        {
            base.peiceID = str;
            flag         = true;
        }
        bool     flag1    = (!this.mirrored ? false : this.mirrored != this.bone);
        bool     flag2    = this.bone;
        BodyPart bodyPart = this.bodyPart;

        if (AuthorShared.ObjectField <Transform>("Bone", ref this.bone, AuthorShared.ObjectFieldFlags.AllowScene | AuthorShared.ObjectFieldFlags.Model | AuthorShared.ObjectFieldFlags.Instance, new GUILayoutOption[0]))
        {
            if (!flag2)
            {
                this.FigureOutDefaultBodyPart(this.bone, ref bodyPart);
            }
            flag = true;
        }
        BodyPart bodyPart1 = this.mirroredBodyPart;

        if (flag2)
        {
            bodyPart = (BodyPart)AuthorShared.EnumField("Body Part", bodyPart, new GUILayoutOption[0]);
        }
        GUI.Box(AuthorShared.BeginVertical(new GUILayoutOption[0]), GUIContent.none);
        flag = flag | AuthorShared.ObjectField <Transform>("Mirrored Bone", ref this.mirrored, AuthorShared.ObjectFieldFlags.AllowScene | AuthorShared.ObjectFieldFlags.Model | AuthorShared.ObjectFieldFlags.Instance, new GUILayoutOption[0]);
        if (flag1)
        {
            bodyPart1 = (BodyPart)AuthorShared.EnumField("Body Part", bodyPart1, new GUILayoutOption[0]);
            AuthorShared.BeginHorizontal(new GUILayoutOption[0]);
            bool flag3 = GUILayout.Toggle(this.mirrorX, "Mirror X", new GUILayoutOption[0]);
            bool flag4 = GUILayout.Toggle(this.mirrorY, "Mirror Y", new GUILayoutOption[0]);
            bool flag5 = GUILayout.Toggle(this.mirrorZ, "Mirror Z", new GUILayoutOption[0]);
            AuthorShared.EndHorizontal();
            if (flag3 != this.mirrorX || flag4 != this.mirrorY || flag5 != this.mirrorZ)
            {
                this.mirrorX = flag3;
                this.mirrorY = flag4;
                this.mirrorZ = flag5;
                flag         = true;
            }
        }
        AuthorShared.EndVertical();
        Vector3 vector3  = this.center;
        float   single   = this.radius;
        float   single1  = this.height;
        Vector3 vector31 = this.size;
        int     num      = this.capsuleAxis;

        AuthorShared.BeginSubSection("Shape", new GUILayoutOption[0]);
        HitShapeKind hitShapeKind = (HitShapeKind)AuthorShared.EnumField("Kind", this.kind, new GUILayoutOption[0]);

        switch (this.kind)
        {
        case HitShapeKind.Sphere:
        {
            vector3 = AuthorShared.Vector3Field("Center", this.center, new GUILayoutOption[0]);
            single  = Mathf.Max(AuthorShared.FloatField("Radius", this.radius, new GUILayoutOption[0]), 0.001f);
            goto case HitShapeKind.Line;
        }

        case HitShapeKind.Capsule:
        {
            vector3 = AuthorShared.Vector3Field("Center", this.center, new GUILayoutOption[0]);
            single  = Mathf.Max(AuthorShared.FloatField("Radius", this.radius, new GUILayoutOption[0]), 0.001f);
            single1 = Mathf.Max(AuthorShared.FloatField("Height", this.height, new GUILayoutOption[0]), 0.001f);
            num     = Mathf.Clamp(AuthorShared.IntField("Height Axis", this.capsuleAxis, new GUILayoutOption[0]), 0, 2);
            goto case HitShapeKind.Line;
        }

        case HitShapeKind.Line:
        {
            AuthorShared.EndSubSection();
            AuthorShared.BeginSubSection("Rigidbody", new GUILayoutOption[0]);
            float single2 = Mathf.Max(AuthorShared.FloatField("Mass", this.mass, new GUILayoutOption[0]), 0.001f);
            float single3 = Mathf.Max(AuthorShared.FloatField("Drag", this.drag, new GUILayoutOption[0]), 0f);
            float single4 = Mathf.Max(AuthorShared.FloatField("Angular Drag", this.angularDrag, new GUILayoutOption[0]), 0f);
            AuthorShared.EndSubSection();
            AuthorShared.BeginSubSection("Hit Box", new GUILayoutOption[0]);
            int   num1    = this.hitPriority;
            float single5 = this.damageMultiplier;
            if (flag1 || flag2)
            {
                num1    = AuthorShared.IntField("Hit Priority", num1, new GUILayoutOption[0]);
                single5 = AuthorShared.FloatField("Damage Mult.", single5, new GUILayoutOption[0]);
            }
            AuthorShared.EndSubSection();
            bool flag6 = GUILayout.Button("Add Joint", new GUILayoutOption[0]);
            if (Event.current.type == EventType.Repaint)
            {
                this.lastPopupRect = GUILayoutUtility.GetLastRect();
            }
            if (flag6)
            {
                AuthorShared.CustomMenu(this.lastPopupRect, AuthorChHit.JointMenu.options, 0, new AuthorShared.CustomMenuProc(AuthorChHit.JointMenu.Callback), this);
            }
            if (hitShapeKind != this.kind || vector3 != this.center || vector31 != this.size || single != this.radius || single1 != this.height || num != this.capsuleAxis || single2 != this.mass || single3 != this.drag || single4 != this.angularDrag || bodyPart != this.bodyPart || bodyPart1 != this.mirroredBodyPart || this.hitPriority != num1 || single5 != this.damageMultiplier)
            {
                flag                  = true;
                this.kind             = hitShapeKind;
                this.center           = vector3;
                this.size             = vector31;
                this.radius           = single;
                this.height           = single1;
                this.capsuleAxis      = num;
                this.mass             = single2;
                this.drag             = single3;
                this.angularDrag      = single4;
                this.bodyPart         = bodyPart;
                this.mirroredBodyPart = bodyPart1;
                this.hitPriority      = num1;
                this.damageMultiplier = single5;
            }
            return(flag);
        }

        case HitShapeKind.Box:
        {
            vector3  = AuthorShared.Vector3Field("Center", this.center, new GUILayoutOption[0]);
            vector31 = AuthorShared.Vector3Field("Size", this.size, new GUILayoutOption[0]);
            goto case HitShapeKind.Line;
        }

        default:
        {
            goto case HitShapeKind.Line;
        }
        }
    }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            const float height = 45;

            EditorGUILayout.Space();
            var selectedRect = GUILayoutUtility.GetLastRect();
            selectedRect.y += selectedRect.height;
            selectedRect.height = height + EditorGUIUtility.standardVerticalSpacing;

            serializedObject.Update();

            EditorGUILayout.BeginVertical();
            {
                for (int i = 0; i < m_actionsPropertry.arraySize; ++i)
                {
                    if (i == m_selectedIndex)
                    {
                        EditorGUI.DrawRect(selectedRect, GUI.skin.settings.selectionColor);
                    }

                    EditorGUILayout.BeginVertical(GUILayout.Height(height));
                    {
                        EditorGUI.BeginChangeCheck();

                        var nameProperty = serializedObject.FindProperty("m_actions.Array.data[" + i + "].m_name");
                        var targetProperty = serializedObject.FindProperty("m_actions.Array.data[" + i + "].m_target");
                        var componentTypeProperty = serializedObject.FindProperty("m_actions.Array.data[" + i + "].m_componentTypeName");
                        var componentMethodProperty = serializedObject.FindProperty("m_actions.Array.data[" + i + "].m_componentMethodName");

                        EditorGUILayout.PropertyField(nameProperty, new GUIContent("Display Name"));

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PropertyField(targetProperty, GUIContent.none, GUILayout.Width(EditorGUIUtility.labelWidth));
                            var target = targetProperty.objectReferenceValue as GameObject;

                            var functions = ListFunctions(target);

                            int oldIndex = ResolveFuntionIndex(functions, componentTypeProperty.stringValue, componentMethodProperty.stringValue);
                            int newIndex = EditorGUILayout.Popup(oldIndex, functions.names);
                            if (oldIndex != newIndex)
                            {
                                if (newIndex >= 2)
                                {
                                    var typeName = functions.componentTypes[newIndex - 2].AssemblyQualifiedName;
                                    var methodName = functions.componentMethods[newIndex - 2].Name;

                                    componentTypeProperty.stringValue = typeName;
                                    componentMethodProperty.stringValue = methodName;
                                    nameProperty.stringValue = StringUtils.ToDisplayName(methodName);
                                }
                                else
                                {
                                    componentTypeProperty.stringValue = null;
                                    componentMethodProperty.stringValue = null;
                                    nameProperty.stringValue = "";
                                }
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();

                    if (Event.current.type == EventType.MouseDown)
                    {
                        if (selectedRect.Contains(Event.current.mousePosition))
                        {
                            m_selectedIndex = i;
                            Repaint();
                        }
                    }

                    selectedRect.y += selectedRect.height;
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                m_actionsCountProperty.intValue++;
            }
            if (GUILayout.Button("Remove"))
            {
                if (m_selectedIndex >= 0 && m_selectedIndex < m_actionsCountProperty.intValue)
                {
                    m_actionsPropertry.DeleteArrayElementAtIndex(m_selectedIndex);
                }
            }
            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            Rigidbody rb = rbLimitations.GetComponent <Rigidbody>();

            if (rb == null || !rb.isKinematic)
            {
                EditorGUILayout.HelpBox("Rigidbody Limitations should be used with a Kinematic Rigidbody", MessageType.Warning);
            }

            serializedObject.Update();

            Vector3 minLimits = minLocalPositionProp.vector3Value;
            Vector3 maxLimits = maxLocalPositionProp.vector3Value;

            EditorGUILayout.BeginHorizontal();
            limitXProp.boolValue = EditorGUILayout.ToggleLeft("Limit Position X", limitXProp.boolValue, GUILayout.MinWidth(110));
            EditorGUI.BeginDisabledGroup(!limitXProp.boolValue);
            EditorGUILayout.LabelField("Min", GUILayout.Width(30));
            float minX = EditorGUILayout.FloatField(minLimits.x);

            EditorGUILayout.LabelField("Max", GUILayout.Width(30));
            float maxX = EditorGUILayout.FloatField(maxLimits.x);

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            limitYProp.boolValue = EditorGUILayout.ToggleLeft("Limit Position Y", limitYProp.boolValue, GUILayout.MinWidth(110));
            EditorGUI.BeginDisabledGroup(!limitYProp.boolValue);
            EditorGUILayout.LabelField("Min", GUILayout.Width(30));
            float minY = EditorGUILayout.FloatField(minLimits.y);

            EditorGUILayout.LabelField("Max", GUILayout.Width(30));
            float maxY = EditorGUILayout.FloatField(maxLimits.y);

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            limitZProp.boolValue = EditorGUILayout.ToggleLeft("Limit Position Z", limitZProp.boolValue, GUILayout.MinWidth(110));
            EditorGUI.BeginDisabledGroup(!limitZProp.boolValue);
            EditorGUILayout.LabelField("Min", GUILayout.Width(30));
            float minZ = EditorGUILayout.FloatField(minLimits.z);

            EditorGUILayout.LabelField("Max", GUILayout.Width(30));
            float maxZ = EditorGUILayout.FloatField(maxLimits.z);

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            minLocalPositionProp.vector3Value = new Vector3(minX, minY, minZ);
            maxLocalPositionProp.vector3Value = new Vector3(maxX, maxY, maxZ);

            EditorGUILayout.BeginHorizontal();
            limitAngleProp.boolValue = EditorGUILayout.ToggleLeft("Limit Angle", limitAngleProp.boolValue, GUILayout.MinWidth(110));
            EditorGUI.BeginDisabledGroup(!limitAngleProp.boolValue);
            EditorGUILayout.LabelField("Angle", GUILayout.Width(40));
            maxLocalAngleProp.floatValue = EditorGUILayout.FloatField(maxLocalAngleProp.floatValue, GUILayout.Width(40));
            EditorGUILayout.LabelField("Axis", GUILayout.Width(40));
            limitAxisProp.vector3Value = EditorGUILayout.Vector3Field("", limitAxisProp.vector3Value, GUILayout.MinWidth(110));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();


            int toBeRemovedEntry = -1;

            EditorGUILayout.Space();

            Vector2 removeButtonSize = GUIStyle.none.CalcSize(m_IconToolbarMinus);

            for (int i = 0; i < m_DelegatesProperty.arraySize; ++i)
            {
                SerializedProperty delegateProperty  = m_DelegatesProperty.GetArrayElementAtIndex(i);
                SerializedProperty eventProperty     = delegateProperty.FindPropertyRelative("eventID");
                SerializedProperty callbacksProperty = delegateProperty.FindPropertyRelative("callback");
                m_EventIDName.text = eventProperty.enumDisplayNames[eventProperty.enumValueIndex];

                EditorGUILayout.PropertyField(callbacksProperty, m_EventIDName);
                Rect callbackRect = GUILayoutUtility.GetLastRect();

                Rect removeButtonPos = new Rect(callbackRect.xMax - removeButtonSize.x - 8, callbackRect.y + 1, removeButtonSize.x, removeButtonSize.y);
                if (GUI.Button(removeButtonPos, m_IconToolbarMinus, GUIStyle.none))
                {
                    toBeRemovedEntry = i;
                }

                EditorGUILayout.Space();
            }

            if (toBeRemovedEntry > -1)
            {
                RemoveEntry(toBeRemovedEntry);
            }

            Rect        btPosition    = GUILayoutUtility.GetRect(m_AddButonContent, GUI.skin.button);
            const float addButonWidth = 200f;

            btPosition.x     = btPosition.x + (btPosition.width - addButonWidth) / 2;
            btPosition.width = addButonWidth;
            if (GUI.Button(btPosition, m_AddButonContent))
            {
                ShowAddTriggermenu();
            }

            if (!Application.isPlaying)
            {
                RigidbodyLimitations rbLim = (RigidbodyLimitations)target;
                basePositionProp.vector3Value = rbLim.transform.localPosition;
            }
            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        ///     Draws the installed readouts panel.
        /// </summary>
        private void DrawInstalledReadouts()
        {
            GUI.skin = HighLogic.Skin;
            this.scrollPositionInstalled = GUILayout.BeginScrollView(this.scrollPositionInstalled, false, true);

            GUI.skin = null;

            GUILayout.Label("INSTALLED", this.panelTitleStyle);
            var removeReadout      = false;
            var removeReadoutIndex = 0;

            for (var i = 0; i < this.ParentSection.ReadoutModules.Count; i++)
            {
                var readout = this.ParentSection.ReadoutModules[i];

                GUILayout.BeginHorizontal(GUILayout.Height(30.0f));
                GUILayout.Label(readout.Name, this.readoutNameStyle);

                if (GUILayout.Button("▲", this.readoutButtonStyle, GUILayout.Width(30.0f)))
                {
                    if (i > 0)
                    {
                        this.ParentSection.ReadoutModules[i]     = this.ParentSection.ReadoutModules[i - 1];
                        this.ParentSection.ReadoutModules[i - 1] = readout;
                    }
                }

                if (GUILayout.Button("▼", this.readoutButtonStyle, GUILayout.Width(30.0f)))
                {
                    if (i < this.ParentSection.ReadoutModules.Count - 1)
                    {
                        this.ParentSection.ReadoutModules[i]     = this.ParentSection.ReadoutModules[i + 1];
                        this.ParentSection.ReadoutModules[i + 1] = readout;
                    }
                }

                Color temp = GUI.color;

                GUI.color = readout.ValueStyle.normal.textColor;

                if (readout.Cloneable == false)
                {
                    if (GUILayout.Button(swatch, this.readoutButtonStyle, GUILayout.Width(30.0f)))
                    {
                        editingReadout      = readout;
                        colorPicker.enabled = true;
                    }

                    if (Event.current.type == EventType.Repaint && editingReadout == readout)
                    {
                        colorPicker.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position).Translate(new Rect(8, scrollRectInstalled.y - scrollPositionInstalled.y, 8, 8)), new Rect(0, 0, 180, 20));
                    }
                }
                else     //dont show for separators.
                {
                    GUILayout.Label("", GUILayout.Width(26.0f));
                }


                GUI.color = temp;

                readout.ShowHelp = GUILayout.Toggle(readout.ShowHelp, "?", this.readoutButtonStyle, GUILayout.Width(30.0f));

                if (GUILayout.Button("REMOVE", this.readoutButtonStyle, GUILayout.Width(75.0f)))
                {
                    removeReadout      = true;
                    removeReadoutIndex = i;
                }
                GUILayout.EndHorizontal();

                this.ShowHelpMessage(readout);
            }

            GUILayout.EndScrollView();

            if (Event.current.type == EventType.Repaint)
            {
                scrollRectInstalled = GUILayoutUtility.GetLastRect();
            }

            if (removeReadout)
            {
                this.ParentSection.ReadoutModules.RemoveAt(removeReadoutIndex);
            }
        }
Exemple #5
0
        public override void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            GameViewSize other = base.m_Object as GameViewSize;

            if (other == null)
            {
                Debug.LogError("Invalid object");
            }
            else
            {
                if (this.m_GameViewSize == null)
                {
                    this.m_GameViewSize = new GameViewSize(other);
                }
                bool flag = (this.m_GameViewSize.width > 0) && (this.m_GameViewSize.height > 0);
                GUILayout.Space(3f);
                GUILayout.Label((base.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add) ? s_Styles.headerEdit : s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]);
                FlexibleMenu.DrawRect(GUILayoutUtility.GetRect((float)1f, (float)1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                GUILayout.Space(4f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.optionalText, options);
                GUILayout.Space(10f);
                this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.typeName, optionArray2);
                GUILayout.Space(10f);
                this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, s_Styles.typeNames, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.widthHeightText, optionArray3);
                GUILayout.Space(10f);
                this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                float pixels    = 10f;
                float cropWidth = rect.width - (2f * pixels);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(pixels);
                GUILayout.FlexibleSpace();
                string displayText = this.m_GameViewSize.displayText;
                using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(displayText)))
                {
                    if (string.IsNullOrEmpty(displayText))
                    {
                        displayText = "Result";
                    }
                    else
                    {
                        displayText = this.GetCroppedText(displayText, cropWidth, EditorStyles.label);
                    }
                    GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label, new GUILayoutOption[0]);
                }
                GUILayout.FlexibleSpace();
                GUILayout.Space(pixels);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(10f);
                if (GUILayout.Button(s_Styles.cancel, new GUILayoutOption[0]))
                {
                    base.editorWindow.Close();
                }
                using (new EditorGUI.DisabledScope(!flag))
                {
                    if (GUILayout.Button(s_Styles.ok, new GUILayoutOption[0]))
                    {
                        other.Set(this.m_GameViewSize);
                        base.Accepted();
                        base.editorWindow.Close();
                    }
                }
                GUILayout.Space(10f);
                GUILayout.EndHorizontal();
            }
        }
Exemple #6
0
        /// <summary>
        /// Override method to show custom editor
        /// </summary>
        public override void OnInspectorGUI()
        {
            // Data object of Unity component
            serializedObject.Update();
            var networkModelConfiguration = target as NetworkModelConfiguration;

            // Ensure no NetworkModelConfiguration in parent
            Transform pointer = networkModelConfiguration.transform;

            while (pointer.parent != null)
            {
                pointer = pointer.parent;
                if (pointer.GetComponent <NetworkModelConfiguration>() != null)
                {
                    EditorGUILayout.HelpBox("Another NetworkModelConfiguration found in parent GameObject. Therefore, this component is disabled.", MessageType.Error);
                    networkModelConfiguration.enabled = false;
                }
            }

            // Ensure a NetworkModel Rule is attached to GameObject as well
            if (networkModelConfiguration.GetComponent <NetworkModelRule>() == null)
            {
                networkModelConfiguration.gameObject.AddComponent <NetworkModelRule>();
            }

            // Hover text for Help
            string serverIP      = "Specify the IP address of the server.";
            string serverPort    = "Specify the port of the server.";
            string reconnectTime = "Minimum time in seconds before next reconnect attempt. Will never be faster than the time between updates.";
            string updateDelay   = "Minimum time in seconds between two updates.";

            string compareTime       = "If checked, every update must contain a more recent timestamp than the last update.";
            string allowSend         = "If checked, the network model will send updates to the server.";
            string allowReceive      = "If checked, the network model will receive updates from the server.";
            string existingObjects   = "Attempt to find existing GameObjects of the correct name before creating new ones. Names of GameObject descendants of NetworkModel must be unique when using this option.";
            string existingResources = "Attempt to find existing Resources of the correct name and type in \"/Resources/NetworkModel\" before creating new ones. Names of Resources in the folder must be unique when using this option.";

            string sendChannel    = "List of channels on which to broadcast changes, seperated by \",\".";
            string receiveChannel = "List of channels from which to receive changes, separated by \",\".";

            string enableText  = "Enable/Disable Resource";
            string sendText    = "Enable/Disable Sending Resource";
            string receiveText = "Enable/Disable Receiving Resource";

            string debugLevel   = "Show all debug messages with regard to specified log level.";
            string debugSend    = "Debug messages sent to the server.";
            string debugReceive = "Debug messages received from server.";

            // Set GUILayout mode
            GUILayout.FlexibleSpace();

            // Textures
            Texture2D textureDark = new Texture2D(1, 1);

            textureDark.SetPixels(new Color[] { new Color(.6f, .6f, .6f) });
            textureDark.Apply();

            Texture2D textureLight = new Texture2D(1, 1);

            textureLight.SetPixels(new Color[] { new Color(.8f, .8f, .8f) });
            textureLight.Apply();

            // GUIStyles
            GUIStyle foldout = EditorStyles.foldoutHeader;

            foldout.fontStyle = FontStyle.Bold;

            GUIStyle header = new GUIStyle();

            header.normal.background = textureDark;

            GUIStyle empty = new GUIStyle();

            GUIStyle rowOdd  = new GUIStyle();
            GUIStyle rowEven = new GUIStyle();

            rowEven.normal.background = textureLight;

            // Connection
            this.toggleGroupConnection = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupConnection, "Connection", foldout);
            if (this.toggleGroupConnection)
            {
                EditorGUI.indentLevel++;

                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.TextField(new GUIContent("Server IP", serverIP), networkModelConfiguration.IP, EditorStyles.label);
                    EditorGUILayout.IntField(new GUIContent("Server Port", serverPort), networkModelConfiguration.PORT, EditorStyles.label);
                }
                else
                {
                    networkModelConfiguration.IP   = EditorGUILayout.TextField(new GUIContent("Server IP", serverIP), networkModelConfiguration.IP);
                    networkModelConfiguration.PORT = EditorGUILayout.IntField(new GUIContent("Server Port", serverPort), networkModelConfiguration.PORT);
                }
                networkModelConfiguration.RECONNECT = EditorGUILayout.Slider(new GUIContent("Seconds to reconnect", reconnectTime), networkModelConfiguration.RECONNECT, 0.0f, 10.0f);
                networkModelConfiguration.DELAY     = EditorGUILayout.Slider(new GUIContent("Seconds bet. updates", updateDelay), networkModelConfiguration.DELAY, 0.0f, 1.0f);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space();

            // Caluclate Editor width
            var windowVisibleRect = GUILayoutUtility.GetLastRect();

            if (windowVisibleRect.width > 1)
            {
                this.currentWidth = windowVisibleRect.width;
            }

            // GUILayoutOptions
            GUILayoutOption[] optionsLeftField   = { GUILayout.MinWidth(70), GUILayout.Width((this.currentWidth * 0.45f) - 45) };
            GUILayoutOption[] optionsRightFields = { GUILayout.MaxWidth(65.0f), GUILayout.MinWidth(65.0f), GUILayout.Width(65.0f) };

            // Settings
            this.toggleGroupSettings = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupSettings, "Settings", foldout);
            if (this.toggleGroupSettings)
            {
                EditorGUI.indentLevel++;
                networkModelConfiguration.TIME              = EditorGUILayout.Toggle(new GUIContent("Compare timestamps", compareTime), networkModelConfiguration.TIME);
                networkModelConfiguration.SEND              = EditorGUILayout.Toggle(new GUIContent("Allow to send updates", allowSend), networkModelConfiguration.SEND);
                networkModelConfiguration.RECEIVE           = EditorGUILayout.Toggle(new GUIContent("Allow to receive updates", allowReceive), networkModelConfiguration.RECEIVE);
                networkModelConfiguration.EXISTINGOBJECTS   = EditorGUILayout.Toggle(new GUIContent("Use existing objects", existingObjects), networkModelConfiguration.EXISTINGOBJECTS);
                networkModelConfiguration.EXISTINGRESOURCES = EditorGUILayout.Toggle(new GUIContent("Use existing resources", existingResources), networkModelConfiguration.EXISTINGRESOURCES);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space();

            // Channel
            this.toggleGroupChannel = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupChannel, "Channel", foldout);
            if (this.toggleGroupChannel)
            {
                EditorGUI.indentLevel++;
                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.TextField(new GUIContent("Send on channels", sendChannel), networkModelConfiguration.SENDCHANNELS, EditorStyles.label);
                    EditorGUILayout.TextField(new GUIContent("Receive on channels", receiveChannel), networkModelConfiguration.RECEIVECHANNELS, EditorStyles.label);
                }
                else
                {
                    networkModelConfiguration.SENDCHANNELS    = EditorGUILayout.TextField(new GUIContent("Send on channels", sendChannel), networkModelConfiguration.SENDCHANNELS);
                    networkModelConfiguration.RECEIVECHANNELS = EditorGUILayout.TextField(new GUIContent("Receive on channels", receiveChannel), networkModelConfiguration.RECEIVECHANNELS);
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space();

            // Rules
            this.toggleGroupRules = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupRules, "Rules", foldout);
            if (this.toggleGroupRules)
            {
                EditorGUI.indentLevel++;

                // Rules Resources
                EditorGUILayout.BeginHorizontal(header);
                EditorGUILayout.LabelField(new GUIContent("Resources", "For which resources should updates be sent"), optionsLeftField);
                EditorGUILayout.LabelField("Send", optionsRightFields);
                EditorGUILayout.LabelField("Receive", optionsRightFields);
                EditorGUILayout.EndHorizontal();

                // Resource Material
                EditorGUILayout.BeginHorizontal(rowOdd);
                networkModelConfiguration.enableMaterial = EditorGUILayout.ToggleLeft(new GUIContent("Material", enableText),
                                                                                      networkModelConfiguration.enableMaterial, EditorStyles.label, optionsLeftField);
                EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableMaterial == false);
                networkModelConfiguration.sendMaterial    = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendMaterial, optionsRightFields);
                networkModelConfiguration.receiveMaterial = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveMaterial, optionsRightFields);
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();

                // Resource Mesh
                EditorGUILayout.BeginHorizontal(rowEven);
                networkModelConfiguration.enableMesh = EditorGUILayout.ToggleLeft(new GUIContent("Mesh", enableText),
                                                                                  networkModelConfiguration.enableMesh, EditorStyles.label, optionsLeftField);
                EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableMesh == false);
                networkModelConfiguration.sendMesh    = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendMesh, optionsRightFields);
                networkModelConfiguration.receiveMesh = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveMesh, optionsRightFields);
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();

                // Resource Texture2D
                EditorGUILayout.BeginHorizontal(rowOdd);
                networkModelConfiguration.enableTexture2D = EditorGUILayout.ToggleLeft(new GUIContent("Texture2D", enableText),
                                                                                       networkModelConfiguration.enableTexture2D, EditorStyles.label, optionsLeftField);
                EditorGUI.BeginDisabledGroup(networkModelConfiguration.enableTexture2D == false);
                networkModelConfiguration.sendTexture2D    = EditorGUILayout.ToggleLeft(new GUIContent("", sendText), networkModelConfiguration.sendTexture2D, optionsRightFields);
                networkModelConfiguration.receiveTexture2D = EditorGUILayout.ToggleLeft(new GUIContent("", receiveText), networkModelConfiguration.receiveTexture2D, optionsRightFields);
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space();

            // Debugging
            this.toggleGroupDebugging = EditorGUILayout.BeginFoldoutHeaderGroup(this.toggleGroupDebugging, "Debugging", foldout);
            if (this.toggleGroupDebugging)
            {
                EditorGUI.indentLevel++;
                networkModelConfiguration.DEBUGLEVEL = (LogType)EditorGUILayout.EnumPopup(new GUIContent("Debug Level", debugLevel), networkModelConfiguration.DEBUGLEVEL);

                if (networkModelConfiguration.SEND)
                {
                    networkModelConfiguration.DEBUGSEND = EditorGUILayout.Toggle(new GUIContent("Log outgoing messages", debugSend), networkModelConfiguration.DEBUGSEND);
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Toggle(new GUIContent("Log outgoing messages", debugSend), networkModelConfiguration.DEBUGSEND);
                    EditorGUI.EndDisabledGroup();
                }

                if (networkModelConfiguration.RECEIVE)
                {
                    networkModelConfiguration.DEBUGRECEIVE = EditorGUILayout.Toggle(new GUIContent("Log incoming messages", debugReceive), networkModelConfiguration.DEBUGRECEIVE);
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Toggle(new GUIContent("Log incoming messages", debugReceive), networkModelConfiguration.DEBUGRECEIVE);
                    EditorGUI.EndDisabledGroup();
                }

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // Apply changes
            serializedObject.ApplyModifiedProperties();
        }
Exemple #7
0
        /// <summary> Make a field for a serialized property. Manual node port override. </summary>
        public static void PropertyField(SerializedProperty property, GUIContent label, XNode.NodePort port, bool includeChildren = true, params GUILayoutOption[] options)
        {
            if (property == null)
            {
                throw new NullReferenceException();
            }

            // If property is not a port, display a regular property field
            if (port == null)
            {
                EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
            }
            else
            {
                Rect rect = new Rect();

                // If property is an input, display a regular property field and put a port handle on the left side
                if (port.direction == XNode.NodePort.IO.Input)
                {
                    // Get data from [Input] attribute
                    XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
                    XNode.Node.InputAttribute   inputAttribute;
                    if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out inputAttribute))
                    {
                        showBacking = inputAttribute.backingValue;
                    }

                    switch (showBacking)
                    {
                    case XNode.Node.ShowBackingValue.Unconnected:
                        // Display a label if port is connected
                        if (port.IsConnected)
                        {
                            EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName));
                        }
                        // Display an editable property field if port is not connected
                        else
                        {
                            EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
                        }
                        break;

                    case XNode.Node.ShowBackingValue.Never:
                        // Display a label
                        EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName));
                        break;

                    case XNode.Node.ShowBackingValue.Always:
                        // Display an editable property field
                        EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
                        break;
                    }

                    rect          = GUILayoutUtility.GetLastRect();
                    rect.position = rect.position - new Vector2(16, 0);
                    // If property is an output, display a text label and put a port handle on the right side
                }
                else if (port.direction == XNode.NodePort.IO.Output)
                {
                    // Get data from [Output] attribute
                    XNode.Node.ShowBackingValue showBacking = XNode.Node.ShowBackingValue.Unconnected;
                    XNode.Node.OutputAttribute  outputAttribute;
                    if (NodeEditorUtilities.GetAttrib(port.node.GetType(), property.name, out outputAttribute))
                    {
                        showBacking = outputAttribute.backingValue;
                    }

                    switch (showBacking)
                    {
                    case XNode.Node.ShowBackingValue.Unconnected:
                        // Display a label if port is connected
                        if (port.IsConnected)
                        {
                            EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.styles.outputPort, GUILayout.MinWidth(30));
                        }
                        // Display an editable property field if port is not connected
                        else
                        {
                            EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
                        }
                        break;

                    case XNode.Node.ShowBackingValue.Never:
                        // Display a label
                        EditorGUILayout.LabelField(label != null ? label : new GUIContent(property.displayName), NodeEditorResources.styles.outputPort, GUILayout.MinWidth(30));
                        break;

                    case XNode.Node.ShowBackingValue.Always:
                        // Display an editable property field
                        EditorGUILayout.PropertyField(property, label, includeChildren, GUILayout.MinWidth(30));
                        break;
                    }

                    rect          = GUILayoutUtility.GetLastRect();
                    rect.position = rect.position + new Vector2(rect.width, 0);
                }

                rect.size = new Vector2(16, 16);

                Color backgroundColor = new Color32(90, 97, 105, 255);
                if (NodeEditorWindow.nodeTint.ContainsKey(port.node.GetType()))
                {
                    backgroundColor *= NodeEditorWindow.nodeTint[port.node.GetType()];
                }
                Color col = NodeGraphEditor.GetEditor(port.node.graph).GetTypeColor(port.ValueType);
                DrawPortHandle(rect, backgroundColor, col);

                // Register the handle position
                Vector2 portPos = rect.center;
                if (NodeEditor.portPositions.ContainsKey(port))
                {
                    NodeEditor.portPositions[port] = portPos;
                }
                else
                {
                    NodeEditor.portPositions.Add(port, portPos);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Sprite, Contents.spriteLabel);

            EditorGUILayout.PropertyField(m_Color, Contents.colorLabel, true);

            FlipToggles();

            Rect r = GUILayoutUtility.GetRect(
                EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW,
                EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight);

            EditorGUI.showMixedValue = m_Material.hasMultipleDifferentValues;
            Object currentMaterialRef  = m_Material.GetArrayElementAtIndex(0).objectReferenceValue;
            Object returnedMaterialRef = EditorGUI.ObjectField(r, Contents.materialLabel, currentMaterialRef, typeof(Material), false);

            if (returnedMaterialRef != currentMaterialRef)
            {
                m_Material.GetArrayElementAtIndex(0).objectReferenceValue = returnedMaterialRef;
            }
            EditorGUI.showMixedValue = false;

            EditorGUILayout.PropertyField(m_DrawMode, Contents.drawModeLabel);

            m_ShowDrawMode.target = ShouldShowDrawMode();
            if (EditorGUILayout.BeginFadeGroup(m_ShowDrawMode.faded))
            {
                string notFullRectWarning = GetSpriteNotFullRectWarning();
                if (notFullRectWarning != null)
                {
                    EditorGUILayout.HelpBox(notFullRectWarning, MessageType.Warning);
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(Contents.sizeLabel);
                EditorGUI.showMixedValue = m_Size.hasMultipleDifferentValues;
                FloatFieldLabelAbove(Contents.widthLabel, m_Size.FindPropertyRelative("x"));
                FloatFieldLabelAbove(Contents.heightLabel, m_Size.FindPropertyRelative("y"));
                EditorGUI.showMixedValue = false;
                EditorGUILayout.EndHorizontal();

                m_ShowTileMode.target = ShouldShowTileMode();
                if (EditorGUILayout.BeginFadeGroup(m_ShowTileMode.faded))
                {
                    EditorGUILayout.PropertyField(m_SpriteTileMode, Contents.fullTileLabel);

                    m_ShowAdaptiveThreshold.target = ShouldShowAdaptiveThreshold();
                    if (EditorGUILayout.BeginFadeGroup(m_ShowAdaptiveThreshold.faded))
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.Slider(m_AdaptiveModeThreshold, 0.0f, 1.0f, Contents.fullTileThresholdLabel);
                        EditorGUI.indentLevel--;
                    }
                    EditorGUILayout.EndFadeGroup();
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            RenderSortingLayerFields();

            EditorGUILayout.PropertyField(m_MaskInteraction, Contents.maskInteractionLabel);

            EditorGUILayout.PropertyField(m_SpriteSortPoint, Contents.spriteSortPointLabel);

            RenderRenderingLayer();

            CheckForErrors();

            serializedObject.ApplyModifiedProperties();
        }
Exemple #9
0
        private void DrawToolsMenu()
        {
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            //拖拽添加
            var aEvent   = Event.current;
            var dragArea = GUILayoutUtility.GetRect(100, 85);

            //在Inspector 窗口上创建区域,向区域拖拽资源对象,获取到拖拽到区域的对象
            GUI.Box(dragArea, "\n\n拖拽添加");

            switch (aEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dragArea.Contains(aEvent.mousePosition))
                {
                    break;
                }

                UnityEngine.Object temp = null;
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                if (aEvent.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();
                    Undo.RecordObject(target, "Drag Insert");
                    for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
                    {
                        temp = DragAndDrop.objectReferences[i];
                        if (temp == null)
                        {
                            break;
                        }

                        m_Target.CompCollectorInfos.Add(new CompCollector.CompCollectorInfo
                        {
                            Name = temp.name, Object = temp
                        });
                    }
                }

                Event.current.Use();
                break;

            default:
                break;
            }

            GUILayout.Space(10);
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            DrawHelperSelect();

            DrawCodeSelect();
            GUILayout.EndHorizontal();

            DrawBtnMenu();

            DrawSearchInput();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Exemple #10
0
 protected virtual Rect ComputeCompositeGUIRect(float frameWidth, float frameHeight)
 {
     return(GUILayoutUtility.GetRect(frameWidth, frameHeight));
 }
Exemple #11
0
        public override void OnInspectorGUI()
        {
            bool GUIEnabledValue = GUI.enabled;

            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                GUI.enabled = false;
            }

            if (m_Edited)
            {
                UpdateOrder(m_Edited);
                m_Edited = null;
            }

            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            {
                GUILayout.Label(Content.helpText, EditorStyles.helpBox);

                EditorGUILayout.Space();

                // Vertical that contains box and the toolbar below it
                Rect listRect = EditorGUILayout.BeginVertical();
                {
                    int        dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect);
                    MonoScript dropped     = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript;
                    if (dropped)
                    {
                        AddScriptToCustomOrder(dropped);
                    }

                    // Vertical that is used as a border around the scrollview
                    EditorGUILayout.BeginVertical(Styles.boxBackground);
                    {
                        // The scrollview itself
                        m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll);
                        {
                            // List
                            Rect r       = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true));
                            int  changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement);
                            if (changed >= 0)
                            {
                                // Give dragged item value in between neighbors
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                                // Update neighbors if needed
                                UpdateOrder(m_CustomTimeScripts[changed]);
                                // Neighbors may have been moved so there's more space around dragged item,
                                // so set order again to get possible rounding benefits
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                            }
                        } EditorGUILayout.EndScrollView();
                    } EditorGUILayout.EndVertical();

                    // The toolbar below the box
                    GUILayout.BeginHorizontal(Styles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        Rect       r2;
                        GUIContent content = Content.iconToolbarPlus;
                        r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown);
                        if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown))
                        {
                            ShowScriptPopup(r2);
                        }
                    } GUILayout.EndHorizontal();
                } GUILayout.EndVertical();

                ApplyRevertGUI();
            } GUILayout.EndVertical();

            GUI.enabled = GUIEnabledValue;
            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning);
            }

            GUILayout.FlexibleSpace();
        }
Exemple #12
0
    public override void OnInspectorGUI()
    {
        m_object.Update();
        DrawDefaultInspector();

        _2dxFX_Outline _2dxScript = (_2dxFX_Outline)target;

        Texture2D icon = Resources.Load("2dxfxinspector") as Texture2D;

        if (icon)
        {
            Rect  r;
            float ih     = icon.height;
            float iw     = icon.width;
            float result = ih / iw;
            float w      = Screen.width;
            result = result * w;
            r      = GUILayoutUtility.GetRect(ih, result);
            EditorGUI.DrawTextureTransparent(r, icon);
        }

        EditorGUILayout.PropertyField(m_object.FindProperty("ActiveUpdate"), new GUIContent("Active Update", "Active Update, for animation / Animator only")); EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call"));

        if (_2dxScript.ForceMaterial == null)
        {
            _2dxScript.ActiveChange = true;
        }
        else
        {
            if (GUILayout.Button("Remove Shared Material"))
            {
                _2dxScript.ForceMaterial = null;
                _2dxScript.ShaderChange  = 1;
                _2dxScript.ActiveChange  = true;
                _2dxScript.CallUpdate();
            }

            EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property"));
        }

        if (_2dxScript.ActiveChange)
        {
            EditorGUILayout.BeginVertical("Box");

            Texture2D icone = Resources.Load("2dxfx-icon-value") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_ColorX"), new GUIContent("Outline color", icone, "Change the color of the outline"));

            icone = Resources.Load("2dxfx-icon-value") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_OutLineSpread"), new GUIContent("Outline size", icone, "Change the size of the outline"));

            EditorGUILayout.BeginVertical("Box");

            icone = Resources.Load("2dxfx-icon-fade") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing"));

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();
        }

        m_object.ApplyModifiedProperties();
    }
Exemple #13
0
    void OnGUI()
    {
        {
            switch (step)
            {
            case 0:


                if (GUILayout.Button("New Skill", GUILayout.Height(40)))
                {
                    step = 1;
                }
                else if (GUILayout.Button("Delete/Edit Skill", GUILayout.Height(40)))
                {
                    step = 2;
                }

                break;

            case 1:
                // Creando una habilidad, definimos nombre, descripcion y tipo de daño que va a hacer
                skillName        = EditorGUILayout.TextField("Skill name", skillName);
                skillDescription = EditorGUILayout.TextField("Skill description", skillDescription);

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Type of skill");
                selectedSpellType = EditorGUILayout.Popup(selectedSpellType, spelltype);
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Skill cast type");
                selectedSkillType = EditorGUILayout.Popup(selectedSkillType, skillType);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Skill effect type");
                selectedEffect = EditorGUILayout.Popup(selectedEffect, skillEffect);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Type of damage");
                selectedSkillType1 = EditorGUILayout.Popup(selectedSkillType1, skillType1);
                GUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Damage:");
                damage = EditorGUILayout.IntField(damage);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Distance:");
                distance = EditorGUILayout.IntField(distance);
                EditorGUILayout.EndHorizontal();

                /*
                 * //Mostramos previsualización del rango de la habilidad.
                 * active = EditorGUILayout.Foldout(active, "Previsual");
                 * if (distance > 0 && active)
                 * {
                 *  EditorGUILayout.BeginHorizontal(GUILayout.Width(1));
                 *
                 *  for (int i = 0; i < distance + distance + 1; i++)
                 *  {
                 *      EditorGUILayout.BeginVertical(GUILayout.Width(1));
                 *      for (int j = 0; j < distance + distance + 1; j++)
                 *      {
                 *          if (i == distance && j == distance)
                 *          {
                 *              GUI.backgroundColor = Color.white;
                 *              GUILayout.Box("", GUILayout.Width(15), GUILayout.Height(15));
                 *          }
                 *          else
                 *          {
                 *              var box = new Vector2(i - distance, j - distance);
                 *              selectColor(activeBoxes.Contains(box));
                 *              GUILayout.Box("", GUILayout.Width(15), GUILayout.Height(15));
                 *          }
                 *      }
                 *      EditorGUILayout.EndVertical();
                 *  }
                 *  EditorGUILayout.EndHorizontal();
                 * }
                 * GUI.backgroundColor = Color.white;
                 */



                //Mostramos previsualización del rango de la habilidad.
                if (GUILayout.Button("Draw area range"))
                {
                    area = 1;
                }

                if (area > 0)
                {
                    //Mostramos previsualización del rango de la habilidad.
                    active = EditorGUILayout.Foldout(active, "Previsual");

                    if (distance > 0 && active)
                    {
                        EditorGUILayout.BeginHorizontal(GUILayout.Width(1));

                        for (int i = 0; i < distance + distance + 1; i++)
                        {
                            EditorGUILayout.BeginVertical(GUILayout.Width(1));
                            for (int j = 0; j < distance + distance + 1; j++)
                            {
                                if (i == distance && j == distance)
                                {
                                    GUI.backgroundColor = Color.white;
                                    GUILayout.Box("", GUILayout.Width(15), GUILayout.Height(15));
                                }
                                else
                                {
                                    var box = new Vector2(i - distance, j - distance);
                                    selectColor(activeBoxes.Contains(box));
                                    GUILayout.Box("", GUILayout.Width(15), GUILayout.Height(15));
                                }

                                if (Event.current.type == EventType.mouseDown &&
                                    Event.current.button == 0 &&
                                    GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                                {
                                    var box = new Vector2(i - distance, j - distance);
                                    if (activeBoxes.Contains(box))
                                    {
                                        activeBoxes.Remove(box);
                                    }
                                    else
                                    {
                                        activeBoxes.Add(box);
                                    }
                                    Repaint();
                                }
                            }
                            EditorGUILayout.EndVertical();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    GUI.backgroundColor = Color.white;
                }



                //requisitos para la habilidad
                activeRequirements = EditorGUILayout.Foldout(activeRequirements, "Requirements");

                if (activeRequirements)
                {
                    if (GUILayout.Button("Add Requirement"))
                    {
                        numberRequirements = numberRequirements + 1;
                    }

                    if (numberRequirements > 0)
                    {
                        for (int i = 0; i < numberRequirements; i++)
                        {
                            EditorGUILayout.BeginHorizontal();
                            selectedRequirement[i] = EditorGUILayout.Popup(selectedRequirement[i], requirements);
                            requisitos[i]          = EditorGUILayout.TextField(requisitos[i]);

                            SkillRequirement require = new SkillRequirement(selectedRequirement[i], requisitos[i]);


                            if (GUILayout.Button("X", GUILayout.Width(30), GUILayout.Height(30)))
                            {
                                //Ha pulsado borrar boton
                                skillRequirements.Remove(require);
                                numberRequirements--;
                            }

                            if (GUILayout.Button("Save", GUILayout.Width(50), GUILayout.Height(30)))
                            {
                                skillRequirements.Add(require);
                            }



                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }


                //fin de la creación de habilidad
                EditorGUILayout.BeginHorizontal("Box");
                if (GUILayout.Button("Cancel", GUILayout.Width(100), GUILayout.Height(50)))
                {
                    setDefaults();
                    step = 0;
                }
                else if (GUILayout.Button("Create Skill", GUILayout.Width(100), GUILayout.Height(50)))
                {
                    // Mensaje de salvado! -> aceptar -> step 1
                    saveSkill();
                    setDefaults();
                    step = 0;
                }


                break;


            //SELECCIONA EDITAR UNA HABILIDAD
            case 2:
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Name");
                EditorGUILayout.LabelField("Description");
                EditorGUILayout.LabelField("Type of skill");
                EditorGUILayout.LabelField("Skill cast type");
                EditorGUILayout.LabelField("Spell Effect");
                EditorGUILayout.LabelField("Damage");
                EditorGUILayout.LabelField("Distance");
                EditorGUILayout.EndHorizontal();

                Skill[] savedSkills = SkillsDB.Instance.getSavedSkills();
                selectedSkillTypes  = new int[savedSkills.Length];
                selectedCastTypes   = new int[savedSkills.Length];
                selectedSpellEffect = new int[savedSkills.Length];

                int[,] selectedRequirements       = new int[savedSkills.Length, MAX_REQUIREMENTS];
                string[,] descriptionRequirements = new string[savedSkills.Length, MAX_REQUIREMENTS];
                for (int i = 0; i < savedSkills.Length; i++)
                {
                    Skill skill = savedSkills[i];
                    EditorGUILayout.BeginHorizontal();
                    //el nombre no se puede modificar porque es la clave de la base de datos
                    EditorGUILayout.LabelField(skill.getName());

                    //changing the description
                    string skillDescription1 = EditorGUILayout.TextField(skill.getDescription());
                    skill.changeDescription(skillDescription1);

                    //changing type of skill type
                    selectedSkillTypes[i] = EditorGUILayout.Popup(skill.getTypeCast(), spelltype);
                    skill.changeTypeSkill(selectedSkillTypes[i]);

                    //changing casting character
                    selectedCastTypes[i] = EditorGUILayout.Popup(skill.getCastCharacter(), skillType);
                    skill.changeCastSkill(selectedCastTypes[i]);

                    //changing the spell effect:
                    selectedSpellEffect[i] = EditorGUILayout.Popup(skill.getSkillEffect(), skillEffect);
                    skill.changeSkillEffect(selectedSpellEffect[i]);


                    //changing amount of damage
                    int damage1 = EditorGUILayout.IntField(skill.getDamage());
                    skill.changeSkillDamage(damage1);
                    //changing distance
                    int distance1 = EditorGUILayout.IntField(skill.getDistance());
                    skill.changeDistance(distance1);



                    //requisitos para la habilidad
                    EditorGUILayout.BeginVertical();
                    activeRequirements = EditorGUILayout.Foldout(activeRequirements, "Requirements");


                    if (activeRequirements)
                    {
                        if (skill.numberRequirements() > 0)
                        {
                            for (int j = 0; j < skill.numberRequirements(); j++)
                            {
                                EditorGUILayout.BeginHorizontal();

                                selectedRequirements[i, j] = skill.getTypeRQ(j);
                                selectedRequirements[i, j] = EditorGUILayout.Popup(selectedRequirements[i, j], requirements);
                                skill.changeTypeRQ(selectedRequirements[i, j], j);

                                descriptionRequirements[i, j] = skill.getDescRQ(j);
                                descriptionRequirements[i, j] = EditorGUILayout.TextField(skill.getDescRQ(j));
                                skill.changeDescRQ(descriptionRequirements[i, j], j);

                                SkillRequirement require = new SkillRequirement(skill.getTypeRQ(j), skill.getDescRQ(j));

                                if (GUILayout.Button("X", GUILayout.Width(30), GUILayout.Height(30)))
                                {
                                    skill.removeRQ(require);
                                    numberRequirements--;
                                    SkillsDB.Instance.updateSkill(skill);
                                }

                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }


                    SkillsDB.Instance.updateSkill(skill);


                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button("X", GUILayout.Width(30), GUILayout.Height(30)))
                    {
                        //Ha pulsado borrar boton
                        this.skills.deleteSkill(skill);
                        SkillsDB.Instance.deleteSkill(skill);
                    }


                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal("Box");
                if (GUILayout.Button("Back to Menu", GUILayout.Width(100), GUILayout.Height(50)))
                {
                    setDefaults();
                    step = 0;
                }

                break;

            default:
                break;
            }
        }
    }
Exemple #14
0
        protected override void RenderContent()
        {
            RenderNameChangeField();
            RenderRadiusField();
            RenderMaxNumberOfObjectsField();
            RenderDistanceBetweenObjectsField();
            RenderIgnoreObjectsOutsideOfPaintSurfaceToggle();
            RenderDestinationCategoryForElementPrefabsSelectionPopup();

            EditorGUILayout.Separator();
            if (!_brush.IsEmpty)
            {
                Octave3DWorldBuilder.ActiveInstance.ShowGUIHint("Left click on an element's preview to change its parameters. Right click to remove the element from the brush. SHIFT + Right click to toggle the element on/off.");
            }
            Data.ElementsScrollPos = EditorGUILayout.BeginScrollView(Data.ElementsScrollPos, "Box", GUILayout.Height(Data.ElementsScrollViewHeight));
            if (_brush.IsEmpty)
            {
                EditorGUILayout.HelpBox("There are no brush elements available. You can drag and drop prefabs onto this area or " +
                                        "right click on prefabs inside the active category to create new elements. All brush elements will " +
                                        "be shown with a preview inside this area.", UnityEditor.MessageType.None);
            }
            else
            {
                List <DecorPaintObjectPlacementBrushElement> allBrushElements = _brush.GetAllBrushElements();
                for (int brushElemIndex = 0; brushElemIndex < allBrushElements.Count; ++brushElemIndex)
                {
                    if (brushElemIndex % Data.NumElementsPerRow == 0)
                    {
                        if (brushElemIndex != 0)
                        {
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUILayout.BeginHorizontal();
                    }

                    DecorPaintObjectPlacementBrushElement brushElement = allBrushElements[brushElemIndex];
                    var previewButtonRenderData = new PrefabPreviewButtonRenderData();
                    previewButtonRenderData.ExtractFromPrefab(brushElement.Prefab, Data.ElementPreviewScale);

                    Color previewTint = brushElement != _brush.ActiveElement ? Color.white : Data.ActiveElementTintColor;
                    if (_brush.ActiveElement != brushElement && !brushElement.IsEnabled)
                    {
                        previewTint = Data.DisabledElementTintColor;
                    }

                    EditorGUILayout.BeginVertical(GUILayout.Width(previewButtonRenderData.ButtonWidth));
                    EditorGUIColor.Push(previewTint);
                    if (EditorGUILayoutEx.PrefabPreview(brushElement.Prefab, true, previewButtonRenderData))
                    {
                        if (Event.current.button == (int)MouseButton.Left)
                        {
                            if (brushElement != _brush.ActiveElement)
                            {
                                UndoEx.RecordForToolAction(_brush);
                                _brush.SetActiveElement(brushElement);
                            }
                        }
                        else
                        if (Event.current.button == (int)MouseButton.Right)
                        {
                            if (!Event.current.shift)
                            {
                                UndoEx.RecordForToolAction(_brush);
                                _brush.RemoveAndDestroyElement(brushElement);
                            }
                            else
                            {
                                UndoEx.RecordForToolAction(brushElement);
                                brushElement.IsEnabled = !brushElement.IsEnabled;
                            }
                        }
                    }
                    EditorGUIColor.Pop();
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();
            Rect prefabDropRect = GUILayoutUtility.GetLastRect();

            EditorGUILayout.BeginHorizontal();
            var content = new GUIContent();

            content.text    = "Load active category";
            content.tooltip = "Loads all the prefabs from the active category inside the active brush. Note: Prefabs which already exist in the brush, will be ignored.";
            if (GUILayout.Button(content, GUILayout.Width(130.0f)))
            {
                UndoEx.RecordForToolAction(_brush);
                _brush.LoadAllPrefabsInActiveCategory();
            }
            RenderRemoveAllElementsButton();

            content.text    = "Look and feel...";
            content.tooltip = "Opens up a new window which allows you to control the look and feel of the brush elements view.";
            if (GUILayout.Button(content, GUILayout.Width(110.0f)))
            {
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.DecorPaintBrushViewLookAndFeelWindow.ViewData = Data;
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.DecorPaintBrushViewLookAndFeelWindow.ShowOctave3DWindow();
            }
            EditorGUILayout.EndHorizontal();

            if (_brush.ActiveElement != null)
            {
                EditorGUILayout.Separator();
                _brush.ActiveElement.View.Render();
            }

            PrefabsToDecorPaintBrushEventHandler.Get().DropDest         = PrefabsToDecorPaintBrushEventHandler.DropDestination.Brush;
            PrefabsToDecorPaintBrushEventHandler.Get().DestinationBrush = _brush;
            PrefabsToDecorPaintBrushEventHandler.Get().Handle(Event.current, prefabDropRect);
        }
Exemple #15
0
        public void Draw()
        {
            // Allow update for non-triggering changes (e.g., changing map view filters or changing a vessel's type)
            // This is the best way I could find to do periodic refreshes;
            //  RTCore.Instance.InvokeRepeating() would require a search for instances
            //  of AntennaFragment, and would keep running after all target windows
            //  closed. Replace with something less clunky later! -- Starstrider42
            if (++refreshCounter >= 100)
            {
                Refresh();
                refreshCounter = 0;
            }

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition);
            Color pushColor = GUI.backgroundColor;
            // starstriders changes
            //Color pushCtColor = GUI.contentColor;
            //Color pushBgColor = GUI.backgroundColor;
            TextAnchor pushAlign = GUI.skin.button.alignment;

            try {
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                // Depth-first tree traversal.
                Stack <Entry> dfs = new Stack <Entry>();
                foreach (Entry child in mRootEntry.SubEntries)
                {
                    dfs.Push(child);
                }

                // Set the inital mouseover to the selected entry
                mouseOverEntry = mSelection;

                while (dfs.Count > 0)
                {
                    Entry current = dfs.Pop();
                    GUI.backgroundColor = current.Color;

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24));
                        if (current.SubEntries.Count > 0)
                        {
                            RTUtil.Button(current.Expanded ? " <" : " >",
                                          () =>
                            {
                                current.Expanded = !current.Expanded;
                            }, GUILayout.Width(24));
                        }

                        RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1,
                                           (s) =>
                        {
                            mSelection     = current;
                            Antenna.Target = mSelection.Guid;
                        });

                        // Mouse is over the button
                        if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && triggerMouseOverListEntry)
                        {
                            // reset current entry
                            mouseOverEntry = null;
                            if (current.Text.ToLower() != Localizer.Format("#RT_ModuleUI_ActiveVessel_Tolower") && current.Text.ToLower() != Localizer.Format("#RT_ModuleUI_NoTarget_Tolower"))//"active vessel""no target"
                            {
                                mouseOverEntry = current;
                            }
                            onMouseOverListEntry.Invoke();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (current.Expanded)
                    {
                        foreach (Entry child in current.SubEntries)
                        {
                            dfs.Push(child);
                        }
                    }
                }
            } finally {
                GUILayout.EndScrollView();
                GUI.skin.button.alignment = pushAlign;
                GUI.backgroundColor       = pushColor;
            }
        }
Exemple #16
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty prop_BaseGlyphID          = property.FindPropertyRelative("m_BaseGlyphID");
            SerializedProperty prop_BaseGlyphAnchorPoint = property.FindPropertyRelative("m_BaseGlyphAnchorPoint");

            SerializedProperty prop_MarkGlyphID          = property.FindPropertyRelative("m_MarkGlyphID");
            SerializedProperty prop_MarkAdjustmentRecord = property.FindPropertyRelative("m_MarkPositionAdjustment");

            position.yMin += 2;

            float width   = position.width / 2;
            float padding = 5.0f;

            Rect rect;

            isEditingEnabled = GUI.enabled;
            isSelectable     = label.text == "Selectable" ? true : false;

            if (isSelectable)
            {
                GUILayoutUtility.GetRect(position.width, 75);
            }
            else
            {
                GUILayoutUtility.GetRect(position.width, 55);
            }

            GUIStyle style = new GUIStyle(EditorStyles.label)
            {
                richText = true
            };

            // Base Glyph
            GUI.enabled = isEditingEnabled;
            if (isSelectable)
            {
                float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_BaseGlyphID.intValue)).x;

                if (!isEditingEnabled)
                {
                    EditorGUI.LabelField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_BaseGlyphID.intValue + "</color>"), style);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUIUtility.labelWidth = 25f;
                    EditorGUI.DelayedIntField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64, 18), prop_BaseGlyphID, new GUIContent("ID:"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        FontAsset fontAsset = property.serializedObject.targetObject as FontAsset;
                        if (fontAsset != null)
                        {
                            property.serializedObject.ApplyModifiedProperties();
                            fontAsset.ReadFontAssetDefinition();
                            TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
                        }
                    }
                }

                GUI.enabled = isEditingEnabled;
                EditorGUIUtility.labelWidth = 30f;

                rect = new Rect(position.x + 70, position.y + 10, (width - 70) - padding, 18);
                EditorGUI.PropertyField(rect, prop_BaseGlyphAnchorPoint.FindPropertyRelative("m_XCoordinate"), new GUIContent("X:"));

                rect.y += 20;
                EditorGUI.PropertyField(rect, prop_BaseGlyphAnchorPoint.FindPropertyRelative("m_YCoordinate"), new GUIContent("Y:"));

                DrawGlyph((uint)prop_BaseGlyphID.intValue, new Rect(position.x, position.y, position.width, position.height), property);
            }

            // Mark Glyph
            GUI.enabled = isEditingEnabled;
            if (isSelectable)
            {
                float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_MarkGlyphID.intValue)).x;

                if (!isEditingEnabled)
                {
                    EditorGUI.LabelField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_MarkGlyphID.intValue + "</color>"), style);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUIUtility.labelWidth = 25f;
                    EditorGUI.DelayedIntField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64, 18), prop_MarkGlyphID, new GUIContent("ID:"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        FontAsset fontAsset = property.serializedObject.targetObject as FontAsset;
                        if (fontAsset != null)
                        {
                            property.serializedObject.ApplyModifiedProperties();
                            fontAsset.ReadFontAssetDefinition();
                            TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
                        }
                    }
                }

                GUI.enabled = isEditingEnabled;
                EditorGUIUtility.labelWidth = 30f;

                rect = new Rect(position.width / 2 + 20 + 70, position.y + 10, (width - 70) - padding, 18);
                EditorGUI.PropertyField(rect, prop_MarkAdjustmentRecord.FindPropertyRelative("m_XPositionAdjustment"), new GUIContent("X:"));

                rect.y += 20;
                EditorGUI.PropertyField(rect, prop_MarkAdjustmentRecord.FindPropertyRelative("m_YPositionAdjustment"), new GUIContent("Y:"));

                DrawGlyph((uint)prop_MarkGlyphID.intValue, new Rect(position.width / 2 + 20, position.y, position.width, position.height), property);
            }
        }
Exemple #17
0
        void OnGUI()
        {
            if (!initedStyle)
            {
                GUIStyle entryInfoTyle = "CN EntryInfo";
                textAreaStyle.richText         = true;
                textAreaStyle.normal.textColor = entryInfoTyle.normal.textColor;
                initedStyle = true;
            }


            string[]   statehints = new string[LuaState.statemap.Count];
            LuaState[] states     = new LuaState[LuaState.statemap.Count];
            int        n          = 0;

            foreach (var k in LuaState.statemap.Values)
            {
                states[n]       = k;
                statehints[n++] = k.Name;
            }

            stateIndex = EditorGUILayout.Popup(stateIndex, statehints);

            LuaState l = null;

            if (stateIndex >= 0 && stateIndex < states.Length)
            {
                l = states[stateIndex];
            }

            if (current != null && current != l)
            {
                current.logDelegate   -= AddLog;
                current.errorDelegate -= AddError;
            }

            if (current != l && l != null)
            {
                l.logDelegate   += AddLog;
                l.errorDelegate += AddError;
                current          = l;
            }



            //Output Text Area
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.ExpandHeight(true));
            EditorGUILayout.TextArea(outputText, textAreaStyle, GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();

            //Filter Option Toggles
            GUILayout.BeginHorizontal();
            bool oldToggleLog = toggleLog;
            bool oldToggleErr = toggleErr;

            toggleLog = GUILayout.Toggle(oldToggleLog, "log", GUILayout.ExpandWidth(false));
            toggleErr = GUILayout.Toggle(oldToggleErr, "error", GUILayout.ExpandWidth(false));

            //Filter Input Field
            GUILayout.Space(10f);
            GUILayout.Label("filter:", GUILayout.ExpandWidth(false));
            string oldFilterPattern = filterText;

            filterText = GUILayout.TextField(oldFilterPattern, GUILayout.Width(200f));

            //Menu Buttons
            if (GUILayout.Button("clear", GUILayout.ExpandWidth(false)))
            {
                recordList.Clear();
                ConsoleFlush();
            }
            GUILayout.EndHorizontal();

            if (toggleLog != oldToggleLog || toggleErr != oldToggleErr || filterText != oldFilterPattern)
            {
                ConsoleFlush();
            }

            if (Event.current.type == EventType.Repaint)
            {
                inputAreaPosY = GUILayoutUtility.GetLastRect().yMax;
            }

            //Drag Spliter
            ResizeScrollView();

            //Input Area
            GUI.SetNextControlName("Input");
            inputText = EditorGUILayout.TextField(inputText, GUILayout.Height(inputAreaHeight));

            if (Event.current.isKey && Event.current.type == EventType.KeyUp)
            {
                bool refresh = false;
                if (Event.current.keyCode == KeyCode.Return)
                {
                    if (inputText != "")
                    {
                        if (history.Count == 0 || history[history.Count - 1] != inputText)
                        {
                            history.Add(inputText);
                        }
                        AddLog(inputText);
                        DoCommand(inputText);
                        inputText    = "";
                        refresh      = true;
                        historyIndex = history.Count;
                    }
                }
                else if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    if (history.Count > 0)
                    {
                        historyIndex = historyIndex - 1;
                        if (historyIndex < 0)
                        {
                            historyIndex = 0;
                        }
                        else
                        {
                            inputText = history[historyIndex];
                            refresh   = true;
                        }
                    }
                }
                else if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    if (history.Count > 0)
                    {
                        historyIndex = historyIndex + 1;
                        if (historyIndex > history.Count - 1)
                        {
                            historyIndex = history.Count - 1;
                        }
                        else
                        {
                            inputText = history[historyIndex];
                            refresh   = true;
                        }
                    }
                }

                if (refresh)
                {
                    Repaint();
                    EditorGUIUtility.editingTextField = false;
                    GUI.FocusControl("Input");
                }
            }
        }
        public override void OnGUI(Rect position)
        {
            position = ApplySettingsPadding(position);
            Styles.Init();
            GUILayout.BeginArea(position);
            {
                GUILayout.Label(title, Styles.TitleStyle);

                EditorGUIUtility.labelWidth = 250;

                position.x = 0;
                position.y = 0;

                EditorGUILayout.Space();
            }
            GUILayout.EndArea();



            position = ApplySettingsPadding(position);

            GUILayout.BeginArea(position);
            {
                hasNotRatedFadePopup.target = !hasRated;

                GUILayout.Space(30);
                //Star Bar
                if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded))
                {
                    //GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndFadeGroup();


                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(Content.ratingPrompt, Styles.subHeadingStyle);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    //Rating selector is invisible
                    GlobalStyles.StartColorArea(Color.clear);
                    //Push ratings bar to middle
                    //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded))
                    {
                        GUILayout.FlexibleSpace();
                        //Ensure maximum middle-ness
                        EditorGUILayout.IntField(0, GUILayout.MaxWidth(EditorGUIUtility.fieldWidth));
                    }
                    //EditorGUILayout.EndFadeGroup();
                    //Rating selector
                    EditorGUI.BeginChangeCheck();
                    rating = EditorGUILayout.IntSlider(rating, 1, maxRating, GUILayout.MaxWidth(starSizeFull + EditorGUIUtility.fieldWidth));
                    if (EditorGUI.EndChangeCheck())
                    {
                        hasRated = true;
                    }

                    GlobalStyles.EndColorArea();



                    Rect lastRect = GUILayoutUtility.GetLastRect();

                    Rect filledStarRect = new Rect(lastRect.x, lastRect.y - (starSize / 8f),
                                                   starSizeFull / (maxRating / (float)rating), starSize);
                    Rect emptyStarRect = new Rect(filledStarRect.x + filledStarRect.width, filledStarRect.y,
                                                  starSizeFull - filledStarRect.width, starSize);
                    //Draw full stars
                    if (!hasRated)
                    {
                        GUI.DrawTextureWithTexCoords(
                            new Rect(filledStarRect.x, filledStarRect.y, starSizeFull, starSize),
                            Styles.starEmptyTex, new Rect(0, 0, maxRating, 1));
                    }
                    else if (rating < maxRating)
                    {
                        GlobalStyles.StartColorArea(new Color(0.2755f, 0.2755f, 0.2755f, 1));
                        GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1));
                        GlobalStyles.EndColorArea();
                    }
                    else
                    {
                        GlobalStyles.StartColorArea(new Color(1, 0.61f, 0, 1));
                        GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1));
                        GlobalStyles.EndColorArea();
                    }

                    if (hasRated)
                    {
                        //Draw empty stars
                        GlobalStyles.StartColorArea(EditorGUIUtility.isProSkin
                            ? Color.white
                            : new Color(0.2755f, 0.2755f, 0.2755f, 1));
                        GUI.DrawTextureWithTexCoords(emptyStarRect, Styles.starEmptyTex,
                                                     new Rect(0, 0, maxRating - rating, 1));
                        GlobalStyles.EndColorArea();
                    }
                }
                //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) {
                GUILayout.FlexibleSpace();
                //}
                //EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndHorizontal();

                hasRatedFadePopup.target = hasRated;
                if (EditorGUILayout.BeginFadeGroup(hasRatedFadePopup.faded))
                {
                    GUILayout.Space(5);

                    //Show the rating dialog if rating is full
                    fadeRatingPopup.target = rating == maxRating;
                    //Show the support dialog if rating is less than the support level
                    fadeSupportPopup.target = rating < supportRating && hasRated;

                    //Rating Dialog
                    if (EditorGUILayout.BeginFadeGroup(fadeRatingPopup.faded))
                    {
                        EditorGUILayout.LabelField(Content.ReviewText, Styles.feedbackLabelStyle);
                        GlobalStyles.LayoutExternalLink(Content.RatingLinkText, Content.RatingLink);
                    }
                    EditorGUILayout.EndFadeGroup();



                    //Support dialog
                    if (EditorGUILayout.BeginFadeGroup(fadeSupportPopup.faded))
                    {
                        EditorGUILayout.LabelField(Content.SupportText, Styles.feedbackLabelStyle);
                        GlobalStyles.LayoutExternalLink(Content.SupportLinkText, Content.s1WebsiteLink);
                    }
                    EditorGUILayout.EndFadeGroup();

                    //Feedback Email
                    //Feedback input box


                    GUI.enabled = !hasSubmitted;
                    {
                        float minHeight = EditorGUIUtility.singleLineHeight * 3;
                        //Expand the textbox if required
                        if ((rating == maxRating) && !String.IsNullOrEmpty(feedbackText))
                        {
                            int count = feedbackText.Split('\n').Length;
                            if (count > 3)
                            {
                                minHeight = count * EditorGUIUtility.singleLineHeight;
                            }
                        }
                        else if ((rating < maxRating) && !String.IsNullOrEmpty(feedbackText2))
                        {
                            int count = feedbackText2.Split('\n').Length;
                            if (count > 3)
                            {
                                minHeight = count * EditorGUIUtility.singleLineHeight;
                            }
                        }



                        if (!hasSubmitted)
                        {
                            if (rating < maxRating && hasRated)
                            {
                                feedbackText2 = EditorGUILayout.TextArea(feedbackText2, Styles.feedbackWindowStyle,
                                                                         GUILayout.MinHeight(minHeight));
                            }
                            else
                            {
                                feedbackText = EditorGUILayout.TextArea(feedbackText, Styles.feedbackWindowStyle,
                                                                        GUILayout.MinHeight(minHeight));
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(feedbackText, Styles.feedbackWindowStyle,
                                                       GUILayout.MinHeight(minHeight));
                        }



                        if (!hasSubmitted && GUILayout.Button(Content.SubmitFeedback))
                        {
                            if (rating < maxRating && hasRated)
                            {
                                feedbackText = feedbackText2;
                            }

                            hasSubmitted = true;
                            StringBuilder ratingAppendBuilder = new StringBuilder();
                            for (int i = 0; i < maxRating; i++)
                            {
                                if (i < rating)
                                {
                                    ratingAppendBuilder.Append('★');
                                }
                                else
                                {
                                    ratingAppendBuilder.Append('☆');
                                }
                            }

                            ratingAppendBuilder.Append('|').Append(String.Format(
                                                                       "{0}|{1}.{2}.{3} ", Application.unityVersion,
                                                                       GlobalPortalSettings.MAJOR_VERSION, GlobalPortalSettings.MINOR_VERSION,
                                                                       GlobalPortalSettings.PATCH_VERSION));
                            ratingAppendBuilder.Append('|').Append(SKSGlobalRenderSettings.Instance.ToString());
                            ratingAppendBuilder.Append('|').Append(GlobalPortalSettings.Instance.ToString());
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.deviceUniqueIdentifier));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.graphicsDeviceName));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.operatingSystem));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.processorType));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.systemMemorySize));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SystemInfo.graphicsMemorySize));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", Application.platform));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", EditorUserBuildSettings.activeBuildTarget));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", PlayerSettings.stereoRenderingPath));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", SetupUtility.projectMode.ToString()));
                            ratingAppendBuilder.Append('|')
                            .Append(String.Format("{0}", Application.systemLanguage));


                            String feedbackNext = feedbackText;
                            feedbackNext = feedbackNext.Replace(Environment.NewLine, " ");
                            feedbackNext = feedbackNext.Replace("\n", " ");
                            feedbackNext = feedbackNext.Replace("|", " ");
                            feedbackNext = feedbackNext + '|' + ratingAppendBuilder;
                            //Queue and send IRC message (wow such technology (I swear there is a reason we're doing it this way))
                            TcpClient socket = new TcpClient();
                            Int32     port   = 7000;
                            string    server = "irc.rizon.net";
                            String    chan   = "#SKSPortalKitFeedback";
                            socket.Connect(server, port);
                            StreamReader input  = new System.IO.StreamReader(socket.GetStream());
                            StreamWriter output = new System.IO.StreamWriter(socket.GetStream());
                            String       nick   = SystemInfo.deviceName;
                            output.Write(
                                "USER " + nick + " 0 * :" + "ChunkBuster" + "\r\n" +
                                "NICK " + nick + "\r\n"
                                );
                            output.Flush();
                            Thread sendMsgThread = new Thread(() => {
                                bool joined = false;
                                while (true)
                                {
                                    try
                                    {
                                        String buf = input.ReadLine();
                                        //Debug.Log(buf);
                                        if (buf == null)
                                        {
                                            //Debug.Log("Null");
                                            return;
                                        }

                                        //Send pong reply to any ping messages
                                        if (buf.StartsWith("PING "))
                                        {
                                            output.Write(buf.Replace("PING", "PONG") + "\r\n");
                                            output.Flush();
                                        }
                                        if (buf[0] != ':')
                                        {
                                            continue;
                                        }

                                        /* IRC commands come in one of these formats:
                                         * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n
                                         * :SERVER COMAND ARGS ... :DATA\r\n
                                         */

                                        //After server sends 001 command, we can set mode to bot and join a channel
                                        if (buf.Split(' ')[1] == "001")
                                        {
                                            output.Write(
                                                "MODE " + nick + " +B\r\n" +
                                                "JOIN " + chan + "\r\n"
                                                );
                                            output.Flush();
                                            joined = true;
                                            continue;
                                        }
                                        if (buf.Contains("End of /NAMES list"))
                                        {
                                            String[] outputText = feedbackNext.Split('\n');
                                            foreach (string s in outputText)
                                            {
                                                output.Write("PRIVMSG " + chan + " :" + s + "\r\n");
                                                output.Flush();
                                                Thread.Sleep(200);
                                            }

                                            socket.Close();
                                            return;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        //If this doesn't function perfectly then just dispose of it, not worth possibly causing issues with clients over network issues
                                        return;
                                    }
                                }
                            });
                            sendMsgThread.Start();
                        }
                        if (hasSubmitted)
                        {
                            GUILayout.Button(Content.SubmittedFeedback);
                        }
                    }
                    GUI.enabled = true;

                    GUILayout.Space(20);
                    //Content submission
                    GUILayout.Label(Content.GalleryText, Styles.subHeadingStyle);
                    GUILayout.Label(Content.GalleryResponseText, Styles.feedbackLabelStyle);
                    GlobalStyles.LayoutExternalLink(Content.GalleryLinkText, Content.GalleryLink);
                    GUILayout.FlexibleSpace();
                }
                else
                {
                    GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndFadeGroup();
                GUILayout.Label(Content.supportLabel, Styles.subHeadingStyle);
                GlobalStyles.LayoutExternalLink(Content.s1Text, Content.s1WebsiteLink);
                GlobalStyles.LayoutExternalLink(Content.s2Text, Content.s2WebsiteLink);
            }
            GUILayout.EndArea();
        }
        void Buttons()
        {
            bool wasGUIEnabled = GUI.enabled;

            GUI.enabled &= !EditorApplication.isPlayingOrWillChangePlaymode;

            if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
            {
                EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Warning);
            }

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            Rect rect = GUILayoutUtility.GetRect(Styles.ContinuousBakeLabel, GUIStyle.none);

            EditorGUI.BeginProperty(rect, Styles.ContinuousBakeLabel, m_WorkflowMode);

            bool iterative = m_WorkflowMode.intValue == (int)Lightmapping.GIWorkflowMode.Iterative;

            EditorGUI.BeginChangeCheck();
            iterative = GUILayout.Toggle(iterative, Styles.ContinuousBakeLabel);

            if (EditorGUI.EndChangeCheck())
            {
                m_WorkflowMode.intValue = (int)(iterative ? Lightmapping.GIWorkflowMode.Iterative : Lightmapping.GIWorkflowMode.OnDemand);
            }

            EditorGUI.EndProperty();

            using (new EditorGUI.DisabledScope(iterative))
            {
                // Bake button if we are not currently baking
                bool showBakeButton = iterative || !Lightmapping.isRunning;
                if (showBakeButton)
                {
                    if (EditorGUI.ButtonWithDropdownList(Styles.BuildLabel, s_BakeModeOptions, BakeDropDownCallback, GUILayout.Width(170)))
                    {
                        DoBake();

                        // DoBake could've spawned a save scene dialog. This breaks GUI on mac (Case 490388).
                        // We work around this with an ExitGUI here.
                        GUIUtility.ExitGUI();
                    }
                }
                // Cancel button if we are currently baking
                else
                {
                    // Only show Force Stop when using the PathTracer backend
                    if (LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.ProgressiveCPU &&
                        m_EnabledBakedGI.boolValue &&
                        GUILayout.Button("Force Stop", GUILayout.Width(kButtonWidth)))
                    {
                        Lightmapping.ForceStop();
                    }
                    if (GUILayout.Button("Cancel", GUILayout.Width(kButtonWidth)))
                    {
                        Lightmapping.Cancel();
                        UsabilityAnalytics.Track("/LightMapper/Cancel");
                    }
                }
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUI.enabled = wasGUIEnabled;
        }
        void OnOverlayGUI(Object target, SceneView sceneView)
        {
            // Draw a preview of the captured texture from the planar reflection

            // Get the exposure texture used in this scene view
            if (!(RenderPipelineManager.currentPipeline is HDRenderPipeline hdrp))
            {
                return;
            }
            var hdCamera    = HDCamera.GetOrCreate(sceneView.camera);
            var exposureTex = hdrp.GetExposureTexture(hdCamera);

            var index = Array.IndexOf(m_TypedTargets, target);

            if (index == -1)
            {
                return;
            }
            var p = m_TypedTargets[index];

            if (p.texture == null)
            {
                return;
            }

            var previewWidth = k_PreviewHeight;
            var previewSize  = new Rect(previewWidth, k_PreviewHeight + EditorGUIUtility.singleLineHeight + 2, 0, 0);

            if (Event.current.type == EventType.Layout ||
                !firstDraw && Event.current.type == EventType.Repaint)
            {
                // Get and reserve rect
                //this can cause the following issue if calls on a repaint before a layout:
                //ArgumentException: Getting control 0's position in a group with only 0 controls when doing repaint
                var cameraRect = GUILayoutUtility.GetRect(previewSize.x, previewSize.y);
                firstDraw = false;

                // The aspect ratio of the capture texture may not be the aspect of the texture
                // So we need to stretch back the texture to the aspect used during the capture
                // to give users a non distorded preview of the capture.
                // Here we compute a centered rect that has the correct aspect for the texture preview.
                var c = new Rect(cameraRect);
                c.y += EditorGUIUtility.singleLineHeight + 2;
                if (p.renderData.aspect > 1)
                {
                    c.width  = k_PreviewHeight;
                    c.height = k_PreviewHeight / p.renderData.aspect;
                    c.y     += (k_PreviewHeight - c.height) * 0.5f;
                }
                else
                {
                    c.width  = k_PreviewHeight * p.renderData.aspect;
                    c.height = k_PreviewHeight;
                    c.x     += (k_PreviewHeight - c.width) * 0.5f;
                }

                // Setup the material to draw the quad with the exposure texture
                var material = GUITextureBlit2SRGBMaterial;
                material.SetTexture("_Exposure", exposureTex);
                Graphics.DrawTexture(c, p.texture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, material, -1);

                // We now display the FoV and aspect used during the capture of the planar reflection
                var fovRect = new Rect(cameraRect);
                fovRect.x     += 5;
                fovRect.y     += 2;
                fovRect.width -= 10;
                fovRect.height = EditorGUIUtility.singleLineHeight;
                var width = fovRect.width;
                fovRect.width = width * 0.5f;
                GUI.TextField(fovRect, $"F: {p.renderData.fieldOfView:F2}°");
                fovRect.x    += width * 0.5f;
                fovRect.width = width * 0.5f;
                GUI.TextField(fovRect, $"A: {p.renderData.aspect:F2}");
            }
        }
 /// <summary>
 ///     Draws the readoutCategories selection list.
 /// </summary>
 private void DrawCategorySelector()
 {
     this.categoryList.enabled = GUILayout.Toggle(this.categoryList.enabled, "▼ SELECTED CATEGORY: " + ReadoutCategory.Selected.ToString().ToUpper() + " ▼", this.categoryTitleButtonStyle);
     if (Event.current.type == EventType.Repaint)
     {
         this.categoryList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position), GUILayoutUtility.GetLastRect());
     }
 }
        private void DrawPreComponents()
        {
            if (nodeInfo.GetPrefab() == null)
            {
                return;
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Label("命名空间", GUILayout.Width(60));
                rule.nameSpace = GUILayout.TextField(rule.nameSpace);

                if (GUILayout.Button(new GUIContent("←", "快速解析"), EditorStyles.toolbarButton, GUILayout.Width(20)))
                {
                    GenCodeUtil.ChoiseAnReferenceMonobehiver(nodeInfo.GetPrefab(), component =>
                    {
                        if (component == null)
                        {
                            EditorApplication.Beep();
                        }
                        else
                        {
                            //从旧的脚本解析出
                            GenCodeUtil.AnalysisComponent(component, components, rule);
                        }
                    });
                }
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("BaseType:", GUILayout.Width(lableWidth));
                EditorGUI.BeginChangeCheck();
                rule.baseTypeIndex = EditorGUILayout.Popup(rule.baseTypeIndex, GenCodeUtil.supportBaseTypes);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateBindingAble();
                }
                if (GUILayout.Button(new GUIContent("update", "更新脚本控件信息"), EditorStyles.miniButton, GUILayout.Width(60)))
                {
                    var go = nodeInfo.GetPrefab();
                    GenCodeUtil.UpdateBindingScripts(go, components, rule);
                }
            }

            if (preComponentList != null)
            {
                preComponentList.DoLayoutList();
            }

            var addRect = GUILayoutUtility.GetRect(BridgeUI.Drawer.BridgeEditorUtility.currentViewWidth, EditorGUIUtility.singleLineHeight);

            if (addRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.DragUpdated)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject)
                            {
                                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                            }
                        }
                    }
                }
                else if (Event.current.type == EventType.DragPerform)
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        foreach (var item in DragAndDrop.objectReferences)
                        {
                            if (item is GameObject)
                            {
                                var obj    = item as GameObject;
                                var parent = PrefabUtility.GetCorrespondingObjectFromSource(obj);
                                if (parent)
                                {
                                    obj = parent as GameObject;
                                }
                                var c_item = new ComponentItem(obj);
                                c_item.components = GenCodeUtil.SortComponent(obj);
                                components.Add(c_item);
                            }
                            else if (item is ScriptableObject)
                            {
                                var c_item = new ComponentItem(item as ScriptableObject);
                                components.Add(c_item);
                            }
                        }
                        DragAndDrop.AcceptDrag();
                    }
                }
            }
        }
 /// <summary>
 ///     Draws the presetsList selection list.
 /// </summary>
 private void DrawPresetSelector()
 {
     this.presetList.enabled = GUILayout.Toggle(this.presetList.enabled, "▼ PRESETS ▼", this.categoryTitleButtonStyle, GUILayout.Width(150.0f));
     if (Event.current.type == EventType.Repaint)
     {
         this.presetList.SetPosition(GUILayoutUtility.GetLastRect().Translate(this.position), GUILayoutUtility.GetLastRect());
     }
 }
        private Rect PaintHead(Rect position, SerializedProperty property)
        {
            Rect  rectTest       = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.label);
            float availableWidth = rectTest.width;

            Rect rectSprite = new Rect(
                position.x,
                position.y,
                RECT_SPRITE.x,
                RECT_SPRITE.y
                );

            Rect rectColor = new Rect(
                rectSprite.x + availableWidth - RECT_COLOR.x,
                rectSprite.y,
                RECT_COLOR.x,
                RECT_COLOR.y
                );

            Rect rectUniqueName = new Rect(
                rectSprite.x + rectSprite.width + ELEM_PADDING,
                rectSprite.y,
                availableWidth - (rectSprite.width + ELEM_PADDING) - (rectColor.width + ELEM_PADDING),
                ELEM_HEIGHT
                );

            Rect rectTitle = new Rect(
                rectUniqueName.x,
                rectUniqueName.y + rectUniqueName.height + ELEM_PADDING,
                rectUniqueName.width,
                rectUniqueName.height
                );

            Rect rectDescription = new Rect(
                rectTitle.x,
                rectTitle.y + rectTitle.height + ELEM_PADDING,
                rectTitle.width,
                rectTitle.height
                );

            Rect rectShort = new Rect(
                rectDescription.x,
                rectDescription.y + rectDescription.height + ELEM_PADDING,
                rectDescription.width,
                rectDescription.height
                );

            EditorGUI.ObjectField(rectSprite, property.FindPropertyRelative(PROP_ICON), typeof(Sprite), GUIContent.none);

            SerializedProperty spColor = property.FindPropertyRelative(PROP_COLOR);

            #if UNITY_2018_1_OR_NEWER
            spColor.colorValue = EditorGUI.ColorField(rectColor, GUIContent.none, spColor.colorValue, false, false, false);
            #else
            spColor.colorValue = EditorGUI.ColorField(rectColor, GUIContent.none, spColor.colorValue, false, false, false, null);
            #endif

            SerializedProperty spUniqueName = property.FindPropertyRelative(PROP_UNIQUE_NAME);
            EditorGUI.PropertyField(rectUniqueName, spUniqueName, GC_NAME);
            spUniqueName.stringValue = ProcessName(spUniqueName.stringValue);

            EditorGUI.PropertyField(rectTitle, property.FindPropertyRelative(PROP_TITLE));
            EditorGUI.PropertyField(rectDescription, property.FindPropertyRelative(PROP_DESCR));
            EditorGUI.PropertyField(rectShort, property.FindPropertyRelative(PROP_SHORT));

            return(new Rect(position.x, position.y + rectSprite.height, availableWidth, 0f));
        }
        void DrawProfileInspectorGUI()
        {
            EditorGUILayout.Space();

            bool assetHasChanged = false;
            bool showCopy = m_Profile.objectReferenceValue != null;

            // The layout system sort of break alignement when mixing inspector fields with custom
            // layouted fields, do the layout manually instead
            int buttonWidth = showCopy ? 45 : 60;
            float indentOffset = EditorGUI.indentLevel * 15f;
            var lineRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height);
            var fieldRect = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - buttonWidth * (showCopy ? 2 : 1), lineRect.height);
            var buttonNewRect = new Rect(fieldRect.xMax, lineRect.y, buttonWidth, lineRect.height);
            var buttonCopyRect = new Rect(buttonNewRect.xMax, lineRect.y, buttonWidth, lineRect.height);

            EditorGUI.PrefixLabel(labelRect, m_ProfileLabel);

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                m_Profile.objectReferenceValue
                    = (PostProcessProfile)EditorGUI.ObjectField(
                        fieldRect, m_Profile.objectReferenceValue, typeof(PostProcessProfile), false);
                assetHasChanged = scope.changed;
            }

            if (GUI.Button(
                buttonNewRect,
                EditorUtilities.GetContent("New|Create a new profile."),
                showCopy ? EditorStyles.miniButtonLeft : EditorStyles.miniButton))
            {
                // By default, try to put assets in a folder next to the currently active
                // scene file. If the user isn't a scene, put them in root instead.
                var targetName = Target.name;
                var scene = Target.gameObject.scene;
                var asset = CreatePostProcessProfile(scene, targetName);
                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (showCopy && GUI.Button(
                buttonCopyRect,
                EditorUtilities.GetContent("Clone|Create a new profile and copy the content of the currently assigned profile."),
                EditorStyles.miniButtonRight))
            {
                // Duplicate the currently assigned profile and save it as a new profile
                var origin = (PostProcessProfile)m_Profile.objectReferenceValue;
                var path = AssetDatabase.GetAssetPath(origin);
                path = AssetDatabase.GenerateUniqueAssetPath(path);

                var asset = Instantiate(origin);
                asset.settings.Clear();
                AssetDatabase.CreateAsset(asset, path);

                foreach (var item in origin.settings)
                {
                    var itemCopy = Instantiate(item);
                    itemCopy.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
                    itemCopy.name = item.name;
                    asset.settings.Add(itemCopy);
                    AssetDatabase.AddObjectToAsset(itemCopy, asset);
                }

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (m_Profile.objectReferenceValue == null)
            {
                if (assetHasChanged && m_EffectList != null)
                    m_EffectList.Clear(); // Asset wasn't null before, do some cleanup

                EditorGUILayout.HelpBox(
                    "Assign an existing Post-process Profile by choosing an asset, or create a new one by "
                        + "clicking the \"New\" button.\nNew assets are automatically put in a folder next " 
                        + "to your scene file. If your scene hasn't been saved yet they will be created " 
                        + "at the root of the Assets folder.",
                    MessageType.Info);
            }
            else
            {
                if (assetHasChanged)
                    RefreshEffectListEditor((PostProcessProfile)m_Profile.objectReferenceValue);
                if (m_EffectList != null)
                    m_EffectList.OnGUI();
            }
        }
Exemple #26
0
        protected void OnGUI()
        {
            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale = Screen.width / 800f;
                    skin.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize = Mathf.RoundToInt(guiscale * 20);
                    skin.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);

                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope())
                        {
                            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                            if (options.isKeepShowing())
                            {
                                var text = GUIManager.Instance.Last;
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");
                            }
                            foreach (var i in order)
                            {
                                ConversationLine ono = options.getLine(i);
                                if (ConditionChecker.check(options.getLineConditions(i)) && GUILayout.Button(ono.getText()))
                                {
                                    OptionSelected(i);
                                }
                            }

                            if (doTimeOut)
                            {
                                if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                {
                                    OptionSelected(options.getChildCount() - 1);
                                }

                                var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                GUILayout.FlexibleSpace();
                                DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
Exemple #27
0
		private void DisplayAsset(HierarchyEntry entry)
		{
			Rect rect;
			using (new EditorGUILayout.HorizontalScope())
			{
				GUILayout.Space(16);
				rect = GUILayoutUtility.GetRect(new GUIContent(entry.Name), GUI.skin.label, GUILayout.ExpandWidth(true));
			}

			var selected = Selection.assetGUIDs.Contains(entry.AssetGuid) || entry == SelectedAssetEntry;

			// browse mode
			if (selectionCallback == null)
			{
				selected = Selection.assetGUIDs.Contains(entry.AssetGuid);
			}


			if (Event.current.type == EventType.Repaint)
			{
				if (scrollToSelected && selected)
				{
					scroll.y = rect.yMin - (position.height - 50) / 2;
					scrollToSelected = false;
				}
			}

			if (rect.Contains(Event.current.mousePosition))
			{
				// click & doubleclick
				if (selectionCallback != null)
				{
					if (Event.current.type == EventType.MouseDown && (enableSelectionOnClick || Event.current.clickCount > 1))
					{
						entry.FindAsset();
						selectionCallback(entry.Asset);
                        if (enableSelectionOnClick)
                        {
                            SelectedAssetEntry = entry;
                        }
                        if (Event.current.clickCount > 1)
                        {
                            Close();
                        }
                        Event.current.Use();
					}
				}
				// drag
				if (selectionCallback == null && Event.current.type == EventType.MouseDrag)
				{
					DragAndDrop.PrepareStartDrag();
					if (!selected)
					{
						entry.FindAsset();
						DragAndDrop.objectReferences = new[] {entry.Asset};
					}
					else
					{
						DragAndDrop.objectReferences = Selection.objects;
					}
					DragAndDrop.StartDrag("AssetPicker");
					Event.current.Use();
				}
				// prevent button from eating RMB
				if (Event.current.isMouse && Event.current.button != 0)
				{
					return;
				}
			}

			var style = selected ? selectedAssetStyle : assetStyle;
			if (GUI.RepeatButton(rect, entry.Name, style))
			{
				entry.FindAsset();

				// browse mode
				if (selectionCallback == null)
				{
					if (Event.current.control)
					{
						// todo: fix blinking
						// ctrl-click: add/remove to selection
						Selection.objects = selected
							? Selection.objects.Where(o => o != entry.Asset).ToArray()
							: Selection.objects.Concat(new[] {entry.Asset}).ToArray();
					}
					// todo: shift-click
					else if (!Event.current.shift)
					{
						// simple click - select asset
						SelectedAssetEntry = entry;
						OnAssetHover(false);
						Repaint();
					}
				}
				else
				{
					SelectedAssetEntry = entry;
				}
			}
		}
    public override void OnInspectorGUI()
    {
        m_object.Update();
        DrawDefaultInspector();

        _2dxFX_AL_Ice _2dxScript = (_2dxFX_AL_Ice)target;

        Texture2D icon = Resources.Load("2dxfxinspector-al") as Texture2D;

        if (icon)
        {
            Rect  r;
            float ih     = icon.height;
            float iw     = icon.width;
            float result = ih / iw;
            float w      = Screen.width;
            result = result * w;
            r      = GUILayoutUtility.GetRect(ih, result);
            EditorGUI.DrawTextureTransparent(r, icon);
        }
        EditorGUILayout.LabelField("Advanced Lightning may work on mobile high-end devices and may be slower than the Standard 2DxFX effects due to is lightning system. Use it only if you need it.", EditorStyles.helpBox);
        EditorGUILayout.PropertyField(m_object.FindProperty("AddShadow"), new GUIContent("Add Shadow", "Use a unique material, reduce drastically the use of draw call"));
        if (_2dxScript.AddShadow)
        {
            EditorGUILayout.PropertyField(m_object.FindProperty("ReceivedShadow"), new GUIContent("Received Shadow : No Transparency and Use Z Buffering instead of Sprite Order Layers", "Received Shadow, No Transparency and Use Z Buffering instead of Sprite Order Layers"));
            if (_2dxScript.ReceivedShadow)
            {
                EditorGUILayout.LabelField("Note 1: Blend Fusion work but without transparency\n", EditorStyles.helpBox);
            }
        }

        // Mode Blend
        string BlendMethode = "Normal";

        if (_2dxScript.BlendMode == 0)
        {
            BlendMethode = "Normal";
        }
        if (_2dxScript.BlendMode == 1)
        {
            BlendMethode = "Additive";
        }
        if (_2dxScript.BlendMode == 2)
        {
            BlendMethode = "Darken";
        }
        if (_2dxScript.BlendMode == 3)
        {
            BlendMethode = "Lighten";
        }
        if (_2dxScript.BlendMode == 4)
        {
            BlendMethode = "Linear Burn";
        }
        if (_2dxScript.BlendMode == 5)
        {
            BlendMethode = "Linear Dodge";
        }
        if (_2dxScript.BlendMode == 6)
        {
            BlendMethode = "Multiply";
        }
        if (_2dxScript.BlendMode == 7)
        {
            BlendMethode = "Soft Aditive";
        }
        if (_2dxScript.BlendMode == 8)
        {
            BlendMethode = "2x Multiplicative";
        }

        EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call"));

        if (_2dxScript.ForceMaterial == null)
        {
            _2dxScript.ActiveChange = true;
        }
        else
        {
            if (GUILayout.Button("Remove Shared Material"))
            {
                _2dxScript.ForceMaterial = null;
                _2dxScript.ShaderChange  = 1;
                _2dxScript.ActiveChange  = true;
                _2dxScript.CallUpdate();
            }

            EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property"));
        }

        if (_2dxScript.ActiveChange)
        {
            EditorGUILayout.BeginVertical("Box");



            Texture2D icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Value1"), new GUIContent("Ice Speed", icone, "Change the fire speed"));

            icone = Resources.Load("2dxfx-icon-brightness") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Value2"), new GUIContent("Ice Intensity", icone, "Change the fire light intensity"));



            EditorGUILayout.BeginVertical("Box");


            icone = Resources.Load("2dxfx-icon-fade") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing"));

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Change Blend Fusion = " + BlendMethode, EditorStyles.whiteLargeLabel);
            if (_2dxScript.ReceivedShadow)
            {
                EditorGUILayout.LabelField("Note: Blend Fusion is not working correctly with Received Shadow", EditorStyles.helpBox);
            }

            EditorGUILayout.BeginHorizontal("Box");

            if (GUILayout.Button("Normal", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 0;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Additive", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 1;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Darken", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 2;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Lighten", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 3;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Linear Burn", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 4;
                _2dxScript.CallUpdate();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal("Box");

            if (GUILayout.Button("Linear Dodge", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 5;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Multiply", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 6;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("Soft Aditive", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 7;
                _2dxScript.CallUpdate();
            }
            if (GUILayout.Button("2x Multiplicative", EditorStyles.toolbarButton))
            {
                _2dxScript.BlendMode = 8;
                _2dxScript.CallUpdate();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }

        m_object.ApplyModifiedProperties();
    }
        public static bool Draw(AudioBus node, bool isSelected)
        {
            if (noMargain == null)
            {
                noMargain        = new GUIStyle();
                noMargain.margin = new RectOffset(0, 0, 0, 0);
            }

            Rect area = EditorGUILayout.BeginHorizontal();

            if (isSelected)
            {
                GUI.DrawTexture(area, EditorResources.Background);
            }
            GUILayout.Space(EditorGUI.indentLevel * 16);
            bool folded = node.FoldedOut;

            Texture picture;

            if (folded || node.Children.Count == 0)
            {
                picture = HDRAudio.EditorResources.Minus;
            }
            else
            {
                picture = HDRAudio.EditorResources.Plus;
            }

            GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width));
            Rect foldRect = GUILayoutUtility.GetLastRect();

            if (Event.current.ClickedWithin(foldRect))
            {
                folded = !folded;
                Event.current.Use();
            }
            EditorGUILayout.EndHorizontal();

            Rect labelArea  = GUILayoutUtility.GetLastRect();
            Rect buttonArea = labelArea;
            Rect sliderArea = buttonArea;


            if (!node.IsRoot)
            {
                buttonArea.x      = buttonArea.x + 45 + EditorGUI.indentLevel * 16;
                buttonArea.width  = 20;
                buttonArea.height = 14;
                GUI.Label(buttonArea, EditorResources.Up, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneUp(node);
                    Event.current.Use();
                }
                buttonArea.y += 15;
                GUI.Label(buttonArea, EditorResources.Down, noMargain);
                if (Event.current.ClickedWithin(buttonArea))
                {
                    NodeWorker.MoveNodeOneDown(node);
                    Event.current.Use();
                }
            }
            labelArea.y += 6;
            labelArea.x += 80;
            EditorGUI.LabelField(labelArea, node.Name);
            GUI.enabled         = false;
            sliderArea.y       += 6;
            sliderArea.x        = labelArea.x + 100;
            sliderArea.height   = 16;
            sliderArea.width    = 180;
            node.CombinedVolume = EditorGUI.Slider(sliderArea, node.CombinedVolume, 0.0f, 1.0f);
            GUI.enabled         = true;

            return(folded);
        }
 public static Rect ReserveRect(GUIStyle style, params GUILayoutOption[] options)
 {
     GUILayout.Label(string.Empty, style, options);
     return(GUILayoutUtility.GetLastRect());
 }