private void OnLabelOverlayGUI(TreeViewItem item, Rect labelRect) { if (AssetsTreeViewGUI.postAssetLabelDrawCallback != null && AssetDatabase.IsMainAsset(item.id)) { string gUIDForInstanceID = AssetsTreeViewGUI.GetGUIDForInstanceID(item.id); AssetsTreeViewGUI.postAssetLabelDrawCallback(labelRect, gUIDForInstanceID); } }
public AssetsTreeViewGUI(TreeView treeView) : base(treeView) { AssetsTreeViewGUI assetsTreeViewGui = this; System.Action <TreeViewItem, Rect> action = assetsTreeViewGui.iconOverlayGUI + new System.Action <TreeViewItem, Rect>(this.OnIconOverlayGUI); assetsTreeViewGui.iconOverlayGUI = action; this.k_TopRowMargin = 4f; }
private void OnIconOverlayGUI(TreeViewItem item, Rect overlayRect) { if (AssetsTreeViewGUI.postAssetIconDrawCallback != null && AssetDatabase.IsMainAsset(item.id)) { string gUIDForInstanceID = AssetsTreeViewGUI.GetGUIDForInstanceID(item.id); AssetsTreeViewGUI.postAssetIconDrawCallback(overlayRect, gUIDForInstanceID); } if (AssetsTreeViewGUI.s_VCEnabled && AssetDatabase.IsMainAsset(item.id)) { string gUIDForInstanceID2 = AssetsTreeViewGUI.GetGUIDForInstanceID(item.id); ProjectHooks.OnProjectWindowItem(gUIDForInstanceID2, overlayRect); } }
private void OnIconOverlayGUI(TreeViewItem item, Rect overlayRect) { if (AssetsTreeViewGUI.postAssetIconDrawCallback != null && AssetDatabase.IsMainAsset(item.id)) { string assetPath = AssetDatabase.GetAssetPath(item.id); string guid = AssetDatabase.AssetPathToGUID(assetPath); AssetsTreeViewGUI.postAssetIconDrawCallback(overlayRect, guid); } if (AssetsTreeViewGUI.s_VCEnabled && AssetDatabase.IsMainAsset(item.id)) { string assetPath2 = AssetDatabase.GetAssetPath(item.id); string guid2 = AssetDatabase.AssetPathToGUID(assetPath2); ProjectHooks.OnProjectWindowItem(guid2, overlayRect); } }
public void PrefabStageHeaderGUI(Rect rect) { var currentItem = StageNavigationManager.instance.currentItem; if (currentItem.isMainStage) { Debug.LogError("Not a Prefab scene"); return; } var prefabStage = currentItem.prefabStage; if (prefabStage == null) { return; } // Cache header text if (m_PrefabHeaderContent == null || m_LastPrefabStageModifiedState == prefabStage.HasSceneBeenModified()) { CachePrefabHeaderText(currentItem); } m_LastPrefabStageModifiedState = prefabStage.HasSceneBeenModified(); // Background GUI.Label(rect, GUIContent.none, Styles.prefabHeaderBg); // Back button if (Event.current.type == EventType.Repaint) { Rect renderRect = new Rect( rect.x + Styles.leftArrow.margin.left, rect.y + (rect.height - Styles.leftArrow.fixedHeight) / 2, Styles.leftArrow.fixedWidth, Styles.leftArrow.fixedHeight); Styles.leftArrow.Draw(renderRect, GUIContent.none, false, false, false, false); } Rect interactionRect = new Rect( rect.x, rect.y, Styles.leftArrow.fixedWidth + Styles.leftArrow.margin.horizontal, rect.height); if (GUI.Button(interactionRect, GUIContent.none, GUIStyle.none)) { StageNavigationManager.instance.NavigateBack(StageNavigationManager.Analytics.ChangeType.NavigateBackViaHierarchyHeaderLeftArrow); } // Prefab icon and name EditorGUIUtility.SetIconSize(new Vector2(16, 16)); float width = TreeViewGUI.Styles.lineBoldStyle.CalcSize(m_PrefabHeaderContent).x; float xStart = Styles.leftArrow.margin.left + Styles.leftArrow.fixedWidth; float space = rect.width; float offsetFromStart = Mathf.Max(xStart, (space - width) / 2); Rect labelRect = new Rect(offsetFromStart, rect.y + 2, rect.width - xStart, 20); if (GUI.Button(labelRect, m_PrefabHeaderContent, currentItem.valid ? BreadcrumbBar.DefaultStyles.labelBold : BreadcrumbBar.DefaultStyles.labelBoldMissing)) { EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(prefabStage.prefabAssetPath)); } EditorGUIUtility.SetIconSize(Vector2.zero); // Version control overlay icons if (VersionControl.Provider.isActive) { Rect overlayRect = labelRect; overlayRect.width = 16; overlayRect.y += (overlayRect.height - 16) / 2; overlayRect.height = 16; AssetsTreeViewGUI.OnIconOverlayGUI(AssetDatabase.LoadMainAssetAtPath(currentItem.prefabAssetPath).GetInstanceID(), overlayRect, true); } }
public void StageHeaderGUI(Rect rect) { var stage = currentStage; if (stage == null || !stage.isValid) { return; } if (m_StageHeaderContent == GUIContent.none || m_LastStageUnsavedChangesState == stage.hasUnsavedChanges) { CacheStageHeaderContent(); } m_LastStageUnsavedChangesState = stage.hasUnsavedChanges; // Background GUI.Box(rect, GUIContent.none, Styles.stageHeaderBg); Rect interactionRect = new Rect( rect.x, rect.y, Styles.leftArrow.fixedWidth + Styles.leftArrow.margin.horizontal, rect.height - 1); /*bottom borer*/ // Back button if (Event.current.type == EventType.Repaint) { // Resets the fixed size to stretch the button float oldW = Styles.leftArrow.fixedWidth, oldH = Styles.leftArrow.fixedHeight; Styles.leftArrow.fixedWidth = 0; Styles.leftArrow.fixedHeight = 0; Styles.leftArrow.Draw(interactionRect, GUIContent.none, interactionRect.Contains(Event.current.mousePosition), false, false, false); Styles.leftArrow.fixedWidth = oldW; Styles.leftArrow.fixedHeight = oldH; } if (GUI.Button(interactionRect, GUIContent.none, GUIStyle.none)) { StageNavigationManager.instance.NavigateBack(StageNavigationManager.Analytics.ChangeType.NavigateBackViaHierarchyHeaderLeftArrow); } // Icon and name EditorGUIUtility.SetIconSize(new Vector2(16, 16)); float width = TreeViewGUI.Styles.lineBoldStyle.CalcSize(m_StageHeaderContent).x; float xStart = Styles.leftArrow.margin.left + Styles.leftArrow.fixedWidth; float space = rect.width; float offsetFromStart = Mathf.Max(xStart, (space - width) / 2); Rect labelRect = new Rect(offsetFromStart, rect.y + 2, rect.width - xStart, 20); if (GUI.Button(labelRect, m_StageHeaderContent, stage.isAssetMissing ? BreadcrumbBar.DefaultStyles.labelBoldMissing : BreadcrumbBar.DefaultStyles.labelBold)) { EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(stage.assetPath)); } EditorGUIUtility.SetIconSize(Vector2.zero); // Version control overlay icons if (VersionControl.Provider.isActive && EditorUserSettings.hierarchyOverlayIcons) { Rect overlayRect = labelRect; overlayRect.width = 16; overlayRect.y += (overlayRect.height - 16) / 2; overlayRect.height = 16; // The source asset could have been deleted while open inside the stage so the library object might be null here (case 1086613) var asset = AssetDatabase.LoadMainAssetAtPath(stage.assetPath); if (asset != null) { AssetsTreeViewGUI.OnIconOverlayGUI(asset.GetInstanceID(), overlayRect, true); } } }