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

Commit

Permalink
Added ability to keep folders in Playmode
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-age committed Nov 22, 2020
1 parent 3e4c193 commit 03f518b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Base/DetachOnBuildProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ internal class DetachOnBuildProcess : IProcessSceneWithReport

public void OnProcessScene(Scene scene, BuildReport report)
{
var preferences = HierarchySettingsProvider.GetProvider().preferences;

if (Application.isEditor && preferences.keepFoldersInPlaymode)
return;

var sceneRoots = scene.GetRootGameObjects();
foreach (var root in sceneRoots)
{
Expand Down
1 change: 1 addition & 0 deletions Base/HierarchySettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class HierarchyPreferences : ScriptableObject
public bool enableSmartHierarchy = true;
public StickyIcon stickyComponentIcon = StickyIcon.NotOnPrefabs;
public TransformIcon transformIcon = TransformIcon.OnUniqueOrigin;
public bool keepFoldersInPlaymode;
}

internal class HierarchySettingsProvider : SettingsProvider
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ Note: Icons are not attached to Prefabs root. This behaviour can be changed in P

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

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

### Activation Toggle
![Activation Toggle](https://i.imgur.com/nv7aPE5.png)
Expand Down
3 changes: 3 additions & 0 deletions UI/smart_hierarchy_settings.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
<uie:EnumField label="Sticky Component Icon" binding-path="stickyComponentIcon" tooltip="Main component icon that is shown instead of GameObject or Prefab icon." />
<uie:EnumField label="Transform Icon" binding-path="transformIcon" />
</ui:Foldout>
<ui:Foldout text="Folders">
<ui:Toggle label="Keep In Playmode" binding-path="keepFoldersInPlaymode" />
</ui:Foldout>
</ui:VisualElement>
</ui:UXML>

0 comments on commit 03f518b

Please sign in to comment.