Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 03f518b

Browse files
committed
Added ability to keep folders in Playmode
1 parent 3e4c193 commit 03f518b

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Base/DetachOnBuildProcess.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ internal class DetachOnBuildProcess : IProcessSceneWithReport
1414

1515
public void OnProcessScene(Scene scene, BuildReport report)
1616
{
17+
var preferences = HierarchySettingsProvider.GetProvider().preferences;
18+
19+
if (Application.isEditor && preferences.keepFoldersInPlaymode)
20+
return;
21+
1722
var sceneRoots = scene.GetRootGameObjects();
1823
foreach (var root in sceneRoots)
1924
{

Base/HierarchySettingsProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal class HierarchyPreferences : ScriptableObject
2626
public bool enableSmartHierarchy = true;
2727
public StickyIcon stickyComponentIcon = StickyIcon.NotOnPrefabs;
2828
public TransformIcon transformIcon = TransformIcon.OnUniqueOrigin;
29+
public bool keepFoldersInPlaymode;
2930
}
3031

3132
internal class HierarchySettingsProvider : SettingsProvider

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ Note: Icons are not attached to Prefabs root. This behaviour can be changed in P
1414

1515
Folder is a special Editor-only object that has no components and no transform.\
1616
It detaches it's children on scene process, so there is no overhead at runtime.\
17+
[Best Practices: Transforms Optimization](https://unity.com/ru/how-to/best-practices-performance-optimization-unity#transforms) \
1718
[Best Practices: Optimizing the Hierarchy](https://blogs.unity3d.com/ru/2017/06/29/best-practices-from-the-spotlight-team-optimizing-the-hierarchy/)
1819

19-
**Issue:** Currently there is no folders displayed in Playmode.
20+
**Issue:** Currently folders are not displayed in Playmode.\
21+
There is an option (in Preferences) to keep them in Editor, but beware of the overhead.
2022

2123
### Activation Toggle
2224
![Activation Toggle](https://i.imgur.com/nv7aPE5.png)

UI/smart_hierarchy_settings.uxml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
<uie:EnumField label="Sticky Component Icon" binding-path="stickyComponentIcon" tooltip="Main component icon that is shown instead of GameObject or Prefab icon." />
77
<uie:EnumField label="Transform Icon" binding-path="transformIcon" />
88
</ui:Foldout>
9+
<ui:Foldout text="Folders">
10+
<ui:Toggle label="Keep In Playmode" binding-path="keepFoldersInPlaymode" />
11+
</ui:Foldout>
912
</ui:VisualElement>
1013
</ui:UXML>

0 commit comments

Comments
 (0)