void SetItemIcon(GameObjectTreeViewItem item) { var go = item.objectPPTR as GameObject; if (go == null) { if (IsPrefabStageHeader(item)) { string prefabAssetPath = PrefabStageUtility.GetCurrentPrefabStage().prefabAssetPath; item.icon = (Texture2D)AssetDatabase.GetCachedIcon(prefabAssetPath); } else { item.icon = GameObjectStyles.sceneAssetIcon; } } else { if (SubSceneGUI.IsSubSceneHeader(go)) { item.icon = GameObjectStyles.sceneAssetIcon; } else { item.icon = PrefabUtility.GetIconForGameObject(go); } } }
int GetDropTargetInstanceID(GameObjectTreeViewItem hierarchyTargetItem, DropPosition dropPosition) { if (SubSceneGUI.IsUsingSubScenes()) { var gameObjectDropTarget = hierarchyTargetItem.objectPPTR as GameObject; if (gameObjectDropTarget != null) { if (dropPosition == DropPosition.Above) { return(hierarchyTargetItem.id); } if (SubSceneGUI.IsSubSceneHeader(gameObjectDropTarget)) { Scene subScene = SubSceneGUI.GetSubScene(gameObjectDropTarget); if (subScene.IsValid()) { return(subScene.handle); } else { return(0); } } } } return(hierarchyTargetItem.id); }
public static bool CanMoveTransformToScene(Transform transform, Scene scene) { if (transform == null) { throw new ArgumentNullException("transform"); } if (!scene.IsValid()) { throw new ArgumentException("The scene is not valid", "scene"); } RefreshSubSceneInfo(); var subSceneInfo = SubSceneGUI.GetSubSceneInfo(scene); if (!subSceneInfo.isValid) { return(true); // scene is a root and is always valid to move into } if (transform == subSceneInfo.transform) { return(false); // cannot move a SubScene's transform parent into itself } return(CanSetNewParent(transform, subSceneInfo.transform)); }
static void RefreshSubSceneInfo() { if (SubSceneGUI.IsUsingSubScenes()) { SubSceneGUI.FetchSubSceneInfo(); } }
static void CreateEmptyChild(MenuCommand menuCommand) { var parent = menuCommand.context as GameObject; if (parent == null) { var activeGO = Selection.activeGameObject; if (activeGO != null && !EditorUtility.IsPersistent(activeGO)) { parent = activeGO; } } // If selected GameObject is a Sub Scene header, place GameObject in active scene // similar to what happens when other scene headers are selected. SceneHierarchyHooks.SubSceneInfo info = SubSceneGUI.GetSubSceneInfo(parent); if (info.isValid) { parent = null; } var go = ObjectFactory.CreateGameObject("GameObject"); Place(go, parent); }
protected override void OnAdditionalGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused) { GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem == null) { return; } m_ContentRectRight = 0; if (goItem.isSceneHeader) { m_ContentRectRight = DoAdditionalSceneHeaderGUI(goItem, rect); } else { m_ContentRectRight = PrefabModeButton(goItem, rect); if (SubSceneGUI.IsUsingSubScenes() && !showingSearchResults) { SubSceneGUI.DrawVerticalLine(rect, k_BaseIndent, k_IndentWidth, (GameObject)goItem.objectPPTR); } HandlePrefabInstanceOverrideStatus(goItem, rect, selected, focused); } if (SceneHierarchy.s_Debug) { GUI.Label(new Rect(rect.xMax - 70, rect.y, 70, rect.height), "" + row + " (" + goItem.id + ")", EditorStyles.boldLabel); } }
bool IsValidSubSceneDropTarget(int dropTargetGameObjectOrSceneInstanceID, DropPosition dropPosition, Object[] draggedObjects) { if (draggedObjects == null || draggedObjects.Length == 0) { return(false); } Transform parentForDrop = GetTransformParentForDrop(dropTargetGameObjectOrSceneInstanceID, dropPosition); if (parentForDrop == null) { // Drop is on a root scene which is always allowed return(true); } foreach (var obj in draggedObjects) { var gameObject = obj as GameObject; if (gameObject == null) { continue; } // Require all dragged objects to be valid (since native cannot filter out invalid sub scene drags currently) if (SubSceneGUI.IsChildOrSameAsOtherTransform(parentForDrop, gameObject.transform)) { return(false); } } // Valid drop target for current dragged objects return(true); }
private static bool CanSetParent(Transform transform, Transform target) { bool canSetParent = transform != target; if (target != null) { canSetParent = canSetParent && !transform.IsChildOf(target) && !target.IsChildOf(transform); } if (SubSceneGUI.IsSubSceneHeader(transform.gameObject)) { canSetParent = canSetParent && !SubSceneGUI.IsChildOrSameAsOtherTransform(transform, target) && !SubSceneGUI.IsChildOrSameAsOtherTransform(target, transform); } return(canSetParent); }
internal static bool CanPasteAsChild() { bool canPaste = (Unsupported.CanPasteGameObjectsFromPasteboard() || CutBoard.hasCutboardData) && ((SceneHierarchyWindow.lastInteractedHierarchyWindow != null && SceneHierarchyWindow.lastInteractedHierarchyWindow.sceneHierarchy != null) || SceneView.lastActiveSceneView != null) && Selection.transforms.Length == 1; var activeGO = Selection.activeGameObject; if (activeGO != null && SubSceneGUI.IsSubSceneHeader(activeGO)) { return(canPaste && SubSceneGUI.GetSubScene(activeGO).IsValid()); } return(canPaste); }
override public bool IsRenamingItemAllowed(TreeViewItem item) { GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem.isSceneHeader) { return(false); } if (SubSceneGUI.IsUsingSubScenes() && SubSceneGUI.IsSubSceneHeader((GameObject)goItem.objectPPTR)) { return(false); } return(true); }
Transform GetTransformParentForDrop(int gameObjectOrSceneInstanceID, DropPosition dropPosition) { var obj = EditorUtility.InstanceIDToObject(gameObjectOrSceneInstanceID); if (obj != null) { // Find transform parent from GameObject var go = obj as GameObject; if (go == null) { throw new InvalidOperationException("Unexpected UnityEngine.Object type in Hierarchy " + obj.GetType()); } switch (dropPosition) { case DropPosition.Upon: return(go.transform); case DropPosition.Below: case DropPosition.Above: if (go.transform.parent == null) { var subSceneInfo = SubSceneGUI.GetSubSceneInfo(go.scene); if (subSceneInfo.isValid) { return(subSceneInfo.transform); } } return(go.transform.parent); default: throw new InvalidOperationException("Unhandled enum " + dropPosition); } } else { // Find transform parent from Scene var scene = EditorSceneManager.GetSceneByHandle(gameObjectOrSceneInstanceID); var subSceneInfo = SubSceneGUI.GetSubSceneInfo(scene); if (subSceneInfo.isValid) { return(subSceneInfo.transform); } return(null); // root scene has no transform parent } }
public static bool CanSetNewParent(Transform transform, Transform newParent) { if (transform == null) { throw new ArgumentNullException("transform"); } if (newParent == null) { return(true); } RefreshSubSceneInfo(); var parentIsChild = SubSceneGUI.IsChildOrSameAsOtherTransform(newParent, transform); return(!parentIsChild); }
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(); }
void CreateSceneHeaderItems() { m_StickySceneHeaderItems.Clear(); int numScenesInHierarchy = EditorSceneManager.sceneCount; if (SubSceneGUI.IsUsingSubScenes()) { for (int i = 0; i < numScenesInHierarchy; ++i) { Scene scene = SceneManager.GetSceneAt(i); var subSceneInfo = SubSceneGUI.GetSubSceneInfo(scene); if (subSceneInfo.isValid) { var item = new GameObjectTreeViewItem(0, 0, null, null); var transform = subSceneInfo.transform; GameObject gameObject = transform.gameObject; int depth = SubSceneGUI.CalculateHierarchyDepthOfSubScene(subSceneInfo); InitTreeViewItem(item, gameObject.GetInstanceID(), subSceneInfo.scene, false, 0, gameObject, false, depth); m_StickySceneHeaderItems.Add(item); } else { var item = new GameObjectTreeViewItem(0, 0, null, null); InitTreeViewItem(item, scene.handle, scene, true, 0, null, false, 0); m_StickySceneHeaderItems.Add(item); } } } else { for (int i = 0; i < numScenesInHierarchy; ++i) { Scene scene = SceneManager.GetSceneAt(i); var item = new GameObjectTreeViewItem(0, 0, null, null); InitTreeViewItem(item, scene.handle, scene, true, 0, null, false, 0); m_StickySceneHeaderItems.Add(item); } } }
void SetItemIcon(GameObjectTreeViewItem item) { var go = item.objectPPTR as GameObject; if (go == null) { item.icon = GameObjectStyles.sceneIcon; } else { if (SubSceneGUI.IsSubSceneHeader(go)) { item.icon = GameObjectStyles.sceneIcon; } else { item.icon = PrefabUtility.GetIconForGameObject(go); } } }
override protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool selected, bool focused, bool useBoldFont) { GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem; if (goItem == null) { return; } EnsureLazyInitialization(goItem); if (goItem.isSceneHeader) { useBoldFont = (goItem.scene == SceneManager.GetActiveScene()) || IsPrefabStageHeader(goItem); } SceneVisibilityHierarchyGUI.DoItemGUI(rect, goItem, selected && !IsRenaming(item.id), m_TreeView.hoveredItem == goItem, focused, isDragging); rect.xMin += SceneVisibilityHierarchyGUI.utilityBarWidth; base.DoItemGUI(rect, row, item, selected, focused, useBoldFont); if (goItem.isSceneHeader) { DoAdditionalSceneHeaderGUI(goItem, rect); } else { PrefabModeButton(goItem, rect); if (SubSceneGUI.IsUsingSubScenes() && !showingSearchResults) { SubSceneGUI.DrawVerticalLine(rect, (GameObject)goItem.objectPPTR); } } if (SceneHierarchy.s_Debug) { GUI.Label(new Rect(rect.xMax - 70, rect.y, 70, rect.height), "" + row + " (" + goItem.id + ")", EditorStyles.boldLabel); } }
override protected void DrawItemBackground(Rect rect, int row, TreeViewItem item, bool selected, bool focused) { var goItem = (GameObjectTreeViewItem)item; if (goItem.isSceneHeader) { GUI.Label(rect, GUIContent.none, GameObjectStyles.sceneHeaderBg); } else { // Don't show indented sub scene header backgrounds when searching (as the texts are not indented here) if (SubSceneGUI.IsUsingSubScenes() && !showingSearchResults) { var gameObject = (GameObject)goItem.objectPPTR; if (gameObject != null && SubSceneGUI.IsSubSceneHeader(gameObject)) { SubSceneGUI.DrawSubSceneHeaderBackground(rect, k_BaseIndent, k_IndentWidth, gameObject); } } } if (m_TreeView.hoveredItem != item) { return; } if (isDragging) { return; } using (new GUI.BackgroundColorScope(GameObjectStyles.hoveredBackgroundColor)) { GUI.Label(rect, GUIContent.none, GameObjectStyles.hoveredItemBackgroundStyle); } }
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; } 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; } // 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); }
public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, DropPosition dropPos) { var hierarchyTargetItem = targetItem as GameObjectTreeViewItem; // Allow client to handle drag if (m_CustomDragHandling != null) { DragAndDropVisualMode dragResult = m_CustomDragHandling(parentItem as GameObjectTreeViewItem, hierarchyTargetItem, dropPos, perform); if (dragResult != DragAndDropVisualMode.None) { return(dragResult); } } // Scene dragging logic DragAndDropVisualMode dragSceneResult = DoDragScenes(parentItem as GameObjectTreeViewItem, hierarchyTargetItem, perform, dropPos); if (dragSceneResult != DragAndDropVisualMode.None) { return(dragSceneResult); } if (targetItem != null && !IsDropTargetUserModifiable(hierarchyTargetItem, dropPos)) { return(DragAndDropVisualMode.Rejected); } var option = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal; var searchActive = !string.IsNullOrEmpty(dataSource.searchString); if (searchActive) { option |= InternalEditorUtility.HierarchyDropMode.kHierarchySearchActive; } if (parentItem == null || targetItem == null) { // Here we are dragging outside any treeview items: if (parentForDraggedObjectsOutsideItems != null) { // Use specific parent for DragAndDropForwarding return(DragAndDropService.Drop(DragAndDropService.kHierarchyDropDstId, 0, option, parentForDraggedObjectsOutsideItems, perform)); } else { // Simulate drag upon the last loaded scene in the hierarchy (adds as last root sibling of the last scene) Scene lastScene = dataSource.GetLastScene(); if (!lastScene.IsValid()) { return(DragAndDropVisualMode.Rejected); } option |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon; return(DragAndDropService.Drop(DragAndDropService.kHierarchyDropDstId, lastScene.handle, option, null, perform)); } } // Here we are hovering over items var draggingUpon = dropPos == TreeViewDragging.DropPosition.Upon; if (searchActive && !draggingUpon) { return(DragAndDropVisualMode.None); } if (draggingUpon) { option |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon; } else { if (dropPos == TreeViewDragging.DropPosition.Above) { option |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAbove; } else { option |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween; } } bool isDroppingBetweenParentAndFirstChild = parentItem != null && targetItem != parentItem && dropPos == DropPosition.Above && parentItem.children[0] == targetItem; if (isDroppingBetweenParentAndFirstChild) { option |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent; } int gameObjectOrSceneInstanceID = GetDropTargetInstanceID(hierarchyTargetItem, dropPos); if (gameObjectOrSceneInstanceID == 0) { return(DragAndDropVisualMode.Rejected); } if (perform && SubSceneGUI.IsUsingSubScenes() && !IsValidSubSceneDropTarget(gameObjectOrSceneInstanceID, dropPos, DragAndDrop.objectReferences)) { return(DragAndDropVisualMode.Rejected); } return(DragAndDropService.Drop(DragAndDropService.kHierarchyDropDstId, gameObjectOrSceneInstanceID, option, null, perform)); }