コード例 #1
0
        private void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlId = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if ((UnityEngine.Object)content.image == (UnityEngine.Object)selectedIcon)
            {
                Rect  position = GUILayoutUtility.topLevel.PeekNext();
                float num      = 2f;
                position.x     -= num;
                position.y     -= num;
                position.width  = (float)selectedIcon.width + 2f * num;
                position.height = (float)selectedIcon.height + 2f * num;
                GUI.Label(position, GUIContent.none, !labelIcon ? IconSelector.m_Styles.selection : IconSelector.m_Styles.selectionLabel);
            }
            if (!EditorGUILayout.IconButton(controlId, content, GUIStyle.none))
            {
                return;
            }
            EditorGUIUtility.SetIconForObject(this.m_TargetObject, this.ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon));
            EditorUtility.ForceReloadInspectors();
            AnnotationWindow.IconChanged();
            if (Event.current.clickCount != 2)
            {
                return;
            }
            this.CloseWindow();
        }
コード例 #2
0
        private void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (content.image == selectedIcon)
            {
                Rect  position = GUILayoutUtility.topLevel.PeekNext();
                float num2     = 2f;
                position.x     -= num2;
                position.y     -= num2;
                position.width  = selectedIcon.width + (2f * num2);
                position.height = selectedIcon.height + (2f * num2);
                GUI.Label(position, GUIContent.none, !labelIcon ? m_Styles.selection : m_Styles.selectionLabel);
            }
            if (EditorGUILayout.IconButton(controlID, content, GUIStyle.none, new GUILayoutOption[0]))
            {
                Texture2D icon = this.ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon);
                EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon);
                EditorUtility.ForceReloadInspectors();
                AnnotationWindow.IconChanged();
                if (Event.current.clickCount == 2)
                {
                    this.CloseWindow();
                }
            }
        }
コード例 #3
0
 private void DoTopSection(bool anySelected)
 {
     GUI.Label(new Rect(6f, 4f, 110f, 20f), "Select Icon");
     EditorGUI.BeginDisabledGroup(!anySelected);
     if (GUI.Button(new Rect(93f, 6f, 43f, 12f), this.m_NoneButtonContent, IconSelector.m_Styles.noneButton))
     {
         EditorGUIUtility.SetIconForObject(this.m_TargetObject, (Texture2D)null);
         EditorUtility.ForceReloadInspectors();
         AnnotationWindow.IconChanged();
     }
     EditorGUI.EndDisabledGroup();
 }
コード例 #4
0
        void SetIconForSelectedObjects(Texture2D icon)
        {
            Undo.RecordObjects(m_TargetObjectList, "Set Icon On GameObject");

            foreach (var target in m_TargetObjectList)
            {
                EditorGUIUtility.SetIconForObject(target, icon);
            }
            SetMultipleSelectedIcons();
            EditorUtility.ForceReloadInspectors();
            AnnotationWindow.IconChanged();
        }
コード例 #5
0
        private void DoTopSection(bool anySelected)
        {
            Rect position = new Rect(6f, 4f, 110f, 20f);

            GUI.Label(position, "Select Icon");
            using (new EditorGUI.DisabledScope(!anySelected))
            {
                Rect rect2 = new Rect(93f, 6f, 43f, 12f);
                if (GUI.Button(rect2, this.m_NoneButtonContent, m_Styles.noneButton))
                {
                    EditorGUIUtility.SetIconForObject(this.m_TargetObject, null);
                    EditorUtility.ForceReloadInspectors();
                    AnnotationWindow.IconChanged();
                }
            }
        }
コード例 #6
0
        void DoTopSection(bool anySelected)
        {
            Rect selectIconRect = new Rect(6, 4, 110, 20);

            GUI.Label(selectIconRect, "Select Icon");

            // Draw selection background if none is selected
            using (new EditorGUI.DisabledScope(!anySelected))
            {
                Rect noneButtonRect = new Rect(93, 6, 43, 12);
                if (GUI.Button(noneButtonRect, m_NoneButtonContent, m_Styles.noneButton))
                {
                    EditorGUIUtility.SetIconForObject(m_TargetObject, null);
                    EditorUtility.ForceReloadInspectors();
                    AnnotationWindow.IconChanged();
                }
            }
        }
コード例 #7
0
        void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            // Draw selection background if this is the selected icon
            if (content.image == selectedIcon)
            {
                // When placing our selection background we assume that icons rendered from top left corner
                Rect  rect = GUILayoutUtility.topLevel.PeekNext();
                float pad  = 2;
                rect.x     -= pad;
                rect.y     -= pad;
                rect.width  = selectedIcon.width + 2 * pad;
                rect.height = selectedIcon.height + 2 * pad;
                GUI.Label(rect, GUIContent.none, labelIcon ? m_Styles.selectionLabel : m_Styles.selection);
            }

            // Do icon
            if (EditorGUILayout.IconButton(controlID, content, GUIStyle.none))
            {
                // Map to new icon
                Texture2D largeIcon = ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon);
                Undo.RecordObject(m_TargetObject, "Set Icon On GameObject");
                EditorGUIUtility.SetIconForObject(m_TargetObject, largeIcon);

                // We assume that we are setting icon in an inspector or annotation window (todo: make repaint delegate)
                EditorUtility.ForceReloadInspectors();
                AnnotationWindow.IconChanged();

                // Close on double click
                if (Event.current.clickCount == 2)
                {
                    CloseWindow();
                }
            }
        }