Example #1
0
    public static bool CreatNecromancerWindow(ref Rect rect, string title)
    {
        Font oldFont = GUI.skin.label.font;

        GUI.skin.label.font = ServiceLocator.Instance.FontManager.Get("Necromancer");

        GUI.DrawTexture(MultiResolutions.Rectangle(0, 0, rect.width, rect.height), ServiceLocator.Instance.TextureManager.GetGUITexture("window"));
        GUIExtension.AddSpikes((int)((rect.width) * Screen.width), rect.height);
        GUIExtension.FancyTop((int)((/*this.initPosition.x + */ rect.width) * Screen.width));
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;

        Rect labelRect = new Rect(rect.x + rect.width * 0.1f, rect.y + 0.1f, rect.width * 0.8f, 0.04f);

        GUI.Label(MultiResolutions.Rectangle(labelRect), "<b>" + title + "</b>");

        GUILayout.BeginArea(MultiResolutions.Rectangle(new Rect(labelRect.x, labelRect.y + 0.045f, labelRect.width, 0.05f)));
        GUILayout.Label("", "Divider");
        GUILayout.EndArea();

        GUI.skin.label.font = oldFont;

        return(true);
        //return !GUI.Button(MultiResolutions.Rectangle(new Rect(
        //    rect.x + rect.width - rect.width * 0.08f,
        //    rect.y + 0.015f,
        //    rect.width * 0.03f,
        //    rect.height * 0.05f)), "<color=#FF0000FF><b>X</b></color>", "details");
    }
        public override void DrawFields(FieldInfo fieldInfo)
        {
            if (fieldInfo.Name == "anim")
            {
                GUIContent lable     = new GUIContent(fieldInfo.Name);
                float      tmpHeight = GUIExtension.GetHeight(fieldInfo.FieldType, lable);

                UnityObjectAsset oldObj       = (UnityObjectAsset)fieldInfo.GetValue(Target);
                ObjectDrawer     objectDrawer = ObjectDrawer.CreateEditor(oldObj);
                objectDrawer.OnGUI(EditorGUILayout.GetControlRect(true, tmpHeight), lable);
                if (GUILayout.Button("设置为动画时长"))
                {
                    AnimationClip clip = (AnimationClip)oldObj.GetObj();
                    if (clip != null)
                    {
                        ClipModel clipModel = Target as ClipModel;
                        clipModel.SetEnd(clipModel.StartTime + clip.length);
                    }
                }
            }
            else
            {
                base.DrawFields(fieldInfo);
            }
        }
Example #3
0
        private static void DrawAndApplyFileSize(string assetPath, Rect selection)
        {
            var isFile = File.Exists(assetPath);

            if (!isFile)
            {
                return;
            }

            long size = new FileInfo(assetPath).Length;

            string metric;

            if (size < 1000)
            {
                metric = $"{size} bytes";
            }
            else if (size >= 1000 && size < 1000000)
            {
                metric = $"{(float)size / 1024:0.00} KB";
            }
            else
            {
                metric = $"{(float)size / 1048576:0.00} MB";
            }

            GUIExtension.DrawLabelStyle(metric, selection, styleData.LabelStyle);
        }
        public override void OnGUI(Rect rect)
        {
            //Draw label
            if (!string.IsNullOrWhiteSpace(header.text))
            {
                EditorGUI.LabelField(rect, header.text.ToUpper(), style);

                //Move to new line and set following line height
                rect.y     += SingleLine + 1;
                rect.height = 1;
            }
            else
            {
                rect.y     += SingleLine / 2f + 1;
                rect.height = 1;
            }

            Color c = Color.gray;

            if (EditorGUIUtility.isProSkin)
            {
                c = style.normal.textColor;
            }

            //Draw spacer
            GUIExtension.CreateLineSpacer(EditorGUI.IndentedRect(rect), c, rect.height);
        }
Example #5
0
        private static void DrawAndApplyStyle(GameObject gameObj, StyleData style, Rect selection)
        {
            if (style.headerTag == string.Empty)
            {
                return;
            }
            if (gameObj.name.Contains(style.headerTag))
            {
                if (style.useCaseScenario == UseCase.ForEditorUseOnly && !gameObj.CompareTag(EditorTag))
                {
                    gameObj.tag = EditorTag;
                }

                var offsetRect = GUIExtension.CalculateRect(selection, style.leftOffset, style.rightOffset, style.backgroundHeight);
                displayHeight = offsetRect.height;

                EditorGUI.DrawRect(offsetRect, style.BackgroundColor);
                EditorGUI.LabelField(offsetRect, gameObj.name.Replace(style.headerTag, ""), style.TextStyle);

                if (style.iconType != Icon.None && selection.width > style.widthToShowIcons)
                {
                    GUIExtension.DrawIconStyle(style.iconType, selection, style.IconStyle);
                }
            }
        }
Example #6
0
        private static void DrawMembers
            (bool isInput, GraphEditor editor, Node node, Rect rect,
            SerializedObject serializedObject, IEnumerable <Socket> sockets)
        {
            rect = new Rect(rect);

            foreach (var socket in sockets)
            {
                var h          = EditorGUIUtility.singleLineHeight;
                var socketRect = new Rect(rect);
                if (isInput)
                {
                    socketRect.x -= SOCKET_RADIUS * 2 + SOCKET_PADDING;
                }
                else
                {
                    socketRect.x += socketRect.width + SOCKET_PADDING;
                }
                socketRect.width  = SOCKET_RADIUS * 2;
                socketRect.height = SOCKET_RADIUS * 2;
                socketRect.y     += (h - socketRect.height) / 2;
                SocketEditor.DrawSocket(editor, node, socket, socketRect);

                string name     = node.GetSocketDisplayName(socket);
                bool   editable = node.IsSocketEditable(socket);

                if (editable)
                {
                    rect.height = h;
                    var type  = node.GetSocketType(socket);
                    var value = node.GetSocketValue(socket);

                    var prop = serializedObject.FindProperty(socket.FieldName);
                    if (prop != null)
                    {
                        EditorGUI.PropertyField(rect, prop, GUIContent.none, true);
                    }
                    else if (type == null)
                    {
                        GUI.enabled = false;
                        EditorGUI.TextField(rect, GUIContent.none, "Unknown Type");
                        GUI.enabled = true;
                    }
                    else
                    {
                        value = GUIExtension.DrawField(rect, value, type, GUIContent.none, true);
                        node.SetSocketValue(socket, value);
                    }

                    rect.y += rect.height + LINE_PADDING;
                }
                else
                {
                    rect.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.LabelField(rect, name);
                    rect.y += rect.height + LINE_PADDING;
                }
            }
        }
        private void OnGUI()
        {
            EditorGUILayoutExtension.LinkFileLabelField("EditorGUILayoutExtension.cs", "Assets/Editor/Examples/Example_34_LinkField/EditorGUILayoutExtension.cs");
            EditorGUILayoutExtension.LinkUrlLabelField("UnityToolchainsTrick仓库", "https://github.com/XINCGer/UnityToolchainsTrick");

            GUIExtension.LinkFileLabelField(new Rect(200, 40, 120, 16), "EditorGUIExtension.cs", "Assets/Editor/Examples/Example_34_LinkField/EditorGUIExtension.cs");
            GUIExtension.LinkUrlLabelField(new Rect(200, 60, 150, 16), "UnityToolchainsTrick仓库", "https://github.com/XINCGer/UnityToolchainsTrick");
        }
Example #8
0
    //public string ComparedRandomToString(AStuff stuff, List<ObjectAttributeCompared> objectAttri)
    //{
    //	return
    //}

    public string ComparedDefinedToString(AStuff <TModuleType> stuff, List <ObjectAttributeCompared> objectAttri)
    {
        string result = "";
        int    i      = 0;

        if (stuff is AWeapon <TModuleType> )
        {
            result = "<b>Damage</b>: " + objectAttri[0].value + "-" + objectAttri[1].value +
                     "(" + GUIExtension.IfNegativeReturnRedIfPositiveReturnGreen(objectAttri[0].difference) + "-" +
                     GUIExtension.IfNegativeReturnRedIfPositiveReturnGreen(objectAttri[1].difference) + ")\n";

            i = 2;
        }

        return(result + ComparedToString(objectAttri, i));
    }
Example #9
0
    //void Update()
    //{
    //    //minimapTexture = RTImage(this.cameras.Cameras[(int)e_whichCamera.Minimap]);
    //    //minimapTexture = ReduceTextureAlpha(minimapTexture);
    //    //minimapTexture.

    //}
    #endregion
    #region Functions
    private void OnHoverText()
    {
        GUIExtension.OnHoverTextCenterWithMousePosition(base.rects[(int)e_rect.Zoom], base.rects[(int)e_rect.OnHoverRect],
                                                        "<color=#00FF00>" + MultiResolutions.Font(16) + base.ModuleManager.LanguageManager.GetText("Zoom") + "</size></color>", GUI.skin.box);

        GUIExtension.OnHoverTextCenterWithMousePosition(base.rects[(int)e_rect.Dezoom], base.rects[(int)e_rect.OnHoverRect],
                                                        "<color=#FF0000>" + MultiResolutions.Font(16) + base.ModuleManager.LanguageManager.GetText("Unzoom") + "</size></color>", GUI.skin.box);

        GUIExtension.OnHoverTextCenterWithMousePosition(base.rects[(int)e_rect.RotateLeft], base.rects[(int)e_rect.OnHoverRect],
                                                        "<color=#3333CC>" + MultiResolutions.Font(16) + base.ModuleManager.LanguageManager.GetText("Rotate left") + "</size></color>", GUI.skin.box);

        GUIExtension.OnHoverTextCenterWithMousePosition(base.rects[(int)e_rect.RotateRight], base.rects[(int)e_rect.OnHoverRect],
                                                        "<color=#3333CC>" + MultiResolutions.Font(16) + base.ModuleManager.LanguageManager.GetText("Rotate right") + "</size></color>", GUI.skin.box);

        GUIExtension.OnHoverTextCenterWithMousePosition(base.rects[(int)e_rect.MinimapButton], base.rects[(int)e_rect.OnHoverRect],
                                                        "<color=#FF0000>" + MultiResolutions.Font(16) + base.ModuleManager.LanguageManager.GetText("Disable minimap") + "</size></color>",
                                                        GUI.skin.box);
    }
Example #10
0
    public static void CreateNecromancerWindowWithTitle(string title, Rect rect, APlayer player, ref Rect initPosition)
    {
        Font oldFont = GUI.skin.label.font;

        GUI.skin.label.font = player.ServiceLocator.FontManager.Get("Necromancer");

        GUI.DrawTexture(MultiResolutions.Rectangle(0, 0, initPosition.width, initPosition.height), player.ServiceLocator.TextureManager.GetGUITexture("window"));
        GUIExtension.AddSpikes((int)((initPosition.width) * Screen.width), initPosition.height);
        GUIExtension.FancyTop((int)((/*this.initPosition.x + */ initPosition.width) * Screen.width));

        GUILayout.BeginArea(MultiResolutions.Rectangle(ref rect));
        GUILayout.Space(Screen.height * 0.1f);
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        GUILayout.Label("<b>" + player.LanguageManager.GetText(title) + "</b>");
        GUILayout.Label("", "Divider");
        GUILayout.EndArea();

        GUI.skin.label.font = oldFont;
    }
Example #11
0
        private static void DrawAndApplyStyles(Object obj, StyleData style, Rect selection)
        {
            if (style.folderOrFileName == string.Empty)
            {
                return;
            }
            if (obj.name == style.folderOrFileName)
            {
                var offsetRect = GUIExtension.CalculateRect(selection, 18, style.rightOffset, style.backgroundHeight);
                displayHeight = offsetRect.height;

                EditorGUI.DrawRect(offsetRect, style.BackgroundColor);
                EditorGUI.LabelField(offsetRect, obj.name, style.TextStyle);

                if (style.iconType != Icon.None && selection.width > style.widthToShowIcons)
                {
                    GUIExtension.DrawIconStyle(style.iconType, selection, style.IconStyle);
                }
            }
        }
Example #12
0
        private static float GetPropertyHeights
            (SerializedObject serializedObject, Node node,
            IEnumerable <Socket> sockets, GraphEditor editor)
        {
            float height = 0f;

            foreach (var socket in sockets)
            {
                var editable = node.GetSocketFlags(socket).IsEditable();
                var linked   = editor.Graph.Links.IsSocketLinkedTo(socket);

                if (editable && !linked)
                {
                    var type  = node.GetSocketType(socket);
                    var value = node.GetSocketValue(socket);

                    var prop = serializedObject.FindProperty(socket.FieldName);
                    if (prop != null)
                    {
                        height += EditorGUI.GetPropertyHeight(prop, GUIContent.none);
                    }
                    else if (type == null)
                    {
                        height += EditorGUIUtility.singleLineHeight;
                    }
                    else
                    {
                        height += GUIExtension.GetFieldHeight(value, type, GUIContent.none);
                    }

                    height += LINE_PADDING;
                }
                else
                {
                    height += EditorGUIUtility.singleLineHeight;
                    height += LINE_PADDING;
                }
            }

            return(height - LINE_PADDING);
        }
Example #13
0
    //public static void CreateAndRotateItemMesh(GameObject mesh, string prefabName, string title, Rect rect, float rotateSpeed)
    //{
    //    if (null == mesh)
    //        mesh = GameObjectExtension.CreateItemMesh(prefabName, 4, 1.3f);
    //        mesh.RotateItemMeshInGUI(rotateSpeed, title);
    //}
    //Ce que je veux, j'aimerai pouvoir avoir une fonction qui appele la création de l'objet si besoin et le rotate aussi
    //a l'endroit voulu
    public static void RotateItemMeshInGUI(this GameObject mesh, float rotateSpeed, string title, Rect rect)
    {
        GUI.Box(MultiResolutions.Rectangle(ref rect), "");
        if (GUI.RepeatButton(MultiResolutions.Rectangle(rect.x + rect.width - 0.02f, rect.y + (rect.height * 0.5f) - 0.02f, 0.02f, 0.04f), MultiResolutions.Font(16) + "<color=#00FF00FF>></color></size>"))
        {
            mesh.transform.Rotate(new Vector3(0, rotateSpeed, 0));
        }
        if (GUI.RepeatButton(MultiResolutions.Rectangle(rect.x, rect.y + (rect.height * 0.5f) - 0.02f, 0.02f, 0.04f), MultiResolutions.Font(16) + "<color=#00FF00FF><</color></size>"))
        {
            mesh.transform.Rotate(new Vector3(0, -rotateSpeed, 0));
        }

        GUIExtension.OnHoverText(MultiResolutions.Rectangle(rect.x + rect.width - 0.02f, rect.y + (rect.height * 0.5f) - 0.02f, 0.02f, 0.04f),
                                 MultiResolutions.Rectangle(-0.0275f, 0f, 0.07f, 0.032f), MultiResolutions.Font(16) + "<color=yellow>Rotate Right</color></size>");

        GUIExtension.OnHoverText(MultiResolutions.Rectangle(rect.x, rect.y + rect.height - 0.02f, 0.02f, 0.04f),
                                 MultiResolutions.Rectangle(-0.0275f, 0f, 0.07f, 0.032f), MultiResolutions.Font(16) + "<color=yellow>Rotate Left</color></size>");

        for (byte i = 0; i < 3; i++)
        {
            GUI.Box(MultiResolutions.Rectangle(rect.x, rect.y, rect.width, 0.035f), title);
        }
    }
Example #14
0
        private void OnGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            //¹¤¾ßÀ¸
            GUILayoutExtension.HorizontalGroup(() =>
            {
                string selMap = currSelAsset == null ? "Null" : currSelAsset.name;
                GUILayout.Label($"µ±Ç°ÅäÖÃ:{selMap}", bigLabel.value);

                if (currSelAsset != null)
                {
                    if (GUILayout.Button("±£´æÅäÖÃ", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                    {
                        SaveAsset(currSelAsset);
                    }
                }
            }, GUILayout.Height(50));

            if (currSelAsset != null)
            {
                GUILayoutExtension.ScrollView(ref ScrollPos, () =>
                {
                    GUILayoutExtension.HorizontalGroup(() =>
                    {
                        EditorGUILayout.Space(35);
                        //×Ö¶Î
                        foreach (var fieldInfo in fields.Keys)
                        {
                            ConfigValueAttribute attr = fields[fieldInfo];
                            Rect rect = GetFieldRect(fieldInfo);
                            EditorGUI.LabelField(rect, GUIHelper.TextContent(attr.Name, attr.Tooltip), bigLabel.value);
                        }
                    });

                    for (int i = 0; i < configs.Count; i++)
                    {
                        IConfig config = configs[i];
                        GUILayoutExtension.HorizontalGroup(() =>
                        {
                            GUI.color = Color.white;
                            if (IsInSel(config))
                            {
                                GUI.color = SelectColor;
                            }
                            MiscHelper.Btn("Ñ¡Ôñ", 35, 35, () =>
                            {
                                OnClickSelBtn(config);
                            });
                            foreach (var fieldInfo in fields.Keys)
                            {
                                object value = fieldInfo.GetValue(config);
                                //float height = GUIExtension.GetHeight(fieldInfo.FieldType, value, GUIHelper.TextContent(""));
                                object newValue = GUIExtension.DrawField(GetFieldRect(fieldInfo), value, GUIHelper.TextContent(""));
                                if (newValue == null || !newValue.Equals(value))
                                {
                                    CommandDispacter.Do(new ChangeValueCommand(config, fieldInfo, newValue));
                                }
                            }
                            GUI.color = Color.white;
                        });
                    }
                });
            }
            OnHandleEvent(Event.current);
        }
Example #15
0
        private Rect GetFieldRect(FieldInfo field)
        {
            float height = GUIExtension.GetHeight(field.FieldType, GUIHelper.TextContent(""));

            return(EditorGUILayout.GetControlRect(true, height));
        }
Example #16
0
    public override void OnGUIDrawWindow(int windowID)
    {
        GUI.skin.box.wordWrap = true;

        for (short i = 0; i < 3; i++)
        {
            GUI.Box(MultiResolutions.Rectangle(this.initPosition),
                    MultiResolutions.Font(20) + "<color=red><b>Caracteristic</b></color></size>");
        }

        this.isActive = GUIExtension.ExitButton(this.initPosition);

        for (short i = 0; i < (int)(e_playerCharacteristic.SIZE); i++)
        {
            GUI.Label(MultiResolutions.Rectangle(this.initPosition.x + 0.01f, this.initPosition.y + 0.1f + i * 0.05f, 0.10f, 0.05f),
                      MultiResolutions.Font(16) + (e_playerCharacteristic)(i) + "</size>");

            if (GUIExtension.CollideMousePositionWithRect(MultiResolutions.Rectangle(this.initPosition.x + 0.01f + this.dragPosition.x / Screen.width, initPosition.y + 0.1f + i * 0.05f + this.dragPosition.y / Screen.height, 0.10f, 0.05f)))
            {
                this.playerCharacteristics.Select(i);
            }

            float displayPoint = this.playerCharacteristics.Characteristics[i].TotalPoint;
            switch ((e_playerCharacteristic)(i))
            {
            case e_playerCharacteristic.Strength: displayPoint += base.ModuleManager.Attributes.attributes[(int)(e_entityAttribute.Strength)]; break;

            case e_playerCharacteristic.Resistance: displayPoint += base.ModuleManager.Attributes.attributes[(int)(e_entityAttribute.Resistance)]; break;

            case e_playerCharacteristic.Vitality: displayPoint += base.ModuleManager.Attributes.attributes[(int)(e_entityAttribute.Vitality)]; break;

            case e_playerCharacteristic.Energy: displayPoint += base.ModuleManager.Attributes.attributes[(int)(e_entityAttribute.Energy)]; break;

            default: break;
            }
            GUI.Label(MultiResolutions.Rectangle(this.initPosition.x + 0.09f, this.initPosition.y + 0.1f + i * 0.05f, 0.015f, 0.03f),
                      MultiResolutions.Font(16) + this.playerCharacteristics.Characteristics[i].Color +
                      displayPoint + "</color></size>");

            //A FIXE
            //if (this.playerAttribute.CharacteristicRemain > 0 &&
            //	GUI.Button(MultiResolutions.Rectangle(this.initPosition.x + 0.11f, this.initPosition.y + 0.1f + i * 0.05f, 0.015f, 0.03f),
            //	MultiResolutions.Font(16) + "<b><color=#00FF00FF>+</color></b></size>"))
            //	this.playerCharacteristics.SubstractCharacteristic(i);

            if (this.playerCharacteristics.Characteristics[i].PointLevel > 0 &&
                GUI.Button(MultiResolutions.Rectangle(this.initPosition.x + 0.127f, this.initPosition.y + 0.1f + i * 0.05f, 0.015f, 0.03f),
                           MultiResolutions.Font(16) + "<b><color=#FF0000FF>-</color></b></size>"))
            {
                this.playerCharacteristics.AddCharacteristic(i);
            }

            GUI.skin.box.alignment = TextAnchor.MiddleCenter;
            GUI.Box(MultiResolutions.Rectangle(this.initPosition.x, this.initPosition.y + (int)(e_playerCharacteristic.SIZE) * 0.05f + 0.188f, this.initPosition.width, 0.1f),
                    ((this.playerCharacteristics.Characteristics[i].Selected) ?
                     MultiResolutions.Font(15) + this.playerCharacteristics.Characteristics[i].Color + "<b>" +
                     this.playerCharacteristics.GetCharacteristicText((e_playerCharacteristic)i) + "</b></color></size>" : ""));
            GUI.skin.box.alignment = TextAnchor.UpperCenter;
        }

        //A FIXEGUI.Box(MultiResolutions.Rectangle(this.initPosition.x, this.initPosition.y + (int)(e_playerCharacteristic.SIZE) * 0.05f + 0.125f, this.initPosition.width, 0.05f),
        //A FIXE	MultiResolutions.Font(18) + "<b><color=red>Usable Point</color></b> : " + playerAttribute.CharacteristicRemain + "</size>");

        if (GUI.Button(MultiResolutions.Rectangle(this.initPosition.x, this.initPosition.y + (int)(e_playerCharacteristic.SIZE) * 0.05f + 0.125f + 0.075f + 0.1f, initPosition.width * 0.5f, 0.05f),
                       MultiResolutions.Font(16) + "<b><color=#00FF00FF>Apply</color></b></size>"))
        {
            this.playerCharacteristics.ApplyCharacteristic();
        }

        if (GUI.Button(MultiResolutions.Rectangle(this.initPosition.x + this.initPosition.width * 0.5f, this.initPosition.y + (int)(e_playerCharacteristic.SIZE) * 0.05f + 0.125f + 0.075f + 0.1f, this.initPosition.width * 0.5f, 0.05f),
                       MultiResolutions.Font(16) + "<b><color=#FF0000FF>Cancel</color></b></size>"))
        {
            this.playerCharacteristics.CancelCharacteristic();
        }
        //valider change les caracteristique qui faut et enlève

        GUI.DragWindow(new Rect(0, 0, 10000, 10000));
    }
Example #17
0
        private static void DrawMember
            (bool isInput, GraphEditor editor, Node node, ref Rect rect,
            SerializedObject serializedObject, Socket socket)
        {
            string name     = node.GetSocketDisplayName(socket);
            bool   editable = node.GetSocketFlags(socket).IsEditable();
            bool   linked   = editor.Graph.Links.IsSocketLinkedTo(socket);

            rect.height = EditorGUIUtility.singleLineHeight;

            XGUI.ResetToStyle(null);
            XGUI.Normal.textColor = GraphEditor.Skin.nodeTextColor;

            if (editor.search.IsOpen)
            {
                XGUI.Normal.textColor = GraphEditor.Skin.TintColor(
                    XGUI.Normal.textColor, GraphEditor.Skin.disabledNodeTextTint);
            }

            var clipboardHasValue = false;
            var hovering          = rect.Contains(Event.current.mousePosition) &&
                                    !editor.search.IsOpen;

            if (editable && !linked)
            {
                var type  = node.GetSocketType(socket);
                var value = node.GetSocketValue(socket);
                clipboardHasValue = editor.Clipboard.ContainsKey(type);

                // Check for clipboard operations
                if (hovering)
                {
                    switch (Event.current.type)
                    {
                    case EventType.MouseDown:
                        if (Event.current.shift)
                        {
                            if (Event.current.button == 0)
                            {
                                usedClipboard = true;
                                if (clipboardHasValue)
                                {
                                    value = editor.Clipboard[type];
                                    node.SetSocketValue(socket, value);
                                }
                            }
                            else if (Event.current.button == 1)
                            {
                                usedClipboard          = true;
                                editor.Clipboard[type] = value;
                            }

                            Event.current.Use();
                        }
                        break;

                    case EventType.MouseUp:
                        if (usedClipboard)
                        {
                            usedClipboard = false;
                            Event.current.Use();
                        }
                        break;
                    }
                }

                XGUI.Enabled = !editor.search.IsOpen;
                var prop = serializedObject.FindProperty(socket.FieldName);
                if (type == typeof(bool))
                {
                    value = XGUI.ToggleLeft(rect, name, (bool)value);
                    node.SetSocketValue(socket, value);
                }
                else if (prop != null)
                {
                    EditorGUI.PropertyField(rect, prop, GUIContent.none, true);
                }
                else if (type == null)
                {
                    XGUI.Enabled = false;
                    XGUI.TextField(rect, "Unknown Type");
                }
                else
                {
                    value = GUIExtension.DrawField
                                (rect, value, type, GUIContent.none, true);
                    node.SetSocketValue(socket, value);
                }
            }
            else
            {
                XGUI.Label(rect, name);
            }

            // Prepare a tooltip
            if (hovering && editor.Tooltip == null)
            {
                var text = string.Format(
                    "<color=#4aa><i>{0}</i></color> <b>{1}</b>\n{2}{3}{4}",
                    node.GetSocketType(socket).Name,
                    node.GetSocketDisplayName(socket),
                    string.IsNullOrEmpty(node.GetSocketDescription(socket))
                                                ? "<color=#aaa><i>No documentation</i></color>"
                                                : node.GetSocketDescription(socket),
                    (editable && !linked ? "\n<color=#777><i>Shift + Right click to copy</i></color>" : ""),
                    (clipboardHasValue ? "\n<color=#777><i>Shift + Left click to paste</i></color>" : "")
                    );
                editor.Tooltip = new Tooltip(text);
            }
        }
Example #18
0
 private static void AddLabel(string label, Rect selection)
 {
     GUIExtension.DrawLabelStyle(label, selection, styleData.LabelStyle);
 }
Example #19
0
        private static void DrawAndApplyExtensions(string assetPath, Rect selection)
        {
            string extension = Path.GetExtension(assetPath);

            GUIExtension.DrawLabelStyle(extension, selection, styleData.LabelStyle);
        }