@@ -15,21 +15,21 @@ internal static class SettingsDrawer
1515 {
1616 { nameof ( StripSettings . PlayMode ) , "Play Mode Stripping Type" } ,
1717 { nameof ( StripSettings . Build ) , "Build Stripping Type" } ,
18- { nameof ( StripSettings . CapitalizeName ) , "Capitalize Folder Names" }
18+ { nameof ( StripSettings . CapitalizeName ) , "Capitalize Folder Names" } ,
19+ { nameof ( StripSettings . StripFoldersFromPrefabsInPlayMode ) , "Strip folders from prefabs in Play Mode" } ,
20+ { nameof ( StripSettings . StripFoldersFromPrefabsInBuild ) , "Strip folders from prefabs in build" } ,
1921 } ;
2022
2123 private static readonly GUIContent _buildStrippingName = new GUIContent ( _fieldNames [ nameof ( StripSettings . Build ) ] ) ;
2224
2325 [ SettingsProvider ]
2426 public static SettingsProvider CreateSettingsProvider ( )
2527 {
26- var provider = new SettingsProvider ( "Preferences/Hierarchy Folders" , SettingsScope . User )
28+ return new SettingsProvider ( "Preferences/Hierarchy Folders" , SettingsScope . User )
2729 {
2830 guiHandler = OnGUI ,
2931 keywords = GetKeywords ( )
3032 } ;
31-
32- return provider ;
3333 }
3434
3535 private static void OnGUI ( string searchContext )
@@ -45,6 +45,22 @@ private static void OnGUI(string searchContext)
4545
4646 StripSettings . Build = ( StrippingMode ) EditorGUILayout . EnumPopup (
4747 _buildStrippingName , StripSettings . Build , TypeCanBeInBuild , true ) ;
48+
49+ EditorGUILayout . Space ( EditorGUIUtility . singleLineHeight ) ;
50+
51+ EditorGUILayout . HelpBox (
52+ "If you notice that entering play mode takes too long, you can try disabling this option. " +
53+ "Folders will not be stripped from prefabs that are instantiated at runtime, but if performance in " +
54+ "Play Mode does not matter, you will be fine." , MessageType . Warning ) ;
55+
56+ using ( new TemporaryLabelWidth ( 230f ) )
57+ {
58+ StripSettings . StripFoldersFromPrefabsInPlayMode =
59+ EditorGUILayout . Toggle ( _fieldNames [ nameof ( StripSettings . StripFoldersFromPrefabsInPlayMode ) ] , StripSettings . StripFoldersFromPrefabsInPlayMode ) ;
60+
61+ StripSettings . StripFoldersFromPrefabsInBuild =
62+ EditorGUILayout . Toggle ( _fieldNames [ nameof ( StripSettings . StripFoldersFromPrefabsInBuild ) ] , StripSettings . StripFoldersFromPrefabsInBuild ) ;
63+ }
4864 }
4965
5066 private static HashSet < string > GetKeywords ( )
@@ -72,5 +88,24 @@ private static bool TypeCanBeInBuild(Enum enumValue)
7288 var mode = ( StrippingMode ) enumValue ;
7389 return mode == StrippingMode . PrependWithFolderName || mode == StrippingMode . Delete ;
7490 }
91+
92+ /// <summary>
93+ /// Temporarily sets <see cref="EditorGUIUtility.labelWidth"/> to a certain value, than reverts it.
94+ /// </summary>
95+ private readonly struct TemporaryLabelWidth : IDisposable
96+ {
97+ private readonly float _oldWidth ;
98+
99+ public TemporaryLabelWidth ( float width )
100+ {
101+ _oldWidth = EditorGUIUtility . labelWidth ;
102+ EditorGUIUtility . labelWidth = width ;
103+ }
104+
105+ public void Dispose ( )
106+ {
107+ EditorGUIUtility . labelWidth = _oldWidth ;
108+ }
109+ }
75110 }
76111}
0 commit comments