public override void OnInspectorGUI() { base.serializedObject.Update(); for (int i = 0; i < this.m_Shaders.arraySize; i++) { this.DrawShaderEntry(i); } if (GUILayout.Button("Add shader", new GUILayoutOption[0])) { ObjectSelector.get.Show(null, typeof(Shader), null, false); ObjectSelector.get.objectSelectorID = "ShaderVariantSelector".GetHashCode(); GUIUtility.ExitGUI(); } if (Event.current.type == EventType.ExecuteCommand) { if (Event.current.commandName == "ObjectSelectorClosed" && ObjectSelector.get.objectSelectorID == "ShaderVariantSelector".GetHashCode()) { Shader shader = ObjectSelector.GetCurrentObject() as Shader; if (shader != null) { ShaderUtil.AddNewShaderToCollection(shader, base.target as ShaderVariantCollection); } Event.current.Use(); GUIUtility.ExitGUI(); } } base.serializedObject.ApplyModifiedProperties(); }
void OnDisable() { if (m_ObjectSelectorReceiver != null) { m_ObjectSelectorReceiver.OnSelectionClosed(GetCurrentObject()); } if (m_OnObjectSelectorClosed != null) { m_OnObjectSelectorClosed(GetCurrentObject()); } SendEvent(ObjectSelectorClosedCommand, false); if (m_ListArea != null) { m_StartGridSize.value = m_ListArea.gridSize; } Undo.CollapseUndoOperations(m_ModalUndoGroup); if (s_SharedObjectSelector == this) { s_SharedObjectSelector = null; } if (m_EditorCache != null) { m_EditorCache.Dispose(); } AssetPreview.ClearTemporaryAssetPreviews(); }
private void HandleObjectSelectorResult() { Event current = Event.current; if (current.type == EventType.ExecuteCommand) { string commandName = current.commandName; if ((commandName == "ObjectSelectorUpdated") && (ObjectSelector.get.objectSelectorID == 0x4bc)) { if ((this.m_DraggedMixers == null) || (this.m_DraggedMixers.Count == 0)) { Debug.LogError("Unexpected invalid mixer list used for dragging"); } UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject(); AudioMixerGroup group = (currentObject == null) ? null : (currentObject as AudioMixerGroup); Undo.RecordObjects(this.m_DraggedMixers.ToArray(), "Set output group for mixer" + ((this.m_DraggedMixers.Count <= 1) ? "" : "s")); foreach (AudioMixerController controller in this.m_DraggedMixers) { if (controller != null) { controller.outputAudioMixerGroup = group; } else { Debug.LogError("invalid mixer: is null"); } } GUI.changed = true; current.Use(); this.ReloadTree(); if (< > f__am$cache1 == null) {
public override void OnInspectorGUI() { this.serializedObject.Update(); for (int shaderIndex = 0; shaderIndex < this.m_Shaders.arraySize; ++shaderIndex) { this.DrawShaderEntry(shaderIndex); } if (GUILayout.Button("Add shader")) { ObjectSelector.get.Show((Object)null, typeof(Shader), (SerializedProperty)null, false); ObjectSelector.get.objectSelectorID = "ShaderVariantSelector".GetHashCode(); GUIUtility.ExitGUI(); } if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorClosed" && ObjectSelector.get.objectSelectorID == "ShaderVariantSelector".GetHashCode()) { Shader currentObject = ObjectSelector.GetCurrentObject() as Shader; if ((Object)currentObject != (Object)null) { ShaderUtil.AddNewShaderToCollection(currentObject, this.target as ShaderVariantCollection); } Event.current.Use(); GUIUtility.ExitGUI(); } this.serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Draws the object field and, if the user attempts to change the value, asks the user for confirmation. /// </summary> /// <param name="serializedObject">The <see cref="SerializedObject"/> that holds the <see cref="SerializedProperty"/> with the new render pipeline asset.</param> /// <param name="serializedProperty">The <see cref="SerializedProperty"/> to modify with the new render pipeline asset.</param> internal static void RenderPipelineAssetField(SerializedObject serializedObject, SerializedProperty serializedProperty) { Rect renderLoopRect = EditorGUILayout.GetControlRect(true, EditorGUI.GetPropertyHeight(serializedProperty)); EditorGUI.BeginProperty(renderLoopRect, RenderPipelineAssetSelectorStyles.renderPipeLabel, serializedProperty); int id = GUIUtility.GetControlID(s_ObjectFieldHash, FocusType.Keyboard, renderLoopRect); var selectedRenderPipelineAsset = DoObjectField( position: IndentedRect(renderLoopRect), dropRect: IndentedRect(renderLoopRect), id: id, obj: serializedProperty.objectReferenceValue, objBeingEdited: null, objType: typeof(RenderPipelineAsset), additionalType: null, property: null, validator: null, allowSceneObjects: false, style: EditorStyles.objectField, onObjectSelectorClosed: obj => { if (!ObjectSelector.SelectionCanceled()) { PromptConfirmation(serializedObject, serializedProperty, obj); } }); if (!ObjectSelector.isVisible) { PromptConfirmation(serializedObject, serializedProperty, selectedRenderPipelineAsset); } EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { serializedObject.Update(); for (var i = 0; i < m_Shaders.arraySize; ++i) { DrawShaderEntry(i); } // Button to add a new shader to collection if (GUILayout.Button("Add shader")) { // Show object selector ObjectSelector.get.Show(null, typeof(Shader), null, false); ObjectSelector.get.objectSelectorID = "ShaderVariantSelector".GetHashCode(); GUIUtility.ExitGUI(); } if (Event.current.type == EventType.ExecuteCommand) { // New shader picked in object selector; add it to the collection if (Event.current.commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == "ShaderVariantSelector".GetHashCode()) { var newShader = ObjectSelector.GetCurrentObject() as Shader; if (newShader != null) { ShaderUtil.AddNewShaderToCollection(newShader, target as ShaderVariantCollection); } Event.current.Use(); GUIUtility.ExitGUI(); } } serializedObject.ApplyModifiedProperties(); }
public override void OnSelectionChanged(Object selection) { if (IsValid()) { m_Owner.SetPreview(ObjectSelector.GetCurrentObject() as GameObject); InspectorWindow.RepaintAllInspectors(); } }
public override void OnSelectionClosed(Object selection) { if (IsValid()) { m_Owner.SetPreview(ObjectSelector.GetCurrentObject() as GameObject); } m_Selector.objectSelectorReceiver = null; }
public void DoAvatarPreview(Rect rect, GUIStyle background) { this.Init(); Rect position = new Rect(rect.xMax - 16f, rect.yMax - 16f, 16f, 16f); if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive, GUIStyle.none)) { GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(EditorGUIUtility.TrTextContent("Auto", null, null), false, new GenericMenu.MenuFunction2(this.SetPreviewAvatarOption), AvatarPreview.PreviewPopupOptions.Auto); genericMenu.AddItem(EditorGUIUtility.TrTextContent("Unity Model", null, null), false, new GenericMenu.MenuFunction2(this.SetPreviewAvatarOption), AvatarPreview.PreviewPopupOptions.DefaultModel); genericMenu.AddItem(EditorGUIUtility.TrTextContent("Other...", null, null), false, new GenericMenu.MenuFunction2(this.SetPreviewAvatarOption), AvatarPreview.PreviewPopupOptions.Other); genericMenu.ShowAsContext(); } Rect rect2 = rect; rect2.yMin += 21f; rect2.height = Mathf.Max(rect2.height, 64f); int controlID = GUIUtility.GetControlID(this.m_PreviewHint, FocusType.Passive, rect2); Event current = Event.current; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl == EventType.Repaint && this.m_IsValid) { this.DoRenderPreview(rect2, background); this.previewUtility.EndAndDrawPreview(rect2); } this.AvatarTimeControlGUI(rect); GUI.DrawTexture(position, AvatarPreview.s_Styles.avatarIcon.image); int controlID2 = GUIUtility.GetControlID(this.m_PreviewSceneHint, FocusType.Passive); typeForControl = current.GetTypeForControl(controlID2); this.DoAvatarPreviewDrag(typeForControl); this.HandleViewTool(current, typeForControl, controlID2, rect2); this.DoAvatarPreviewFrame(current, typeForControl, rect2); if (!this.m_IsValid) { Rect position2 = rect2; position2.yMax -= position2.height / 2f - 16f; EditorGUI.DropShadowLabel(position2, "No model is available for preview.\nPlease drag a model into this Preview Area."); } if (current.type == EventType.ExecuteCommand) { string commandName = current.commandName; if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == this.m_ModelSelectorId) { this.SetPreview(ObjectSelector.GetCurrentObject() as GameObject); current.Use(); } } if (current.type == EventType.Repaint) { EditorGUIUtility.AddCursorRect(rect2, this.currentCursor); } }
private void TreeViewSelection(TreeViewItem item) { if (this.m_ObjectSelectorReceiver != null) { this.m_ObjectSelectorReceiver.OnSelectionChanged(ObjectSelector.GetCurrentObject()); } if (this.m_OnObjectSelectorUpdated != null) { this.m_OnObjectSelectorUpdated(ObjectSelector.GetCurrentObject()); } this.SendEvent("ObjectSelectorUpdated", true); }
static Object AssignSelectedObject(SerializedProperty property, ObjectFieldValidator validator, System.Type objectType, Event evt) { Object[] references = { ObjectSelector.GetCurrentObject() }; Object assigned = validator(references, objectType, property, ObjectFieldValidatorOptions.None); // Assign the value if (property != null) { property.objectReferenceValue = assigned; } GUI.changed = true; evt.Use(); return(assigned); }
void HandleObjectSelectorResult() { Event evt = Event.current; if (evt.type == EventType.ExecuteCommand) { string commandName = evt.commandName; if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == kObjectSelectorID) { if (m_DraggedMixers == null || m_DraggedMixers.Count == 0) { Debug.LogError("Unexpected invalid mixer list used for dragging"); } var selected = ObjectSelector.GetCurrentObject(); AudioMixerGroup selectedGroup = selected != null ? selected as AudioMixerGroup : null; Undo.RecordObjects(m_DraggedMixers.ToArray(), "Set output group for mixer" + (m_DraggedMixers.Count > 1 ? "s" : "")); foreach (var mixer in m_DraggedMixers) { if (mixer != null) { mixer.outputAudioMixerGroup = selectedGroup; } else { Debug.LogError("invalid mixer: is null"); } } GUI.changed = true; evt.Use(); ReloadTree(); // Ensure newly selected output group is revealed int[] selectedIDs = (from i in m_DraggedMixers select i.GetInstanceID()).ToArray(); m_TreeView.SetSelection(selectedIDs, true); } if (commandName == ObjectSelector.ObjectSelectorClosedCommand) { m_DraggedMixers = null; // cleanup stored state } } }
private void HandleObjectSelectorResult() { Event current1 = Event.current; if (current1.type != EventType.ExecuteCommand) { return; } string commandName = current1.commandName; if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == 1212) { if (this.m_DraggedMixers == null || this.m_DraggedMixers.Count == 0) { Debug.LogError((object)"Unexpected invalid mixer list used for dragging"); } UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject(); AudioMixerGroup audioMixerGroup = !(currentObject != (UnityEngine.Object)null) ? (AudioMixerGroup)null : currentObject as AudioMixerGroup; Undo.RecordObjects((UnityEngine.Object[]) this.m_DraggedMixers.ToArray(), "Set output group for mixer" + (this.m_DraggedMixers.Count <= 1 ? string.Empty : "s")); using (List <AudioMixerController> .Enumerator enumerator = this.m_DraggedMixers.GetEnumerator()) { while (enumerator.MoveNext()) { AudioMixerController current2 = enumerator.Current; if ((UnityEngine.Object)current2 != (UnityEngine.Object)null) { current2.outputAudioMixerGroup = audioMixerGroup; } else { Debug.LogError((object)"invalid mixer: is null"); } } } GUI.changed = true; current1.Use(); this.ReloadTree(); this.m_TreeView.SetSelection(this.m_DraggedMixers.Select <AudioMixerController, int>((Func <AudioMixerController, int>)(i => i.GetInstanceID())).ToArray <int>(), true); } if (!(commandName == "ObjectSelectorClosed")) { return; } this.m_DraggedMixers = (List <AudioMixerController>)null; }
private void OnDisable() { this.SendEvent("ObjectSelectorClosed", false); if (this.m_ListArea != null) { this.m_StartGridSize.value = this.m_ListArea.gridSize; } Undo.CollapseUndoOperations(this.m_ModalUndoGroup); if (ObjectSelector.s_SharedObjectSelector == this) { ObjectSelector.s_SharedObjectSelector = null; } if (this.m_EditorCache != null) { this.m_EditorCache.Dispose(); } AssetPreview.ClearTemporaryAssetPreviews(); }
private void ListAreaItemSelectedCallback(bool doubleClicked) { if (doubleClicked) { this.ItemWasDoubleClicked(); } else { this.m_FocusSearchFilter = false; if (this.m_ObjectSelectorReceiver != null) { this.m_ObjectSelectorReceiver.OnSelectionChanged(ObjectSelector.GetCurrentObject()); } if (this.m_OnObjectSelectorUpdated != null) { this.m_OnObjectSelectorUpdated(ObjectSelector.GetCurrentObject()); } this.SendEvent("ObjectSelectorUpdated", true); } }
private void HandleObjectSelectorResult() { Event current = Event.current; if (current.type == EventType.ExecuteCommand) { string commandName = current.commandName; if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == 1212) { if (this.m_DraggedMixers == null || this.m_DraggedMixers.Count == 0) { Debug.LogError("Unexpected invalid mixer list used for dragging"); } UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject(); AudioMixerGroup outputAudioMixerGroup = (!(currentObject != null)) ? null : (currentObject as AudioMixerGroup); Undo.RecordObjects(this.m_DraggedMixers.ToArray(), "Set output group for mixer" + ((this.m_DraggedMixers.Count <= 1) ? string.Empty : "s")); foreach (AudioMixerController current2 in this.m_DraggedMixers) { if (current2 != null) { current2.outputAudioMixerGroup = outputAudioMixerGroup; } else { Debug.LogError("invalid mixer: is null"); } } GUI.changed = true; current.Use(); this.ReloadTree(); int[] selectedIDs = ( from i in this.m_DraggedMixers select i.GetInstanceID()).ToArray <int>(); this.m_TreeView.SetSelection(selectedIDs, true); } if (commandName == "ObjectSelectorClosed") { this.m_DraggedMixers = null; } } }
void OnDisable() { NotifySelectorClosed(false); if (m_ListArea != null) { m_StartGridSize.value = m_ListArea.gridSize; } if (s_SharedObjectSelector == this) { s_SharedObjectSelector = null; } if (m_EditorCache != null) { m_EditorCache.Dispose(); } AssetPreview.ClearTemporaryAssetPreviews(); HierarchyProperty.ClearSceneObjectsFilter(); m_Debounce?.Dispose(); m_Debounce = null; }
void OnDisable() { NotifySelectorClosed(false); if (m_ListArea != null) { m_StartGridSize.value = m_ListArea.gridSize; } Undo.CollapseUndoOperations(m_ModalUndoGroup); if (s_SharedObjectSelector == this) { s_SharedObjectSelector = null; } if (m_EditorCache != null) { m_EditorCache.Dispose(); } AssetPreview.ClearTemporaryAssetPreviews(); m_Debounce = null; }
static void ApplyChangeIfNeeded(SerializedObject serializedObject, SerializedProperty serializedProperty, Object selectedRenderPipelineAsset) { if (!ObjectSelector.isVisible) { AskRenderPipelineChangeConfirmation(serializedObject, serializedProperty, selectedRenderPipelineAsset); return; } if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == ObjectSelector.ObjectSelectorClosedCommand) { AskRenderPipelineChangeConfirmation(serializedObject, serializedProperty, ObjectSelector.GetCurrentObject()); Event.current.Use(); GUIUtility.ExitGUI(); } }
public void DoAvatarPreview(Rect rect, GUIStyle background) { Init(); Rect choserRect = new Rect(rect.xMax - 16, rect.yMax - 16, 16, 16); if (EditorGUI.DropdownButton(choserRect, GUIContent.none, FocusType.Passive, GUIStyle.none)) { GenericMenu menu = new GenericMenu(); menu.AddItem(EditorGUIUtility.TrTextContent("Auto"), false, SetPreviewAvatarOption, PreviewPopupOptions.Auto); menu.AddItem(EditorGUIUtility.TrTextContent("Unity Model"), false, SetPreviewAvatarOption, PreviewPopupOptions.DefaultModel); menu.AddItem(EditorGUIUtility.TrTextContent("Other..."), false, SetPreviewAvatarOption, PreviewPopupOptions.Other); menu.ShowAsContext(); } Rect previewRect = rect; previewRect.yMin += kTimeControlRectHeight; previewRect.height = Mathf.Max(previewRect.height, 64f); int previewID = GUIUtility.GetControlID(m_PreviewHint, FocusType.Passive, previewRect); Event evt = Event.current; EventType type = evt.GetTypeForControl(previewID); if (type == EventType.Repaint && m_IsValid) { DoRenderPreview(previewRect, background); previewUtility.EndAndDrawPreview(previewRect); } AvatarTimeControlGUI(rect); GUI.DrawTexture(choserRect, s_Styles.avatarIcon.image); int previewSceneID = GUIUtility.GetControlID(m_PreviewSceneHint, FocusType.Passive); type = evt.GetTypeForControl(previewSceneID); DoAvatarPreviewDrag(type); HandleViewTool(evt, type, previewSceneID, previewRect); DoAvatarPreviewFrame(evt, type, previewRect); if (!m_IsValid) { Rect warningRect = previewRect; warningRect.yMax -= warningRect.height / 2 - 16; EditorGUI.DropShadowLabel( warningRect, "No model is available for preview.\nPlease drag a model into this Preview Area."); } // Check for model selected from ObjectSelector if (evt.type == EventType.ExecuteCommand) { string commandName = evt.commandName; if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == m_ModelSelectorId) { SetPreview(ObjectSelector.GetCurrentObject() as GameObject); evt.Use(); } } // Apply the current cursor if (evt.type == EventType.Repaint) { EditorGUIUtility.AddCursorRect(previewRect, currentCursor); } }
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(); }
private void PreviewArea() { GUI.Box(new Rect(0.0f, this.m_TopSize, this.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground); if (this.m_ListArea.GetSelection().Length == 0) { return; } EditorWrapper p = (EditorWrapper)null; UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject(); if ((double)this.m_PreviewSize < 75.0) { string s; if (currentObject != (UnityEngine.Object)null) { p = this.m_EditorCache[currentObject]; string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name); s = (p == null ? currentObject.name + " (" + str + ")" : p.name + " (" + str + ")") + " " + AssetDatabase.GetAssetPath(currentObject); } else { s = "None"; } this.LinePreview(s, currentObject, p); } else { if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } string s; if (currentObject != (UnityEngine.Object)null) { p = this.m_EditorCache[currentObject]; string str1 = ObjectNames.NicifyVariableName(currentObject.GetType().Name); string str2; if (p != null) { string infoString = p.GetInfoString(); if (infoString != string.Empty) { str2 = p.name + "\n" + str1 + "\n" + infoString; } else { str2 = p.name + "\n" + str1; } } else { str2 = currentObject.name + "\n" + str1; } s = str2 + "\n" + AssetDatabase.GetAssetPath(currentObject); } else { s = "None"; } if ((double)this.m_ShowWidePreview.faded != 0.0) { GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded); this.WidePreview(this.m_PreviewSize, s, currentObject, p); } if ((double)this.m_ShowOverlapPreview.faded != 0.0) { GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded); this.OverlapPreview(this.m_PreviewSize, s, currentObject, p); } GUI.color = Color.white; this.m_EditorCache.CleanupUntouchedEditors(); } }
public ObjectSelectorOperation(AvatarPreview owner, ObjectSelector selector) { m_Owner = owner; m_Selector = selector; }
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; } }
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(); } } }
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(); } }
public static UnityEngine.Object GetObjectPickerObject() { return(ObjectSelector.GetCurrentObject()); }
public static Object GetObjectPickerObject() { return(ObjectSelector.GetCurrentObject()); }
private void PreviewArea() { GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), string.Empty, this.m_Styles.previewBackground); if (this.m_ListArea.GetSelection().Length == 0) { return; } EditorWrapper editorWrapper = null; UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject(); if (this.m_PreviewSize < 75f) { string text; if (currentObject != null) { editorWrapper = this.m_EditorCache[currentObject]; string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name); if (editorWrapper != null) { text = editorWrapper.name + " (" + str + ")"; } else { text = currentObject.name + " (" + str + ")"; } text = text + " " + AssetDatabase.GetAssetPath(currentObject); } else { text = "None"; } this.LinePreview(text, currentObject, editorWrapper); } else { if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } string text3; if (currentObject != null) { editorWrapper = this.m_EditorCache[currentObject]; string text2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name); if (editorWrapper != null) { text3 = editorWrapper.GetInfoString(); if (text3 != string.Empty) { text3 = string.Concat(new string[] { editorWrapper.name, "\n", text2, "\n", text3 }); } else { text3 = editorWrapper.name + "\n" + text2; } } else { text3 = currentObject.name + "\n" + text2; } text3 = text3 + "\n" + AssetDatabase.GetAssetPath(currentObject); } else { text3 = "None"; } if (this.m_ShowWidePreview.faded != 0f) { GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded); this.WidePreview(this.m_PreviewSize, text3, currentObject, editorWrapper); } if (this.m_ShowOverlapPreview.faded != 0f) { GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded); this.OverlapPreview(this.m_PreviewSize, text3, currentObject, editorWrapper); } GUI.color = Color.white; this.m_EditorCache.CleanupUntouchedEditors(); } }
internal void Show(UnityEngine.Object obj, Type requiredType, SerializedProperty property, bool allowSceneObjects, List <int> allowedInstanceIDs) { this.m_AllowSceneObjects = allowSceneObjects; this.m_IsShowingAssets = true; this.m_AllowedIDs = allowedInstanceIDs; string text = string.Empty; if (property != null) { text = property.objectReferenceTypeString; obj = property.objectReferenceValue; UnityEngine.Object targetObject = property.serializedObject.targetObject; if (targetObject != null && EditorUtility.IsPersistent(targetObject)) { this.m_AllowSceneObjects = false; } } else { if (requiredType != null) { text = requiredType.Name; } } if (this.m_AllowSceneObjects) { if (obj != null) { if (typeof(Component).IsAssignableFrom(obj.GetType())) { obj = ((Component)obj).gameObject; } this.m_IsShowingAssets = (EditorUtility.IsPersistent(obj) || ObjectSelector.GuessIfUserIsLookingForAnAsset(text, false)); } else { this.m_IsShowingAssets = ObjectSelector.GuessIfUserIsLookingForAnAsset(text, true); } } else { this.m_IsShowingAssets = true; } this.m_DelegateView = GUIView.current; this.m_RequiredType = text; this.m_SearchFilter = string.Empty; this.m_OriginalSelection = obj; this.m_ModalUndoGroup = Undo.GetCurrentGroup(); ContainerWindow.SetFreezeDisplay(true); base.ShowWithMode(ShowMode.AuxWindow); base.title = "Select " + text; Rect position = this.m_Parent.window.position; position.width = EditorPrefs.GetFloat("ObjectSelectorWidth", 200f); position.height = EditorPrefs.GetFloat("ObjectSelectorHeight", 390f); base.position = position; base.minSize = new Vector2(200f, 335f); base.maxSize = new Vector2(10000f, 10000f); this.SetupPreview(); base.Focus(); ContainerWindow.SetFreezeDisplay(false); this.m_FocusSearchFilter = true; this.m_Parent.AddToAuxWindowList(); int num = (!(obj != null)) ? 0 : obj.GetInstanceID(); if (property != null && property.hasMultipleDifferentValues) { num = 0; } if (ObjectSelector.ShouldTreeViewBeUsed(text)) { this.m_ObjectTreeWithSearch.Init(base.position, this, new UnityAction <ObjectTreeForSelector.TreeSelectorData>(this.CreateAndSetTreeView), new UnityAction <TreeViewItem>(this.TreeViewSelection), new UnityAction(this.ItemWasDoubleClicked), num, 0); } else { this.InitIfNeeded(); this.m_ListArea.InitSelection(new int[] { num }); if (num != 0) { this.m_ListArea.Frame(num, true, false); } } }