/// <inheritdoc /> protected override void DrawHeaderBase(Rect position) { HandlePrefixHighlightingForFilter(position, 55f, 4f); var headerEditor = HeaderEditor; #if SAFE_MODE // I think that Editor was once null when creating a build if (headerEditor == null) { return; } #endif var drawnRect = EditorGUIDrawer.AssetHeader(position, headerEditor); if (!headerHeightDetermined && Event.current.type == EventType.Repaint) { if (headerHeight != drawnRect.height) { if (drawnRect.height >= DrawGUI.SingleLineHeight) { headerHeight = drawnRect.height; } else { headerHeight = DrawGUI.Active.AssetTitlebarHeight(false); } } headerHeightDetermined = true; } }
protected override void DrawHeaderBase(Rect position) { HandlePrefixHighlightingForFilter(position, 55f, 4f); if (editor == null) { Editors.GetEditor(ref editor, Target); } Rect drawnRect; bool setHeaderHeightDetermined = headerHeightDetermined; try { drawnRect = EditorGUIDrawer.AssetHeader(position, editor, ref headerHeightDetermined); } #if DEV_MODE catch (MissingReferenceException e) // asset has probably been moved or destroyed { Debug.LogError(e); #else catch (MissingReferenceException) { #endif inspector.ForceRebuildDrawers(); ExitGUIUtility.ExitGUI(); return; } if (!headerHeightDetermined && setHeaderHeightDetermined) { headerHeightDetermined = true; if (headerHeight != drawnRect.height) { if (drawnRect.height >= DrawGUI.SingleLineHeight) { #if DEV_MODE Debug.Log(ToString() + ".headerHeight = " + drawnRect.height); #endif headerHeight = drawnRect.height; } else { #if DEV_MODE Debug.Log(ToString() + ".headerHeight = " + DrawGUI.Active.AssetTitlebarHeight(HeaderHasTwoRowsOfButtons)); #endif headerHeight = DrawGUI.Active.AssetTitlebarHeight(HeaderHasTwoRowsOfButtons); } } } }
//private Rect? assetHeaderDetectedHeight; #if UNITY_EDITOR protected override void DrawHeaderBase(Rect position) { HandlePrefixHighlightingForFilter(position, 55f, 4f); if (editor == null) { Editors.GetEditor(ref editor, Target); } Rect drawnRect; try { drawnRect = EditorGUIDrawer.AssetHeader(position, editor); } #if DEV_MODE catch (MissingReferenceException e) // asset has probably been moved or destroyed { Debug.LogError(e); #else catch (MissingReferenceException) { #endif inspector.ForceRebuildDrawers(); ExitGUIUtility.ExitGUI(); return; } if (!headerHeightDetermined && Event.current.type == EventType.Repaint) { if (headerHeight != drawnRect.height) { #if DEV_MODE Debug.Log(GetType().Name + " header GetLastRect " + drawnRect + " vs position " + position); #endif OnNextLayout(() => { if (drawnRect.height >= DrawGUI.SingleLineHeight) { headerHeight = drawnRect.height; } else { headerHeight = DrawGUI.Active.AssetTitlebarHeight(false); } }); } headerHeightDetermined = true; } }
public Rect Draw(Rect position) { #if UNITY_EDITOR if (Platform.EditorMode) { bool headerHeightDetermined = true; var actualDrawnPosition = EditorGUIDrawer.AssetHeader(position, editor, ref headerHeightDetermined); #if UNITY_2018_3_OR_NEWER if (isPrefab) { const float padding = 3f; const float doublePadding = padding + padding; position.y += position.height - OpenInPrefabModeButtonHeight + padding; position.height = OpenInPrefabModeButtonHeight - doublePadding; DrawGUI.Active.ColorRect(position, InspectorUtility.Preferences.theme.AssetHeaderBackground); position.x += padding; position.width -= doublePadding; // UPDATE: even if prefab is being drawn in grayed out color // due to being inactive, draw the open prefab button without // being grayed out, to make it clear that it remains usable. var guiColorWas = GUI.color; var setColor = guiColorWas; setColor.a = 1f; GUI.color = setColor; if (GUI.Button(position, OpenPrefabButtonLabel)) { DrawGUI.UseEvent(); GameObjectDrawer.OpenPrefab(targets[0]); } GUI.color = guiColorWas; actualDrawnPosition.height += OpenInPrefabModeButtonHeight; } #endif return(actualDrawnPosition); } #endif DrawGUI.Runtime.GameObjectHeader(position, targets[0]); return(position); }
/// <inheritdoc /> protected override void DrawHeaderBase(Rect position) { HandlePrefixHighlightingForFilter(position, 55f, 4f); var headerEditor = HeaderEditor; #if SAFE_MODE // I think that Editor was once null when creating a build if (headerEditor == null) { return; } #endif bool setHeaderHeightDetermined = headerHeightDetermined; var drawnRect = EditorGUIDrawer.AssetHeader(position, headerEditor, ref setHeaderHeightDetermined); if (!headerHeightDetermined && setHeaderHeightDetermined) { headerHeightDetermined = true; if (headerHeight != drawnRect.height) { if (drawnRect.height >= DrawGUI.SingleLineHeight) { #if DEV_MODE Debug.Log(ToString() + ".headerHeight = " + drawnRect.height); #endif headerHeight = drawnRect.height; } else { #if DEV_MODE Debug.Log(ToString() + ".headerHeight = " + DrawGUI.Active.AssetTitlebarHeight(HeaderHasTwoRowsOfButtons)); #endif headerHeight = DrawGUI.Active.AssetTitlebarHeight(HeaderHasTwoRowsOfButtons); } } } }