public override void OnPreviewGUI(Rect r, GUIStyle background) { var layoutDropdown = new Rect(r.x + 5, r.y + 5, r.width - 10, 20); var layoutImage = new Rect(r.x, layoutDropdown.yMax + 5, r.width, r.yMax - layoutDropdown.yMax - 5); var currentChannel = _currentPreviewChannels[target]; currentChannel = SirenixEditorFields.Dropdown(layoutDropdown, currentChannel, target.GetChannelIdentifiers()); if (target.GetImage(currentChannel)?.Texture != null) { var image = target.GetImage(currentChannel); var s = new GUIStyle { normal = { textColor = Color.white }, alignment = TextAnchor.MiddleCenter, fontSize = r.width > 200 ? 12 : 10 }; GUI.DrawTexture(layoutImage.SubYMax(s.fontSize * 1.5f), image.Texture, ScaleMode.ScaleToFit, true); GUI.Box(layoutImage.AlignBottom(s.fontSize * 1.5f), $"{image.Width} x {image.Height} {image.Format} Image", s); } else { var s = new GUIStyle { normal = { textColor = Color.gray }, alignment = TextAnchor.MiddleCenter }; GUI.Box(layoutImage, "Empty Image", s); } _currentPreviewChannels[target] = currentChannel; }
/// <summary> /// Draws the graphics for a DropZone. /// </summary> public static void DrawDropZone(Rect rect, object value, GUIContent label, int id) { bool isDragging = IsDragging; if (Event.current.type == EventType.Repaint) { var objectToPaint = value as UnityEngine.Object; var objectFieldThumb = EditorStyles.objectFieldThumb; var on = GUI.enabled && hoveringAcceptedDropZone == id && rect.Contains(Event.current.mousePosition) && isDragging; objectFieldThumb.Draw(rect, GUIContent.none, id, on); if (EditorGUI.showMixedValue) { GUI.Label(rect, SirenixEditorGUI.MixedValueDashChar, SirenixGUIStyles.LabelCentered); } else if (objectToPaint) { Texture image = null; var rt = objectToPaint as RenderTexture; if (rt) { image = rt; } var img = objectToPaint as UnityEngine.UI.Image; if (img) { objectToPaint = img.sprite; } var rawImg = objectToPaint as UnityEngine.UI.RawImage; if (rawImg) { image = rawImg.texture; } if (image == null) { image = GUIHelper.GetAssetThumbnail(objectToPaint, objectToPaint.GetType(), true); } rect = rect.Padding(2); float size = Mathf.Min(rect.width, rect.height); EditorGUI.DrawTextureTransparent(rect.AlignCenter(size, size), image, ScaleMode.ScaleToFit); if (label != null) { rect = rect.AlignBottom(16); GUI.Label(rect, label, EditorStyles.label); } } } }
internal static void DrawAboutGUI() { #if ODIN_TRIAL_VERSION Rect position = new Rect(EditorGUILayout.GetControlRect()) { height = 110f }; #else Rect position = new Rect(EditorGUILayout.GetControlRect()) { height = 90f }; #endif // Logo GUI.DrawTexture(position.SetWidth(86).SetHeight(75).AddY(4).AddX(-5), EditorIcons.OdinInspectorLogo, ScaleMode.ScaleAndCrop); // About GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 0f - 2f, height = 18f, }, OdinInspectorVersion.Version, SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 1f - 2f, height = 18f, }, "Developed by Sirenix", SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 2f - 2f, height = 18f, }, "Published by DevDog", SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 3f - 2f, height = 18f, }, "All rights reserved", SirenixGUIStyles.LeftAlignedGreyMiniLabel); // Links DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 0f, width = 95f, height = 14f, }, "www.sirenix.net", "http://sirenix.net", EditorStyles.miniButton); DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 1f, width = 95f, height = 14f, }, "www.devdog.io", "http://devdog.io", EditorStyles.miniButton); #if ODIN_TRIAL_VERSION if (GUI.Button(position.AlignBottom(20), " Purchase Odin Inspector & Serializer")) { Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/content/89041"); } #endif }
[Test] public void Alignment() { Assert.AreEqual(new Rect(-5, -5, 10, 10), Rect.AlignCenter(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, -5, 10, 10), Rect.AlignLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, -5, 10, 10), Rect.AlignRight(0, 0, 10, 10)); Assert.AreEqual(new Rect(-5, 0, 10, 10), Rect.AlignTop(0, 0, 10, 10)); Assert.AreEqual(new Rect(-5, -10, 10, 10), Rect.AlignBottom(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, 0, 10, 10), Rect.AlignTopLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, 0, 10, 10), Rect.AlignTopRight(0, 0, 10, 10)); Assert.AreEqual(new Rect(0, -10, 10, 10), Rect.AlignBottomLeft(0, 0, 10, 10)); Assert.AreEqual(new Rect(-10, -10, 10, 10), Rect.AlignBottomRight(0, 0, 10, 10)); }
/// <summary> /// Draws the graphics for a DropZone. /// </summary> public static void DrawDropZone(Rect rect, object value, GUIContent label, int id) { bool isDragging = IsDragging; if (Event.current.type == EventType.Repaint) { var unityObject = value as UnityEngine.Object; var objectFieldThumb = EditorStyles.objectFieldThumb; var on = GUI.enabled && isHoveringAcceptedDropZone && rect.Contains(Event.current.mousePosition) && isDragging; objectFieldThumb.Draw(rect, GUIContent.none, id, on); if (EditorGUI.showMixedValue) { GUI.Label(rect, "—", SirenixGUIStyles.LabelCentered); } else if (unityObject) { if (unityObject is Component) { unityObject = (unityObject as Component).gameObject; } Texture image; image = AssetPreview.GetAssetPreview(unityObject); if (image == null) { image = AssetPreview.GetMiniThumbnail(unityObject); } rect = rect.Padding(2); float size = Mathf.Min(rect.width, rect.height); EditorGUI.DrawTextureTransparent(rect.AlignCenter(size, size), image, ScaleMode.ScaleToFit); if (label != null) { rect = rect.AlignBottom(16); GUI.Label(rect, label, EditorStyles.label); } } } }
private void DrawRows(Rect rect, IPropertyValueEntry <TArray> entry, Context context, int rowIndex) { if (rowIndex < context.RowCount) { GUI.Label(rect, rowIndex.ToString(), SirenixGUIStyles.LabelCentered); // Handle Row dragging. if (!context.Attribute.IsReadOnly) { var id = GUIUtility.GetControlID(FocusType.Passive); if (GUI.enabled && Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) { GUIHelper.RemoveFocusControl(); GUIUtility.hotControl = id; EditorGUIUtility.SetWantsMouseJumping(1); Event.current.Use(); context.RowDragFrom = rowIndex; context.RowDragTo = rowIndex; context.dragStartPos = Event.current.mousePosition; } else if (GUIUtility.hotControl == id) { if ((context.dragStartPos - Event.current.mousePosition).sqrMagnitude > 5 * 5) { context.IsDraggingRow = true; } if (Event.current.type == EventType.MouseDrag) { Event.current.Use(); } else if (Event.current.type == EventType.MouseUp) { GUIUtility.hotControl = 0; EditorGUIUtility.SetWantsMouseJumping(0); Event.current.Use(); context.IsDraggingRow = false; ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.MoveRow(arr, context.RowDragFrom, context.RowDragTo)); } } if (context.IsDraggingRow && Event.current.type == EventType.Repaint) { float mouseY = Event.current.mousePosition.y; if (mouseY > rect.y - 1 && mouseY < rect.y + rect.height + 1) { Rect arrowRect; if (mouseY > rect.y + rect.height * 0.5f) { arrowRect = rect.AlignBottom(16); arrowRect.width = 16; arrowRect.y += 8; arrowRect.x -= 13; context.RowDragTo = rowIndex; } else { arrowRect = rect.AlignTop(16); arrowRect.width = 16; arrowRect.y -= 8; arrowRect.x -= 13; context.RowDragTo = rowIndex - 1; } entry.Property.Tree.DelayActionUntilRepaint(() => { //GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; GUI.DrawTexture(arrowRect, EditorIcons.ArrowRight.Active); //GL.sRGBWrite = false; var lineRect = arrowRect; lineRect.y = lineRect.center.y - 2 + 1; lineRect.height = 3; lineRect.x += 14; lineRect.xMax = context.Table.TableRect.xMax; EditorGUI.DrawRect(lineRect, new Color(0, 0, 0, 0.6f)); }); } if (rowIndex == context.RowCount - 1) { entry.Property.Tree.DelayActionUntilRepaint(() => { var cell = context.Table[context.Table.ColumnCount - 1, context.Table.RowCount - context.RowCount + context.RowDragFrom]; var rowRect = cell.Rect; rowRect.xMin = rect.xMin; SirenixEditorGUI.DrawSolidRect(rowRect, new Color(0, 0, 0, 0.2f)); }); } } } } else { GUI.Label(rect, "...", EditorStyles.centeredGreyMiniLabel); } if (!context.Attribute.IsReadOnly && Event.current.type == EventType.MouseDown && Event.current.button == 1 && rect.Contains(Event.current.mousePosition)) { Event.current.Use(); GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Insert 1 above"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneRowAbove(arr, rowIndex))); menu.AddItem(new GUIContent("Insert 1 below"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneRowBelow(arr, rowIndex))); menu.AddItem(new GUIContent("Duplicate"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DuplicateRow(arr, rowIndex))); menu.AddSeparator(""); menu.AddItem(new GUIContent("Delete"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DeleteRow(arr, rowIndex))); menu.ShowAsContext(); } }
internal static void DrawAboutGUI() { #if ODIN_TRIAL_VERSION Rect position = new Rect(EditorGUILayout.GetControlRect()) { height = 110f }; #else Rect position = new Rect(EditorGUILayout.GetControlRect()) { height = 90f }; #endif // Logo GUI.DrawTexture(position.SetWidth(86).SetHeight(75).AddY(4).AddX(-5), EditorIcons.OdinInspectorLogo, ScaleMode.ScaleAndCrop); // About #if ODIN_TRIAL_VERSION string version = "Version: " + typeof(InspectorConfig).Assembly.GetName(false).Version.ToString() + " (Trial)"; #else string version = "Version: " + typeof(InspectorConfig).Assembly.GetName(false).Version.ToString(); #endif GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 0f - 2f, height = 18f, }, version, SirenixGUIStyles.LeftAlignedGreyMiniLabel); //DrawLink(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 1f - 2f, height = 18f, }, "Developed by Sirenix", "http://www.sirenix.net", SirenixGUIStyles.LeftAlignedGreyMiniLabel); //DrawLink(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 2f - 2f, height = 18f, }, "Published by DevDog", "http://www.devdog.io", SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 1f - 2f, height = 18f, }, "Developed by Sirenix", SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 2f - 2f, height = 18f, }, "Published by DevDog", SirenixGUIStyles.LeftAlignedGreyMiniLabel); GUI.Label(new Rect(position) { x = position.x + 82f, y = position.y + 20f * 3f - 2f, height = 18f, }, "All rights reserved", SirenixGUIStyles.LeftAlignedGreyMiniLabel); //"" // Links DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 0f, width = 95f, height = 14f, }, "Manuals", "http://sirenix.net/odininspector/manual/introduction/getting-started", EditorStyles.miniButton); DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 1f, width = 95f, height = 14f, }, "Documentation", "http://sirenix.net/odininspector/documentation", EditorStyles.miniButton); DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 2f, width = 95f, height = 14f, }, "Forums", "https://forum.unity3d.com/threads/wip-odin-inspector-serializer-looking-for-feedback.457670/", EditorStyles.miniButton); DrawLink(new Rect(position) { x = position.xMax - 95f, y = position.y + 20f * 3f, width = 95f, height = 14f, }, "Issue tracker", "https://bitbucket.org/sirenix/odin-inspector/issues?status=new&status=open", EditorStyles.miniButton); #if ODIN_TRIAL_VERSION if (GUI.Button(position.AlignBottom(20), " Purchase Odin Inspector & Serializer")) { Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/content/89041"); } #endif }
private void Game(GameContext game) { Rect rect = EditorGUILayout.GetControlRect(true, TileSize * BoardSize + 20); rect = rect.AlignCenter(TileSize * BoardSize); // Toolbar { SirenixEditorGUI.DrawSolidRect(rect.AlignTop(20), new Color(0.5f, 0.5f, 0.5f, 1f)); SirenixEditorGUI.DrawBorders(rect.AlignTop(20).SetHeight(21).SetWidth(rect.width + 1), 1); if (Event.current.type == EventType.Repaint && !game.GameOver) { double t = EditorApplication.timeSinceStartup; game.Time += t - game.PrevTime; game.PrevTime = t; } var time = GUIHelper.TempContent(((int)game.Time).ToString()); GUIHelper.PushContentColor(Color.black); GUI.Label(rect.AlignTop(20).HorizontalPadding(4).AlignMiddle(18).AlignRight(EditorStyles.label.CalcSize(time).x), time); GUIHelper.PopContentColor(); GUI.Label(rect.AlignTop(20).AlignCenter(20), EditorIcons.PacmanGhost.ActiveGUIContent); if (game.GameOver) { GUIHelper.PushContentColor(game.FlaggedBombs == game.NumberOfBombs ? Color.green : Color.red); GUI.Label(rect.AlignTop(20).HorizontalPadding(4).AlignMiddle(18), game.FlaggedBombs == game.NumberOfBombs ? "You win!" : "Game over!"); GUIHelper.PopContentColor(); } } rect = rect.AlignBottom(rect.height - 20); SirenixEditorGUI.DrawSolidRect(rect, new Color(0.7f, 0.7f, 0.7f, 1f)); for (int i = 0; i < BoardSize * BoardSize; i++) { Rect tileRect = rect.SplitGrid(TileSize, TileSize, i); SirenixEditorGUI.DrawBorders(tileRect.SetWidth(tileRect.width + 1).SetHeight(tileRect.height + 1), 1); int x = i % BoardSize; int y = i / BoardSize; var tile = game.Tiles[x, y]; var visible = game.VisibleTiles[x, y]; if (game.GameOver || visible == Tile.Open) { SirenixEditorGUI.DrawSolidRect(new Rect(tileRect.x + 1, tileRect.y + 1, tileRect.width - 1, tileRect.height - 1), new Color(0.3f, 0.3f, 0.3f, 1f)); } if ((game.GameOver || visible == Tile.Open) && tile == Tile.Bomb) { GUIHelper.PushColor(visible == Tile.Flag ? Color.black : Color.white); GUI.Label(tileRect.AlignCenter(18).AlignMiddle(18), EditorIcons.SettingsCog.ActiveGUIContent); GUIHelper.PopColor(); } if (visible == Tile.Flag) { GUIHelper.PushColor(Color.red); GUI.Label(tileRect.AlignCenter(18).AlignMiddle(18), EditorIcons.Flag.ActiveGUIContent); GUIHelper.PopColor(); } if ((game.GameOver || visible == Tile.Open) && (int)tile >= 1 && (int)tile <= 8) { GUIHelper.PushColor(this.NumberColors[(int)tile - 1]); GUI.Label(tileRect.AlignCenter(18).AlignCenter(18).AddX(2).AddY(2), ((int)tile).ToString(), EditorStyles.boldLabel); GUIHelper.PopColor(); } if (!game.GameOver && tileRect.Contains(Event.current.mousePosition)) { SirenixEditorGUI.DrawSolidRect(new Rect(tileRect.x + 1, tileRect.y + 1, tileRect.width - 1, tileRect.height - 1), new Color(0f, 1f, 0f, 0.3f)); // Input // Reveal if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (visible != Tile.Flag) { if (tile == Tile.Bomb) { // LOSE game.GameOver = true; SirenixEditorGUI.StartShakingGroup(game.Key, 3f); } else { this.Reveal(game, x, y); } } Event.current.Use(); } // Place flag else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { if (visible == Tile.None) { game.VisibleTiles[x, y] = Tile.Flag; if (tile == Tile.Bomb) { game.FlaggedBombs++; if (game.FlaggedBombs == game.NumberOfBombs) { game.GameOver = true; } } } else if (visible == Tile.Flag) { game.VisibleTiles[x, y] = Tile.None; if (tile == Tile.Bomb) { game.FlaggedBombs--; } } Event.current.Use(); } } } GUIHelper.RequestRepaint(); }
/// <summary> /// Draws a objectpicker butter, in the given rect. This one is designed to look good on top of DrawDropZone(). /// </summary> public static object ObjectPickerZone(Rect rect, object value, Type type, bool allowSceneObjects, int id) { var btnId = GUIUtility.GetControlID(FocusType.Passive); var objectPicker = ObjectPicker.GetObjectPicker(type.FullName + "+" + btnId, type); var selectRect = rect.AlignBottom(15).AlignCenter(45); var uObj = value as UnityEngine.Object; selectRect.xMin = Mathf.Max(selectRect.xMin, rect.xMin); var hide = IsDragging || Event.current.type == EventType.Repaint && !rect.Contains(Event.current.mousePosition); if (hide) { GUIHelper.PushColor(new Color(0, 0, 0, 0)); GUIHelper.PushGUIEnabled(false); } bool hideInspectorBtn = !hide && !(uObj); if (hideInspectorBtn) { GUIHelper.PushGUIEnabled(false); GUIHelper.PushColor(new Color(0, 0, 0, 0)); } var inspectBtn = rect.AlignRight(14); inspectBtn.height = 14; SirenixEditorGUI.BeginDrawOpenInspector(inspectBtn, uObj, rect); SirenixEditorGUI.EndDrawOpenInspector(inspectBtn, uObj); if (hideInspectorBtn) { GUIHelper.PopColor(); GUIHelper.PopGUIEnabled(); } if (GUI.Button(selectRect, "select", SirenixGUIStyles.TagButton)) { GUIHelper.RemoveFocusControl(); objectPicker.ShowObjectPicker(allowSceneObjects, rect, false); Event.current.Use(); } if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id) { objectPicker.ShowObjectPicker(allowSceneObjects, rect, false); Event.current.Use(); } if (hide) { GUIHelper.PopColor(); GUIHelper.PopGUIEnabled(); } if (objectPicker.IsReadyToClaim) { GUIHelper.RequestRepaint(); GUI.changed = true; var newValue = objectPicker.ClaimObject(); Event.current.Use(); return(newValue); } if (Event.current.keyCode == KeyCode.Delete && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id) { Event.current.Use(); GUI.changed = true; return(null); } if (uObj && Event.current.type == EventType.MouseUp && rect.Contains(Event.current.mousePosition) && EditorGUIUtility.hotControl == id && Event.current.button == 0) { EditorGUIUtility.PingObject(uObj); } return(value); }
/// <summary> /// Draws the graphics for a DropZone. /// </summary> public static void DrawDropZone(Rect rect, object value, GUIContent label, int id) { bool isDragging = IsDragging; if (Event.current.type == EventType.Repaint) { var objectToPaint = value as UnityEngine.Object; var objectFieldThumb = EditorStyles.objectFieldThumb; var on = GUI.enabled && hoveringAcceptedDropZone == id && rect.Contains(Event.current.mousePosition) && isDragging; objectFieldThumb.Draw(rect, GUIContent.none, id, on); if (EditorGUI.showMixedValue) { GUI.Label(rect, SirenixEditorGUI.MixedValueDashChar, SirenixGUIStyles.LabelCentered); } else if (objectToPaint) { Texture image = null; var rt = objectToPaint as RenderTexture; if (rt) { image = rt; } // Weakly typed, check if it's a UnityEngine.UI.Image instance and paint its sprite, if so. // This is weakly typed because we can no longer safely reference the UnityEngine.UI assembly. { if (Type_UnityEngine_UI_Image != null && Property_UnityEngine_UI_Image_Sprite != null && Type_UnityEngine_UI_Image.IsAssignableFrom(objectToPaint.GetType())) { objectToPaint = (UnityEngine.Object)Property_UnityEngine_UI_Image_Sprite.GetValue(objectToPaint, null); } // This was the old code for the above section: //var img = objectToPaint as UnityEngine.UI.Image; //if (img) //{ // objectToPaint = img.sprite; //} } // Weakly typed, check if it's a UnityEngine.UI.RawImage instance and paint its texture, if so. // This is weakly typed because we can no longer safely reference the UnityEngine.UI assembly. { if (Type_UnityEngine_UI_RawImage != null && Property_UnityEngine_UI_RawImage_Texture != null && Type_UnityEngine_UI_RawImage.IsAssignableFrom(objectToPaint.GetType())) { image = (Texture)Property_UnityEngine_UI_RawImage_Texture.GetValue(objectToPaint, null); } // This was the old code for the above section: //var rawImg = objectToPaint as UnityEngine.UI.RawImage; //if (rawImg) //{ // image = rawImg.texture; //} } if (image == null) { image = GUIHelper.GetAssetThumbnail(objectToPaint, objectToPaint.GetType(), true); } rect = rect.Padding(2); float size = Mathf.Min(rect.width, rect.height); EditorGUI.DrawTextureTransparent(rect.AlignCenter(size, size), image, ScaleMode.ScaleToFit); if (label != null) { rect = rect.AlignBottom(16); GUI.Label(rect, label, EditorStyles.label); } } } }
/// <summary> /// Draws a objectpicker button in the given rect. This one is designed to look good on top of DrawDropZone(). /// </summary> public static object ObjectPickerZone(Rect rect, object value, Type type, bool allowSceneObjects, int id) { // TODO: btnId wasn't used, but the GetControlID call is probably still important. //var btnId = GUIUtility.GetControlID(FocusType.Passive); GUIUtility.GetControlID(FocusType.Passive); var objectPicker = ObjectPicker.GetObjectPicker(type.FullName + "+" + GUIHelper.CurrentWindowInstanceID.ToString() + "+" + id, type); var selectRect = rect.AlignBottom(15).AlignCenter(45); var uObj = value as UnityEngine.Object; selectRect.xMin = Mathf.Max(selectRect.xMin, rect.xMin); var hide = IsDragging || Event.current.type == EventType.Repaint && !rect.Contains(Event.current.mousePosition); if (hide) { GUIHelper.PushColor(new Color(0, 0, 0, 0)); GUIHelper.PushGUIEnabled(false); } bool hideInspectorBtn = !hide && !(uObj); if (hideInspectorBtn) { GUIHelper.PushGUIEnabled(false); GUIHelper.PushColor(new Color(0, 0, 0, 0)); } var inspectBtn = rect.AlignRight(14); inspectBtn.height = 14; SirenixEditorGUI.BeginDrawOpenInspector(inspectBtn, uObj, rect); SirenixEditorGUI.EndDrawOpenInspector(inspectBtn, uObj); if (hideInspectorBtn) { GUIHelper.PopColor(); GUIHelper.PopGUIEnabled(); } if (GUI.Button(selectRect, "select", SirenixGUIStyles.TagButton)) { GUIHelper.RemoveFocusControl(); objectPicker.ShowObjectPicker(value, allowSceneObjects, rect, false); Event.current.Use(); } if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id) { objectPicker.ShowObjectPicker(value, allowSceneObjects, rect, false); Event.current.Use(); } if (hide) { GUIHelper.PopColor(); GUIHelper.PopGUIEnabled(); } if (objectPicker.IsReadyToClaim) { GUIHelper.RequestRepaint(); GUI.changed = true; var newValue = objectPicker.ClaimObject(); Event.current.Use(); return(newValue); } if (objectPicker.IsPickerOpen && typeof(UnityEngine.Object).IsAssignableFrom(type)) { return(objectPicker.CurrentSelectedObject); } if (Event.current.keyCode == KeyCode.Delete && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id) { Event.current.Use(); GUI.changed = true; return(null); } if (uObj && Event.current.rawType == EventType.MouseUp && rect.Contains(Event.current.mousePosition) && Event.current.button == 0) { // For components ping the attached game object instead, because then Unity can figure out to ping prefabs in the project window too. UnityEngine.Object pingObj = uObj; if (pingObj is Component) { pingObj = (pingObj as Component).gameObject; } EditorGUIUtility.PingObject(pingObj); } return(value); }