internal static void CopyGO() { CutBoard.Reset(); FilterSelection(canCopyGameObject); copyingGameObjects?.Invoke(Selection.gameObjects); Unsupported.CopyGameObjectsToPasteboard(); }
internal static void CutGO() { FilterSelection(canCutGameObject); cuttingGameObjects?.Invoke(Selection.gameObjects); CutBoard.CutGO(); RepaintHierarchyWindowsAfterPaste(); }
internal static void ResetCutboardAndRepaintHierarchyWindows() { if (CutBoard.hasCutboardData) { CutBoard.Reset(); RepaintHierarchyWindowsAfterPaste(); } }
internal static void DuplicateGO(Transform fallbackParent) { CutBoard.Reset(); bool customParentIsSelected = GetIsCustomParentSelected(fallbackParent); Unsupported.DuplicateGameObjectsUsingPasteboard(); if (customParentIsSelected) { Selection.activeTransform.SetParent(fallbackParent, true); } }
internal static void PasteGO(Transform fallbackParent) { if (CutBoard.hasCutboardData) { CutBoard.PasteGameObjects(fallbackParent); } // If it is not a Cut operation, execute regular paste else { bool customParentIsSelected = GetIsCustomParentSelected(fallbackParent); Unsupported.PasteGameObjectsFromPasteboard(); if (customParentIsSelected) { Selection.activeTransform.SetParent(fallbackParent, true); } } }
internal static void PasteGOAsChild() { Transform[] selected = Selection.transforms; // paste as a child if a gameObject is selected if (selected.Length == 1) { Scene subScene = new Scene(); bool pasteToSubScene = false; bool isSubScene = false; // If target is subScene make sure we just move objects under subScene if (SubSceneGUI.IsSubSceneHeader(selected[0].gameObject)) { subScene = SubSceneGUI.GetSubScene(selected[0].gameObject); isSubScene = subScene.isSubScene; pasteToSubScene = subScene.IsValid(); } // handle paste after cut if (CutBoard.hasCutboardData) { if (pasteToSubScene) { if (subScene.handle != 0) { CutBoard.PasteToScene(subScene, selected[0]); pastedGameObjects?.Invoke(Selection.gameObjects); } } else if (!isSubScene) { CutBoard.PasteAsChildren(selected[0]); pastedGameObjects?.Invoke(Selection.gameObjects); } } // paste after copy else if (pasteToSubScene || !isSubScene) { Unsupported.PasteGameObjectsFromPasteboard(selected[0], pasteToSubScene ? subScene.handle : 0); pastedGameObjects?.Invoke(Selection.gameObjects); } } RepaintHierarchyWindowsAfterPaste(); }
internal static void PasteGOAsChild() { Transform[] selected = Selection.transforms; // paste as a child if a gameObject is selected if (selected.Length == 1) { // handle paste after cut if (CutBoard.hasCutboardData) { CutBoard.PasteAsChildren(selected[0]); } // paste after copy else { Unsupported.PasteGameObjectsFromPasteboard(selected[0]); } } RepaintHierarchyWindowsAfterPaste(); }
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); }
internal static void CopyGO() { CutBoard.Reset(); Unsupported.CopyGameObjectsToPasteboard(); }
internal static void CutGO() { CutBoard.CutGO(); RepaintHierarchyWindowsAfterPaste(); }
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; } } 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); } rect.xMin += iconTotalPadding + k_IconWidth + k_SpaceBetweenIconAndText; } // Draw text lineStyle.Draw(rect, label, false, false, selected, focused); }