Наследование: EditorWindow
Пример #1
0
 internal static void SetMonoScriptIconChangedCallback(IconSelector.MonoScriptIconChangedCallback callback)
 {
   if ((UnityEngine.Object) IconSelector.s_IconSelector != (UnityEngine.Object) null)
     IconSelector.s_IconSelector.m_MonoScriptIconChangedCallback = callback;
   else
     Debug.Log((object) "ERROR: setting callback on hidden IconSelector");
 }
Пример #2
0
        internal override void OnHeaderIconGUI(Rect iconRect)
        {
            if (assetTargets != null)
            {
                if (m_Icon == null)
                {
                    m_TargetObject = new SerializedObject(assetTargets);
                    m_Icon = m_TargetObject.FindProperty("m_Icon");
                }

                if (m_Icon == null)
                {
                    base.OnHeaderIconGUI(iconRect);
                    return;
                }

                Rect dropDownRect = iconRect;

                dropDownRect.size = EditorGUI.GetObjectIconDropDownSize(iconRect.width, iconRect.height);
                EditorGUI.ObjectIconDropDown(dropDownRect, assetTargets, true, null, m_Icon);

                Event evt = Event.current;
                if (EventType.ValidateCommand == evt.type && (evt.commandName == "Undo Icon On GameObject" || evt.commandName == "Redo Icon On GameObject"))
                {
                    MonoScript monoScript = assetTargets[0] as MonoScript;
                    IconSelector.CopyIconToImporter(monoScript);
                    GUI.changed = true;
                    evt.Use();
                }
            }
            else
            {
                base.OnHeaderIconGUI(iconRect);
            }
        }
Пример #3
0
        void OnDisable()
        {
            SaveIconChanges();

            s_LastClosedTime = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            s_IconSelector   = null;
        }
Пример #4
0
 internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
 {
   int instanceId = targetObj.GetInstanceID();
   bool flag = DateTime.Now.Ticks / 10000L < IconSelector.s_LastClosedTime + 50L;
   if (instanceId == IconSelector.s_LastInstanceID && flag)
     return false;
   Event.current.Use();
   IconSelector.s_LastInstanceID = instanceId;
   if ((UnityEngine.Object) IconSelector.s_IconSelector == (UnityEngine.Object) null)
     IconSelector.s_IconSelector = ScriptableObject.CreateInstance<IconSelector>();
   IconSelector.s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
   return true;
 }
Пример #5
0
		internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
		{
			int instanceID = targetObj.GetInstanceID();
			long num = DateTime.Now.Ticks / 10000L;
			bool flag = num < IconSelector.s_LastClosedTime + 50L;
			if (instanceID != IconSelector.s_LastInstanceID || !flag)
			{
				Event.current.Use();
				IconSelector.s_LastInstanceID = instanceID;
				if (IconSelector.s_IconSelector == null)
				{
					IconSelector.s_IconSelector = ScriptableObject.CreateInstance<IconSelector>();
				}
				IconSelector.s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
				return true;
			}
			return false;
		}
Пример #6
0
        internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            int  instanceId = targetObj.GetInstanceID();
            bool flag       = DateTime.Now.Ticks / 10000L < IconSelector.s_LastClosedTime + 50L;

            if (instanceId == IconSelector.s_LastInstanceID && flag)
            {
                return(false);
            }
            Event.current.Use();
            IconSelector.s_LastInstanceID = instanceId;
            if ((UnityEngine.Object)IconSelector.s_IconSelector == (UnityEngine.Object)null)
            {
                IconSelector.s_IconSelector = ScriptableObject.CreateInstance <IconSelector>();
            }
            IconSelector.s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
            return(true);
        }
Пример #7
0
        internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            int  instanceID = targetObj.GetInstanceID();
            long num2       = DateTime.Now.Ticks / 0x2710L;
            bool flag       = num2 < (s_LastClosedTime + 50L);

            if ((instanceID != s_LastInstanceID) || !flag)
            {
                Event.current.Use();
                s_LastInstanceID = instanceID;
                if (s_IconSelector == null)
                {
                    s_IconSelector = ScriptableObject.CreateInstance <IconSelector>();
                }
                s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
                return(true);
            }
            return(false);
        }
Пример #8
0
        // Returns true if shown
        internal static bool ShowAtPosition(Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            int instanceID = targetObj.GetInstanceID();
            // We could not use realtimeSinceStartUp since it is resetted when entering playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (instanceID != s_LastInstanceID || !justClosed)
            {
                Event.current.Use();
                s_LastInstanceID = instanceID;
                if (s_IconSelector == null)
                {
                    s_IconSelector = ScriptableObject.CreateInstance <IconSelector>();
                }
                s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
                return(true);
            }

            return(false);
        }
Пример #9
0
        internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            int  instanceID = targetObj.GetInstanceID();
            long num        = DateTime.Now.Ticks / 10000L;
            bool flag       = num < IconSelector.s_LastClosedTime + 50L;
            bool result;

            if (instanceID != IconSelector.s_LastInstanceID || !flag)
            {
                Event.current.Use();
                IconSelector.s_LastInstanceID = instanceID;
                if (IconSelector.s_IconSelector == null)
                {
                    IconSelector.s_IconSelector = ScriptableObject.CreateInstance <IconSelector>();
                }
                IconSelector.s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Пример #10
0
 private void OnDisable()
 {
     this.SaveIconChanges();
     s_LastClosedTime = DateTime.Now.Ticks / 0x2710L;
     s_IconSelector   = null;
 }
        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;
        }
Пример #12
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;
     }
 }
Пример #13
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;
     }
 }
Пример #14
0
 private void OnDisable()
 {
     this.SaveIconChanges();
     IconSelector.s_LastClosedTime = DateTime.Now.Ticks / 10000L;
     IconSelector.s_IconSelector   = (IconSelector)null;
 }
Пример #15
0
 private void OnDisable()
 {
   this.SaveIconChanges();
   IconSelector.s_LastClosedTime = DateTime.Now.Ticks / 10000L;
   IconSelector.s_IconSelector = (IconSelector) null;
 }
Пример #16
0
 internal static bool ShowAtPosition(UnityEngine.Object targetObj, Rect activatorRect, bool showLabelIcons)
 {
     int instanceID = targetObj.GetInstanceID();
     long num2 = DateTime.Now.Ticks / 0x2710L;
     bool flag = num2 < (s_LastClosedTime + 50L);
     if ((instanceID == s_LastInstanceID) && flag)
     {
         return false;
     }
     Event.current.Use();
     s_LastInstanceID = instanceID;
     if (s_IconSelector == null)
     {
         s_IconSelector = ScriptableObject.CreateInstance<IconSelector>();
     }
     s_IconSelector.Init(targetObj, activatorRect, showLabelIcons);
     return true;
 }
Пример #17
0
 private void OnDisable()
 {
     this.SaveIconChanges();
     s_LastClosedTime = DateTime.Now.Ticks / 0x2710L;
     s_IconSelector = null;
 }
Пример #18
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;
     }
 }
Пример #19
0
		internal static void SetMonoScriptIconChangedCallback(IconSelector.MonoScriptIconChangedCallback callback)
		{
			if (IconSelector.s_IconSelector != null)
			{
				IconSelector.s_IconSelector.m_MonoScriptIconChangedCallback = callback;
			}
			else
			{
				Debug.Log("ERROR: setting callback on hidden IconSelector");
			}
		}