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(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(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(string.Empty, 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(); } EventType eventType = type; if (eventType == EventType.ExecuteCommand) { string commandName = current.commandName; if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == controlID && GUIUtility.keyboardControl == controlID) { Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D; EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon); GUI.changed = true; current.Use(); } } }
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(); }
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(); }