protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging) { if (Event.current.type != EventType.Repaint) { return; } GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem == null) { return; } if (goItem.isSceneHeader) { if (goItem.scene.isDirty) { label += "*"; } switch (goItem.scene.loadingState) { case Scene.LoadingState.NotLoaded: label += " (not loaded)"; break; case Scene.LoadingState.Loading: label += " (is loading)"; break; } // Render disabled if scene is unloaded using (new EditorGUI.DisabledScope(!goItem.scene.isLoaded)) { base.OnContentGUI(rect, row, item, label, selected, focused, useBoldFont, isPinging); } return; } if (!isPinging) { // The rect is assumed indented and sized after the content when pinging rect.xMin += GetContentIndent(item) + extraSpaceBeforeIconAndLabel; } int colorCode = goItem.colorCode; GUIStyle lineStyle = Styles.lineStyle; if (SubSceneGUI.IsUsingSubScenes()) { useBoldFont = SubSceneGUI.UseBoldFontForGameObject((GameObject)goItem.objectPPTR); } if (useBoldFont) { lineStyle = Styles.lineBoldStyle; } else { if ((colorCode & 3) == (int)GameObjectColorType.Normal) { lineStyle = (colorCode < 4) ? Styles.lineStyle : GameObjectStyles.disabledLabel; } else if ((colorCode & 3) == (int)GameObjectColorType.Prefab) { lineStyle = (colorCode < 4) ? GameObjectStyles.prefabLabel : GameObjectStyles.disabledPrefabLabel; } else if ((colorCode & 3) == (int)GameObjectColorType.BrokenPrefab) { lineStyle = (colorCode < 4) ? GameObjectStyles.brokenPrefabLabel : GameObjectStyles.disabledBrokenPrefabLabel; } } lineStyle.padding.left = 0; if (goItem.icon != null) { Rect iconRect = rect; iconRect.width = k_IconWidth; bool renderDisabled = colorCode >= 4; Color col = GUI.color; if (renderDisabled) { col = new Color(1f, 1f, 1f, 0.5f); } GUI.DrawTexture(iconRect, goItem.icon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); if (goItem.overlayIcon != null) { GUI.DrawTexture(iconRect, goItem.overlayIcon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); } rect.xMin += iconTotalPadding + k_IconWidth + k_SpaceBetweenIconAndText; } // Draw text lineStyle.Draw(rect, label, false, false, selected, focused); }
protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging) { if (Event.current.type != EventType.Repaint) { return; } GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem == null) { return; } rect.xMax = m_ContentRectRight; if (goItem.isSceneHeader) { if (goItem.scene.isDirty) { label += "*"; } switch (goItem.scene.loadingState) { case Scene.LoadingState.NotLoaded: label += " (not loaded)"; break; case Scene.LoadingState.Loading: label += " (is loading)"; break; case Scene.LoadingState.Unloading: label += " (is unloading)"; break; } // Render disabled if scene is unloaded using (new EditorGUI.DisabledScope(!goItem.scene.isLoaded)) { base.OnContentGUI(rect, row, item, label, selected, focused, useBoldFont, isPinging); } return; } if (!isPinging) { // The rect is assumed indented and sized after the content when pinging rect.xMin += GetContentIndent(item) + extraSpaceBeforeIconAndLabel; } int colorCode = goItem.colorCode; bool renderDisabled = colorCode >= 4; lineStyle = Styles.lineStyle; if (SubSceneGUI.IsUsingSubScenes()) { useBoldFont = SubSceneGUI.UseBoldFontForGameObject((GameObject)goItem.objectPPTR); } if (useBoldFont) { lineStyle = Styles.lineBoldStyle; } else { GameObjectColorType objectColorType = (GameObjectColorType)(colorCode & 3); if (objectColorType == GameObjectColorType.Normal) { lineStyle = (renderDisabled) ? GameObjectStyles.disabledLabel : Styles.lineStyle; } else if (objectColorType == GameObjectColorType.Prefab) { lineStyle = (renderDisabled) ? GameObjectStyles.disabledPrefabLabel : GameObjectStyles.prefabLabel; } else if (objectColorType == GameObjectColorType.BrokenPrefab) { lineStyle = (renderDisabled) ? GameObjectStyles.disabledBrokenPrefabLabel : GameObjectStyles.brokenPrefabLabel; } } var sceneGUID = s_ActiveParentObjectPerSceneGUID.FirstOrDefault(x => x.Value == goItem.id).Key; if (!string.IsNullOrEmpty(sceneGUID) && (EditorSceneManager.GetActiveScene().guid == sceneGUID || PrefabStageUtility.GetCurrentPrefabStage() != null)) { lineStyle = Styles.lineBoldStyle; } lineStyle.padding.left = 0; Texture icon = GetEffectiveIcon(goItem, selected, focused); if (icon != null) { Rect iconRect = rect; iconRect.width = k_IconWidth; Color col = GUI.color; if (renderDisabled || (CutBoard.hasCutboardData && CutBoard.IsGameObjectPartOfCutAndPaste((GameObject)goItem.objectPPTR))) { col = new Color(1f, 1f, 1f, 0.5f); } GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); if (goItem.overlayIcon != null) { GUI.DrawTexture(iconRect, goItem.overlayIcon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); } if (!EditorApplication.isPlaying) { var vco = VersionControlManager.activeVersionControlObject; if (vco != null) { var extension = vco.GetExtension <IIconOverlayExtension>(); if (extension != null && m_HierarchyPrefabToAssetPathMap.TryGetValue(item.id, out var assetPath)) { iconRect.x -= 10; iconRect.width += 7 * 2; extension.DrawOverlay(assetPath, IconOverlayType.Hierarchy, iconRect); } } else { Asset[] assets; m_HierarchyPrefabToAssetIDMap.TryGetValue(item.id, out assets); if (assets != null) { iconRect.x -= 10; iconRect.width += 7 * 2; Overlay.DrawHierarchyOverlay(assets[0], assets[1], iconRect); } } } rect.xMin += iconTotalPadding + k_IconWidth + k_SpaceBetweenIconAndText; } // Draw text lineStyle.Draw(rect, label, false, false, selected, focused); }
protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging) { if (Event.current.type != EventType.Repaint) { return; } GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem == null) { return; } rect.xMax = m_ContentRectRight; if (goItem.isSceneHeader) { if (goItem.scene.isDirty) { label += "*"; } switch (goItem.scene.loadingState) { case Scene.LoadingState.NotLoaded: label += " (not loaded)"; break; case Scene.LoadingState.Loading: label += " (is loading)"; break; } // Render disabled if scene is unloaded using (new EditorGUI.DisabledScope(!goItem.scene.isLoaded)) { base.OnContentGUI(rect, row, item, label, selected, focused, useBoldFont, isPinging); } return; } if (!isPinging) { // The rect is assumed indented and sized after the content when pinging rect.xMin += GetContentIndent(item) + extraSpaceBeforeIconAndLabel; } int colorCode = goItem.colorCode; lineStyle = Styles.lineStyle; if (SubSceneGUI.IsUsingSubScenes()) { useBoldFont = SubSceneGUI.UseBoldFontForGameObject((GameObject)goItem.objectPPTR); } if (useBoldFont) { lineStyle = Styles.lineBoldStyle; } else { if ((colorCode & 3) == (int)GameObjectColorType.Normal) { lineStyle = (colorCode < 4) ? Styles.lineStyle : GameObjectStyles.disabledLabel; } else if ((colorCode & 3) == (int)GameObjectColorType.Prefab) { lineStyle = (colorCode < 4) ? GameObjectStyles.prefabLabel : GameObjectStyles.disabledPrefabLabel; } else if ((colorCode & 3) == (int)GameObjectColorType.BrokenPrefab) { lineStyle = (colorCode < 4) ? GameObjectStyles.brokenPrefabLabel : GameObjectStyles.disabledBrokenPrefabLabel; } } if (activeParentObjects.ContainsValue(goItem.id)) { lineStyle = Styles.lineBoldStyle; } lineStyle.padding.left = 0; Texture icon = GetEffectiveIcon(goItem); if (icon != null) { Rect iconRect = rect; iconRect.width = k_IconWidth; bool renderDisabled = colorCode >= 4; Color col = GUI.color; if (renderDisabled || (CutBoard.hasCutboardData && CutBoard.IsGameObjectPartOfCutAndPaste((GameObject)goItem.objectPPTR))) { col = new Color(1f, 1f, 1f, 0.5f); } GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); if (goItem.overlayIcon != null) { GUI.DrawTexture(iconRect, goItem.overlayIcon, ScaleMode.ScaleToFit, true, 0, col, 0, 0); } if (!EditorApplication.isPlaying) { Asset[] assets; m_HierarchyPrefabToAssetIDMap.TryGetValue(item.id, out assets); if (assets != null) { iconRect.x -= 10; iconRect.width += 7 * 2; Overlay.DrawHierarchyOverlay(assets[0], assets[1], iconRect); } } rect.xMin += iconTotalPadding + k_IconWidth + k_SpaceBetweenIconAndText; } // Draw text lineStyle.Draw(rect, label, false, false, selected, focused); }