GetMiniTypeThumbnailFromClassID() private method

private GetMiniTypeThumbnailFromClassID ( int classID ) : Texture2D
classID int
return UnityEngine.Texture2D
 public ComponentElement(int level, string name, string menuPath, string commandString)
 {
     this.level    = level;
     this.typeName = name.Replace(" ", string.Empty);
     this.menuPath = menuPath;
     if (commandString.StartsWith("SCRIPT"))
     {
         Texture miniThumbnail = (Texture)AssetPreview.GetMiniThumbnail(EditorUtility.InstanceIDToObject(int.Parse(commandString.Substring(6))));
         this.content = new GUIContent(name, miniThumbnail);
     }
     else
     {
         int classID = int.Parse(commandString);
         this.content = new GUIContent(name, (Texture)AssetPreview.GetMiniTypeThumbnailFromClassID(classID));
     }
 }
Exemplo n.º 2
0
 public ComponentElement(int level, string name, string menuPath, string commandString)
 {
     this.level    = level;
     this.menuPath = menuPath;
     this.isLegacy = menuPath.Contains("Legacy");
     if (commandString.StartsWith("SCRIPT"))
     {
         int instanceID                   = int.Parse(commandString.Substring(6));
         UnityEngine.Object obj           = EditorUtility.InstanceIDToObject(instanceID);
         Texture            miniThumbnail = AssetPreview.GetMiniThumbnail(obj);
         this.content = new GUIContent(name, miniThumbnail);
     }
     else
     {
         int classID = int.Parse(commandString);
         this.content = new GUIContent(name, AssetPreview.GetMiniTypeThumbnailFromClassID(classID));
     }
 }
        public ComponentDropdownItem(string name, string menuPath, string command) : base(name, -1)
        {
            m_MenuPath = menuPath;
            m_IsLegacy = menuPath.Contains("Legacy");

            if (command.StartsWith("SCRIPT"))
            {
                var scriptId = int.Parse(command.Substring(6));
                var obj      = EditorUtility.InstanceIDToObject(scriptId);
                var icon     = AssetPreview.GetMiniThumbnail(obj);
                m_Content = new GUIContent(name, icon);
            }
            else
            {
                var classId = int.Parse(command);
                m_Content = new GUIContent(name, AssetPreview.GetMiniTypeThumbnailFromClassID(classId));
            }
            m_ContentWhenSearching = new GUIContent(m_Content);
            if (m_IsLegacy)
            {
                m_ContentWhenSearching.text += " (Legacy)";
            }
        }
 public ComponentDropdownElement(string name, string menuPath, string command) : base(name)
 {
     this.m_MenuPath = menuPath;
     this.m_Command  = command;
     this.m_IsLegacy = menuPath.Contains("Legacy");
     if (command.StartsWith("SCRIPT"))
     {
         int instanceID                   = int.Parse(command.Substring(6));
         UnityEngine.Object obj           = EditorUtility.InstanceIDToObject(instanceID);
         Texture2D          miniThumbnail = AssetPreview.GetMiniThumbnail(obj);
         this.m_Content = new GUIContent(name, miniThumbnail);
     }
     else
     {
         int classID = int.Parse(command);
         this.m_Content = new GUIContent(name, AssetPreview.GetMiniTypeThumbnailFromClassID(classID));
     }
     this.m_ContentWhenSearching = new GUIContent(this.m_Content);
     if (this.m_IsLegacy)
     {
         GUIContent expr_A4 = this.m_ContentWhenSearching;
         expr_A4.text += " (Legacy)";
     }
 }
Exemplo n.º 5
0
 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;
     }
 }
        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;
        }
Exemplo n.º 7
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;
     }
 }
Exemplo n.º 8
0
 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;
     }
 }