public static void ExportMessageIcon()
        {
            var size = 16;

            var type = MessageType.Warning;

            var restoreSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(size, size));

            var icon = LudiqGUIUtility.GetHelpIcon(type);

            icon.filterMode = FilterMode.Point;
            var rt = RenderTexture.GetTemporary(icon.width, icon.height);

            rt.filterMode        = FilterMode.Point;
            RenderTexture.active = rt;
            Graphics.Blit(icon, rt);
            var readableIcon = new Texture2D(icon.width, icon.height);

            readableIcon.ReadPixels(new Rect(0, 0, icon.width, icon.height), 0, 0);
            readableIcon.Apply();
            RenderTexture.active = null;
            icon = readableIcon;

            File.WriteAllBytes($"{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), type.ToString())}@{size}x.png", icon.EncodeToPNG());

            EditorGUIUtility.SetIconSize(restoreSize);
        }
        protected override float GetHeight(float width, GUIContent label)
        {
            var height = LudiqGUIUtility.GetHelpBoxHeight(message, MessageType.Warning, width);

            height += EditorGUIUtility.standardVerticalSpacing;
            return(height);
        }
Example #3
0
        public Rect GetLayoutPosition(GUIContent label = null, float scrollbarTrigger = 14, RectOffset offset = null)
        {
            var width = LudiqGUIUtility.GetLayoutWidth(offset);

            LudiqGUIUtility.currentInspectorHasScrollbar = width < LudiqGUIUtility.currentInspectorWidth - scrollbarTrigger;

            return(LudiqGUIUtility.GetLayoutRect(GetCachedHeight(width, label, null), offset));
        }
 private static void OnUndoRedo()
 {
     if (PluginContainer.initialized)
     {
         LudiqGUIUtility.BeginNotActuallyOnGUI();
         onUndoRedo?.Invoke();
         LudiqGUIUtility.EndNotActuallyOnGUI();
     }
 }
 private static void OnHierarchyChange()
 {
     if (PluginContainer.initialized)
     {
         LudiqGUIUtility.BeginNotActuallyOnGUI();
         onHierarchyChange?.Invoke();
         LudiqGUIUtility.EndNotActuallyOnGUI();
     }
 }
Example #6
0
        private float GetBackgroundEmbedWarningHeight(float width)
        {
            var fixContent = new GUIContent("Fix");

            var fixButtonWidth = Styles.fixBackgroundEmbedButton.CalcSize(fixContent).x - (Styles.spaceBeforeButton / 2);
            var warningWidth   = width - fixButtonWidth - (Styles.spaceBeforeButton / 2);
            var warningHeight  = LudiqGUIUtility.GetHelpBoxHeight(BackgroundEmbedWarning, MessageType.Warning, warningWidth);

            return(warningHeight);
        }
Example #7
0
        public static GUIStyle ProcessLabelStyle(Metadata metadata, GUIStyle labelStyle)
        {
            if (labelStyle == null)
            {
                labelStyle = defaultLabelStyle.value ?? EditorStyles.label;
            }

            if (metadata.isPrefabDiff)
            {
                labelStyle = LudiqGUIUtility.BoldedStyle(labelStyle);
            }

            return(labelStyle);
        }
Example #8
0
        public void OnGUI(Rect position)
        {
            HandleResizing(position);

            if (Event.current.ShouldSkip(position))
            {
                return;
            }

            if (e.IsRepaint)
            {
                Styles.background.Draw(position, false, false, false, false);
            }

            LudiqGUIUtility.BeginScrollablePanel(position, width => GetHeight(position.height), out Rect sidebarScrolledPosition, ref scroll);

            var y = sidebarScrolledPosition.y;

            for (int i = 0; i < displayedPanels.Count; i++)
            {
                var panel  = displayedPanels[i];
                var isLast = i == displayedPanels.Count - 1;

                if (isLast)
                {
                    var remainingHeight = sidebarScrolledPosition.height - y - 1;
                    var minPanelHeight  = panel.content.minSize.y;
                    var heightOverride  = Mathf.Max(remainingHeight, minPanelHeight);
                    panel.OnGUI(sidebarScrolledPosition, ref y, heightOverride);
                }
                else
                {
                    panel.OnGUI(sidebarScrolledPosition, ref y);
                }

                if (e.IsRepaint)
                {
                    Styles.separator.Draw(sidebarScrolledPosition.VerticalSection(ref y, 1), false, false, false, false);
                }
            }

            LudiqGUIUtility.EndScrollablePanel();

            if (e.IsRepaint)
            {
                Styles.separator.Draw(new Rect(position.x, position.y, 1, position.height), false, false, false, false);
            }
        }
Example #9
0
        private void OnBackgroundEmbedWarningGUI(Rect position, ref float y)
        {
            var fixContent = new GUIContent("Fix");

            var fixButtonWidth = Styles.fixBackgroundEmbedButton.CalcSize(fixContent).x - (Styles.spaceBeforeButton / 2);
            var warningWidth   = position.width - fixButtonWidth - (Styles.spaceBeforeButton / 2);
            var warningHeight  = LudiqGUIUtility.GetHelpBoxHeight(BackgroundEmbedWarning, MessageType.Warning, warningWidth);

            var warningPosition = new Rect
                                  (
                position.x,
                y,
                warningWidth,
                warningHeight
                                  );

            var fixButtonPosition = new Rect
                                    (
                warningPosition.xMax + Styles.spaceBeforeButton,
                y,
                fixButtonWidth,
                warningHeight
                                    );

            EditorGUI.HelpBox(warningPosition, BackgroundEmbedWarning, MessageType.Warning);

            if (GUI.Button(fixButtonPosition, fixContent))
            {
                if (EditorUtility.DisplayDialog("Background Embed Graph", "A background embed graph has been detected on this nest. This may cause slowdowns on serialization operations and unfixable background warnings. Do you want to delete the embed graph?", "Delete", "Cancel"))
                {
                    metadata.RecordUndo();
                    embedGraphMetadata.value = null;
                }
            }

            y += warningPosition.height;
        }
Example #10
0
 protected float GetExceptionHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(exceptionMessage, MessageType.Error, width));
 }
Example #11
0
 private float GetComponentPrefabWarningHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(ComponentPrefabWarning, MessageType.Warning, width));
 }
Example #12
0
 private float GetNoGraphSelectedHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(NoGraphSelectedMessage, MessageType.Info, width));
 }
Example #13
0
 private float GetNoMultiEditHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(NoMultiEditMessage, MessageType.Info, width));
 }
Example #14
0
 public float GetHeight(float width)
 {
     return(LudiqGUIUtility.GetHelpBoxHeight(message, messageType, width));
 }
Example #15
0
 private static Rect ToWindowRect(Rect rect)
 {
     return(LudiqGUIUtility.Unclip(new Rect(0, 0, rect.width, rect.height)));
 }