示例#1
0
        void Init(Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            m_TargetObject   = targetObj;
            m_StartIcon      = EditorGUIUtility.GetIconForObject(m_TargetObject);
            m_ShowLabelIcons = showLabelIcons;
            Rect screenActivatorRect = GUIUtility.GUIToScreenRect(activatorRect);

            // Remove any keyboard control when opening this window
            GUIUtility.keyboardControl = 0;

            // Init GUIContents
            m_LabelLargeIcons        = GetTextures("sv_label_", "", 0, 8);
            m_LabelIcons             = GetTextures("sv_icon_name", "", 0, 8);
            m_SmallIcons             = GetTextures("sv_icon_dot", "_sml", 0, 16);
            m_LargeIcons             = GetTextures("sv_icon_dot", "_pix16_gizmo", 0, 16);
            m_NoneButtonContent      = EditorGUIUtility.IconContent("sv_icon_none");
            m_NoneButtonContent.text = "None";

            // Deal with window size
            float k_Width  = 140;
            float k_Height = 86;

            if (m_ShowLabelIcons)
            {
                k_Height = 126;
            }

            ShowAsDropDown(screenActivatorRect, new Vector2(k_Width, k_Height));
        }
示例#2
0
        void SetMultipleSelectedIcons()
        {
            m_MultipleSelectedIcons = false;
            Texture2D firstIcon = EditorGUIUtility.GetIconForObject(m_TargetObjectList[0]);

            foreach (var target in m_TargetObjectList)
            {
                Texture2D icon = EditorGUIUtility.GetIconForObject(target);
                if (icon != firstIcon)
                {
                    m_MultipleSelectedIcons = true;
                    break;
                }
            }
        }
示例#3
0
 private void SaveIconChanges()
 {
     if (EditorGUIUtility.GetIconForObject(this.m_TargetObject) != this.m_StartIcon)
     {
         MonoScript targetObject = this.m_TargetObject as MonoScript;
         if (targetObject != null)
         {
             if (this.m_MonoScriptIconChangedCallback != null)
             {
                 this.m_MonoScriptIconChangedCallback(targetObject);
             }
             else
             {
                 MonoImporter.CopyMonoScriptIconToImporters(targetObject);
             }
         }
     }
 }
示例#4
0
        internal static void CopyIconToImporter(MonoScript monoScript)
        {
            // update the icon on the importer (requires a reimport)
            var icon           = EditorGUIUtility.GetIconForObject(monoScript);
            var importer       = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(monoScript));
            var monoImporter   = importer as MonoImporter;
            var pluginImporter = importer as PluginImporter;

            if (monoImporter)
            {
                monoImporter.SetIcon(icon);
                monoImporter.SaveAndReimport();
            }
            else if (pluginImporter)
            {
                pluginImporter.SetIcon(monoScript.GetClass().FullName, icon);
                pluginImporter.SaveAndReimport();
            }
        }
示例#5
0
        private void SaveIconChanges()
        {
            if (!((UnityEngine.Object)EditorGUIUtility.GetIconForObject(this.m_TargetObject) != (UnityEngine.Object) this.m_StartIcon))
            {
                return;
            }
            MonoScript targetObject = this.m_TargetObject as MonoScript;

            if (!((UnityEngine.Object)targetObject != (UnityEngine.Object)null))
            {
                return;
            }
            if (this.m_MonoScriptIconChangedCallback != null)
            {
                this.m_MonoScriptIconChangedCallback(targetObject);
            }
            else
            {
                MonoImporter.CopyMonoScriptIconToImporters(targetObject);
            }
        }
示例#6
0
        void SaveIconChanges()
        {
            Texture2D currentIcon = EditorGUIUtility.GetIconForObject(m_TargetObject);

            // Only save if we had any changes
            if (currentIcon != m_StartIcon)
            {
                MonoScript monoScript = m_TargetObject as MonoScript;
                if (monoScript != null)
                {
                    // If callback is set then it is the callback owner responsiblity to call CopyMonoScriptIconToImporters
                    if (m_MonoScriptIconChangedCallback != null)
                    {
                        m_MonoScriptIconChangedCallback(monoScript);
                    }
                    else
                    {
                        MonoImporter.CopyMonoScriptIconToImporters(monoScript);
                    }
                }
            }
        }
示例#7
0
        private void Init(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            this.m_TargetObject   = targetObj;
            this.m_StartIcon      = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            this.m_ShowLabelIcons = showLabelIcons;
            Rect buttonRect = GUIUtility.GUIToScreenRect(activatorRect);

            GUIUtility.keyboardControl    = 0;
            this.m_LabelLargeIcons        = this.GetTextures("sv_label_", "", 0, 8);
            this.m_LabelIcons             = this.GetTextures("sv_icon_name", "", 0, 8);
            this.m_SmallIcons             = this.GetTextures("sv_icon_dot", "_sml", 0, 0x10);
            this.m_LargeIcons             = this.GetTextures("sv_icon_dot", "_pix16_gizmo", 0, 0x10);
            this.m_NoneButtonContent      = EditorGUIUtility.IconContent("sv_icon_none");
            this.m_NoneButtonContent.text = "None";
            float x = 140f;
            float y = 86f;

            if (this.m_ShowLabelIcons)
            {
                y = 126f;
            }
            base.ShowAsDropDown(buttonRect, new Vector2(x, y));
        }
 private void DrawListElement(Rect rect, bool even, AInfo ainfo)
 {
     if (ainfo == null)
     {
         Debug.LogError("DrawListElement: AInfo not valid!");
     }
     else
     {
         float num     = 17f;
         float a       = 0.3f;
         bool  changed = GUI.changed;
         bool  enabled = GUI.enabled;
         Color color   = GUI.color;
         GUI.changed = false;
         GUI.enabled = true;
         GUIStyle style = (!even) ? AnnotationWindow.m_Styles.listOddBg : AnnotationWindow.m_Styles.listEvenBg;
         GUI.Label(rect, GUIContent.Temp(""), style);
         Rect position = rect;
         position.width = rect.width - 64f - 22f;
         GUI.Label(position, ainfo.m_DisplayText, AnnotationWindow.m_Styles.listTextStyle);
         float   num2    = 16f;
         Rect    rect2   = new Rect(rect.width - 64f, rect.y + (rect.height - num2) * 0.5f, num2, num2);
         Texture texture = null;
         if (ainfo.m_ScriptClass != "")
         {
             texture = EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass));
             Rect position2 = rect2;
             position2.x     += 18f;
             position2.y     += 1f;
             position2.width  = 1f;
             position2.height = 12f;
             if (!EditorGUIUtility.isProSkin)
             {
                 GUI.color = new Color(0f, 0f, 0f, 0.33f);
             }
             else
             {
                 GUI.color = new Color(1f, 1f, 1f, 0.13f);
             }
             GUI.DrawTexture(position2, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
             GUI.color = Color.white;
             Rect rect3 = rect2;
             rect3.x    += 18f;
             rect3.y     = rect3.y;
             rect3.width = 9f;
             if (GUI.Button(rect3, this.iconSelectContent, AnnotationWindow.m_Styles.iconDropDown))
             {
                 UnityEngine.Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass);
                 if (script != null)
                 {
                     this.m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass;
                     if (IconSelector.ShowAtPosition(script, rect3, true))
                     {
                         IconSelector.SetMonoScriptIconChangedCallback(new IconSelector.MonoScriptIconChangedCallback(this.MonoScriptIconChanged));
                         GUIUtility.ExitGUI();
                     }
                 }
             }
         }
         else if (ainfo.HasIcon())
         {
             texture = AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID);
         }
         if (texture != null)
         {
             if (!ainfo.m_IconEnabled)
             {
                 GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a);
             }
             this.iconToggleContent.image = texture;
             if (GUI.Button(rect2, this.iconToggleContent, GUIStyle.none))
             {
                 ainfo.m_IconEnabled = !ainfo.m_IconEnabled;
                 this.SetIconState(ainfo);
             }
             GUI.color = color;
         }
         if (GUI.changed)
         {
             this.SetIconState(ainfo);
             GUI.changed = false;
         }
         GUI.enabled = true;
         GUI.color   = color;
         if (ainfo.HasGizmo())
         {
             string tooltip   = "Show/Hide Gizmo";
             Rect   position3 = new Rect(rect.width - 23f, rect.y + (rect.height - num) * 0.5f, num, num);
             ainfo.m_GizmoEnabled = GUI.Toggle(position3, ainfo.m_GizmoEnabled, new GUIContent("", tooltip), AnnotationWindow.m_Styles.toggle);
             if (GUI.changed)
             {
                 this.SetGizmoState(ainfo);
             }
         }
         GUI.enabled = enabled;
         GUI.changed = changed;
         GUI.color   = color;
     }
 }
示例#9
0
        internal void OnGUI()
        {
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }
            if ((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Escape))
            {
                this.CloseWindow();
            }
            Texture2D iconForObject = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      isLabelIcon   = false;

            if (Event.current.type == EventType.Repaint)
            {
                iconForObject = this.ConvertLargeIconToSmallIcon(iconForObject, ref isLabelIcon);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), m_Styles.background);
            this.DoTopSection(iconForObject != null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label("", m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int k = 0; k < (this.m_LabelIcons.Length / 2); k++)
                {
                    this.DoButton(this.m_LabelIcons[k], iconForObject, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int m = this.m_LabelIcons.Length / 2; m < this.m_LabelIcons.Length; m++)
                {
                    this.DoButton(this.m_LabelIcons[m], iconForObject, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label("", m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int i = 0; i < (this.m_SmallIcons.Length / 2); i++)
            {
                this.DoButton(this.m_SmallIcons[i], iconForObject, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int j = this.m_SmallIcons.Length / 2; j < this.m_SmallIcons.Length; j++)
            {
                this.DoButton(this.m_SmallIcons[j], iconForObject, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag2     = false;
            int  controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0]))
            {
                GUIUtility.keyboardControl = controlID;
                flag2 = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag2)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = controlID;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            if ((type == EventType.ExecuteCommand) && (((current.commandName == "ObjectSelectorUpdated") && (ObjectSelector.get.objectSelectorID == controlID)) && (GUIUtility.keyboardControl == controlID)))
            {
                Texture2D currentObject = ObjectSelector.GetCurrentObject() as Texture2D;
                EditorGUIUtility.SetIconForObject(this.m_TargetObject, currentObject);
                GUI.changed = true;
                current.Use();
            }
        }
        void DrawListElement(Rect rect, bool even, AInfo ainfo)
        {
            if (ainfo == null)
            {
                Debug.LogError("DrawListElement: AInfo not valid!");
                return;
            }

            string tooltip;
            float  togglerSize   = 17;
            float  disabledAlpha = 0.3f;

            // We maintain our own gui.changed
            bool  orgGUIChanged = GUI.changed;
            bool  orgGUIEnabled = GUI.enabled;
            Color orgColor      = GUI.color;

            GUI.changed = false;
            GUI.enabled = true;

            // Bg
            GUIStyle backgroundStyle = even ? m_Styles.listEvenBg : m_Styles.listOddBg;

            GUI.Label(rect, GUIContent.Temp(""), backgroundStyle);


            // Text
            Rect textRect = rect;

            //textRect.x += 22;
            textRect.width = rect.width - iconRightAlign - 22; // ensure text doesnt flow behind toggles
            GUI.Label(textRect, ainfo.m_DisplayText, m_Styles.listTextStyle);


            // Icon toggle
            float   iconSize = 16;
            Rect    iconRect = new Rect(rect.width - iconRightAlign, rect.y + (rect.height - iconSize) * 0.5f, iconSize, iconSize);
            Texture thumb    = null;

            if (ainfo.m_ScriptClass != "")
            {
                // Icon for scripts
                thumb = EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass));

                Rect div = iconRect;
                div.x     += 18;
                div.y     += 1;
                div.width  = 1;
                div.height = 12;

                if (!EditorGUIUtility.isProSkin)
                {
                    GUI.color = new Color(0, 0, 0, 0.33f);
                }
                else
                {
                    GUI.color = new Color(1, 1, 1, 0.13f);
                }

                GUI.DrawTexture(div, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
                GUI.color = Color.white;

                Rect arrowRect = iconRect;
                arrowRect.x    += 18;
                arrowRect.y    += 0;
                arrowRect.width = 9;

                if (GUI.Button(arrowRect, iconSelectContent, m_Styles.iconDropDown))
                {
                    Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass);
                    if (script != null)
                    {
                        m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass;
                        if (IconSelector.ShowAtPosition(script, arrowRect, true))
                        {
                            IconSelector.SetMonoScriptIconChangedCallback(MonoScriptIconChanged);
                            GUIUtility.ExitGUI();
                        }
                    }
                }
            }
            else
            {
                // Icon for builtin components
                if (ainfo.HasIcon())
                {
                    thumb = AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID);
                }
            }

            if (thumb != null)
            {
                if (!ainfo.m_IconEnabled)
                {
                    GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, disabledAlpha);
                    tooltip   = "";
                }

                iconToggleContent.image = thumb;
                if (GUI.Button(iconRect, iconToggleContent, GUIStyle.none))
                {
                    ainfo.m_IconEnabled = !ainfo.m_IconEnabled;
                    SetIconState(ainfo);
                }

                GUI.color = orgColor;
            }

            if (GUI.changed)
            {
                SetIconState(ainfo);
                GUI.changed = false;
            }

            GUI.enabled = true;
            GUI.color   = orgColor;

            // Gizmo toggle
            if (ainfo.HasGizmo())
            {
                tooltip = textGizmoVisible;

                Rect togglerRect = new Rect(rect.width - gizmoRightAlign, rect.y + (rect.height - togglerSize) * 0.5f, togglerSize, togglerSize);
                ainfo.m_GizmoEnabled = GUI.Toggle(togglerRect, ainfo.m_GizmoEnabled, new GUIContent("", tooltip), m_Styles.toggle);
                if (GUI.changed)
                {
                    SetGizmoState(ainfo);
                }
            }

            GUI.enabled = orgGUIEnabled;
            GUI.changed = orgGUIChanged;
            GUI.color   = orgColor;
        }
示例#11
0
 private void DrawListElement(Rect rect, bool even, AInfo ainfo)
 {
     if (ainfo == null)
     {
         Debug.LogError("DrawListElement: AInfo not valid!");
     }
     else
     {
         string str;
         float  width   = 17f;
         float  a       = 0.3f;
         bool   changed = GUI.changed;
         bool   enabled = GUI.enabled;
         Color  color   = GUI.color;
         GUI.changed = false;
         GUI.enabled = true;
         GUIStyle style = !even ? m_Styles.listOddBg : m_Styles.listEvenBg;
         GUI.Label(rect, GUIContent.Temp(string.Empty), style);
         Rect position = rect;
         position.width = (rect.width - 64f) - 22f;
         GUI.Label(position, ainfo.m_DisplayText, m_Styles.listTextStyle);
         float   num3          = 16f;
         Rect    rect3         = new Rect(rect.width - 64f, rect.y + ((rect.height - num3) * 0.5f), num3, num3);
         Texture iconForObject = null;
         if (ainfo.m_ScriptClass != string.Empty)
         {
             iconForObject = EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass));
             Rect rect4 = rect3;
             rect4.x += 18f;
             rect4.y++;
             rect4.width  = 1f;
             rect4.height = 12f;
             if (!EditorGUIUtility.isProSkin)
             {
                 GUI.color = new Color(0f, 0f, 0f, 0.33f);
             }
             else
             {
                 GUI.color = new Color(1f, 1f, 1f, 0.13f);
             }
             GUI.DrawTexture(rect4, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
             GUI.color = Color.white;
             Rect rect5 = rect3;
             rect5.x    += 18f;
             rect5.y     = rect5.y;
             rect5.width = 9f;
             if (GUI.Button(rect5, this.iconSelectContent, m_Styles.iconDropDown))
             {
                 Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass);
                 if (script != null)
                 {
                     this.m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass;
                     if (IconSelector.ShowAtPosition(script, rect5, true))
                     {
                         IconSelector.SetMonoScriptIconChangedCallback(new IconSelector.MonoScriptIconChangedCallback(this.MonoScriptIconChanged));
                         GUIUtility.ExitGUI();
                     }
                 }
             }
         }
         else if (ainfo.HasIcon())
         {
             iconForObject = AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID);
         }
         if (iconForObject != null)
         {
             if (!ainfo.m_IconEnabled)
             {
                 GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a);
                 str       = string.Empty;
             }
             this.iconToggleContent.image = iconForObject;
             if (GUI.Button(rect3, this.iconToggleContent, GUIStyle.none))
             {
                 ainfo.m_IconEnabled = !ainfo.m_IconEnabled;
                 this.SetIconState(ainfo);
             }
             GUI.color = color;
         }
         if (GUI.changed)
         {
             this.SetIconState(ainfo);
             GUI.changed = false;
         }
         GUI.enabled = true;
         GUI.color   = color;
         if (ainfo.HasGizmo())
         {
             str = "Show/Hide Gizmo";
             Rect rect6 = new Rect(rect.width - 23f, rect.y + ((rect.height - width) * 0.5f), width, width);
             ainfo.m_GizmoEnabled = GUI.Toggle(rect6, ainfo.m_GizmoEnabled, new GUIContent(string.Empty, str), m_Styles.toggle);
             if (GUI.changed)
             {
                 this.SetGizmoState(ainfo);
             }
         }
         GUI.enabled = enabled;
         GUI.changed = changed;
         GUI.color   = color;
     }
 }
 private void DrawListElement(Rect rect, bool even, AInfo ainfo)
 {
     if (ainfo == null)
     {
         Debug.LogError((object)"DrawListElement: AInfo not valid!");
     }
     else
     {
         float num1    = 17f;
         float a       = 0.3f;
         bool  changed = GUI.changed;
         bool  enabled = GUI.enabled;
         Color color   = GUI.color;
         GUI.changed = false;
         GUI.enabled = true;
         GUIStyle style = !even ? AnnotationWindow.m_Styles.listOddBg : AnnotationWindow.m_Styles.listEvenBg;
         GUI.Label(rect, GUIContent.Temp(string.Empty), style);
         Rect position1 = rect;
         position1.width = (float)((double)rect.width - 64.0 - 22.0);
         GUI.Label(position1, ainfo.m_DisplayText, AnnotationWindow.m_Styles.listTextStyle);
         float   num2      = 16f;
         Rect    position2 = new Rect(rect.width - 64f, rect.y + (float)(((double)rect.height - (double)num2) * 0.5), num2, num2);
         Texture texture   = (Texture)null;
         if (ainfo.m_ScriptClass != string.Empty)
         {
             texture = (Texture)EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass));
             Rect position3 = position2;
             position3.x += 18f;
             ++position3.y;
             position3.width  = 1f;
             position3.height = 12f;
             GUI.color        = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.13f) : new Color(0.0f, 0.0f, 0.0f, 0.33f);
             GUI.DrawTexture(position3, (Texture)EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
             GUI.color = Color.white;
             Rect rect1 = position2;
             rect1.x += 18f;
             // ISSUE: explicit reference operation
             // ISSUE: variable of a reference type
             Rect& local = @rect1;
             // ISSUE: explicit reference operation
             double y = (double)(^ local).y;
             // ISSUE: explicit reference operation
             (^ local).y = (float)y;
             rect1.width = 9f;
             if (GUI.Button(rect1, this.iconSelectContent, AnnotationWindow.m_Styles.iconDropDown))
             {
                 UnityEngine.Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass);
                 if (script != (UnityEngine.Object)null)
                 {
                     this.m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass;
                     if (IconSelector.ShowAtPosition(script, rect1, true))
                     {
                         IconSelector.SetMonoScriptIconChangedCallback(new IconSelector.MonoScriptIconChangedCallback(this.MonoScriptIconChanged));
                         GUIUtility.ExitGUI();
                     }
                 }
             }
         }
         else if (ainfo.HasIcon())
         {
             texture = (Texture)AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID);
         }
         if ((UnityEngine.Object)texture != (UnityEngine.Object)null)
         {
             if (!ainfo.m_IconEnabled)
             {
                 GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a);
                 string empty = string.Empty;
             }
             this.iconToggleContent.image = texture;
             if (GUI.Button(position2, this.iconToggleContent, GUIStyle.none))
             {
                 ainfo.m_IconEnabled = !ainfo.m_IconEnabled;
                 this.SetIconState(ainfo);
             }
             GUI.color = color;
         }
         if (GUI.changed)
         {
             this.SetIconState(ainfo);
             GUI.changed = false;
         }
         GUI.enabled = true;
         GUI.color   = color;
         if (ainfo.HasGizmo())
         {
             string tooltip   = "Show/Hide Gizmo";
             Rect   position3 = new Rect(rect.width - 23f, rect.y + (float)(((double)rect.height - (double)num1) * 0.5), num1, num1);
             ainfo.m_GizmoEnabled = GUI.Toggle(position3, ainfo.m_GizmoEnabled, new GUIContent(string.Empty, tooltip), AnnotationWindow.m_Styles.toggle);
             if (GUI.changed)
             {
                 this.SetGizmoState(ainfo);
             }
         }
         GUI.enabled = enabled;
         GUI.changed = changed;
         GUI.color   = color;
     }
 }
示例#13
0
        internal void OnGUI()
        {
            if (IconSelector.m_Styles == null)
            {
                IconSelector.m_Styles = new IconSelector.Styles();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.CloseWindow();
            }
            Texture2D texture2D = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      flag      = false;

            if (Event.current.type == EventType.Repaint)
            {
                texture2D = this.ConvertLargeIconToSmallIcon(texture2D, ref flag);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), IconSelector.m_Styles.background);
            this.DoTopSection(texture2D != null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label("", IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int i = 0; i < this.m_LabelIcons.Length / 2; i++)
                {
                    this.DoButton(this.m_LabelIcons[i], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int j = this.m_LabelIcons.Length / 2; j < this.m_LabelIcons.Length; j++)
                {
                    this.DoButton(this.m_LabelIcons[j], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label("", IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int k = 0; k < this.m_SmallIcons.Length / 2; k++)
            {
                this.DoButton(this.m_SmallIcons[k], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int l = this.m_SmallIcons.Length / 2; l < this.m_SmallIcons.Length; l++)
            {
                this.DoButton(this.m_SmallIcons[l], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag2     = false;
            int  controlID = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0]))
            {
                GUIUtility.keyboardControl = controlID;
                flag2 = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag2)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = controlID;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            if (type == EventType.ExecuteCommand)
            {
                string commandName = current.commandName;
                if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == controlID && GUIUtility.keyboardControl == controlID)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    Undo.RecordObject(this.m_TargetObject, "Set Icon On GameObject");
                    EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon);
                    GUI.changed = true;
                    current.Use();
                }
            }
        }
示例#14
0
        internal void OnGUI()
        {
            // Here due to static vars being thrown out when reloading assemblies
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }

            // Escape pressed?
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                CloseWindow();
            }

            Texture2D selectedIcon          = EditorGUIUtility.GetIconForObject(m_TargetObject);
            bool      isSelectionALabelIcon = false;

            if (Event.current.type == EventType.Repaint)
            {
                selectedIcon = ConvertLargeIconToSmallIcon(selectedIcon, ref isSelectionALabelIcon);
            }

            Event     evt       = Event.current;
            EventType eventType = evt.type;

            GUI.BeginGroup(new Rect(0, 0, position.width, position.height), m_Styles.background);

            DoTopSection(selectedIcon != null);

            GUILayout.Space(22);
            GUILayout.BeginHorizontal();
            GUILayout.Space(1);
            GUI.enabled = false;
            GUILayout.Label("", m_Styles.seperator);
            GUI.enabled = true;
            GUILayout.Space(1);
            GUILayout.EndHorizontal();
            GUILayout.Space(3);

            if (m_ShowLabelIcons)
            {
                // Label icons
                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = 0; i < m_LabelIcons.Length / 2; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = m_LabelIcons.Length / 2; i < m_LabelIcons.Length; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.Space(1);
                GUI.enabled = false;
                GUILayout.Label("", m_Styles.seperator);
                GUI.enabled = true;
                GUILayout.Space(1);
                GUILayout.EndHorizontal();
                GUILayout.Space(3);
            }

            // Small icons
            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = 0; i < m_SmallIcons.Length / 2; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = m_SmallIcons.Length / 2; i < m_SmallIcons.Length; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();
            GUILayout.Space(6);

            // Object selector section
            GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
            bool clicked = false;
            int  id      = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(s_Other))
            {
                GUIUtility.keyboardControl = id;
                clicked = true;
            }
            GUI.backgroundColor = new Color(1, 1, 1, 1);
            GUI.EndGroup();

            if (clicked)
            {
                ObjectSelector.get.Show(m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = id;
                GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
                evt.Use();
                GUIUtility.ExitGUI();
            }

            // Check for icon selected from ObjectSelector
            switch (eventType)
            {
            case EventType.ExecuteCommand:
                string commandName = evt.commandName;
                if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    Undo.RecordObject(m_TargetObject, "Set Icon On GameObject");
                    EditorGUIUtility.SetIconForObject(m_TargetObject, icon);

                    GUI.changed = true;
                    evt.Use();
                }
                break;
            }
        }
示例#15
0
        internal void OnGUI()
        {
            if (IconSelector.m_Styles == null)
            {
                IconSelector.m_Styles = new IconSelector.Styles();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.CloseWindow();
            }
            Texture2D texture2D   = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      isLabelIcon = false;

            if (Event.current.type == EventType.Repaint)
            {
                texture2D = this.ConvertLargeIconToSmallIcon(texture2D, ref isLabelIcon);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0.0f, 0.0f, this.position.width, this.position.height), IconSelector.m_Styles.background);
            this.DoTopSection((UnityEngine.Object)texture2D != (UnityEngine.Object)null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(6f);
                for (int index = 0; index < this.m_LabelIcons.Length / 2; ++index)
                {
                    this.DoButton(this.m_LabelIcons[index], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(6f);
                for (int index = this.m_LabelIcons.Length / 2; index < this.m_LabelIcons.Length; ++index)
                {
                    this.DoButton(this.m_LabelIcons[index], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal();
            GUILayout.Space(9f);
            for (int index = 0; index < this.m_SmallIcons.Length / 2; ++index)
            {
                this.DoButton(this.m_SmallIcons[index], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(9f);
            for (int index = this.m_SmallIcons.Length / 2; index < this.m_SmallIcons.Length; ++index)
            {
                this.DoButton(this.m_SmallIcons[index], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag      = false;
            int  controlId = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other...")))
            {
                GUIUtility.keyboardControl = controlId;
                flag = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), (SerializedProperty)null, false);
                ObjectSelector.get.objectSelectorID = controlId;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            if (type != EventType.ExecuteCommand || !(current.commandName == "ObjectSelectorUpdated") || (ObjectSelector.get.objectSelectorID != controlId || GUIUtility.keyboardControl != controlId))
            {
                return;
            }
            EditorGUIUtility.SetIconForObject(this.m_TargetObject, ObjectSelector.GetCurrentObject() as Texture2D);
            GUI.changed = true;
            current.Use();
        }