Skip to content

Commit ffb1461

Browse files
authored
Merge pull request #161 from brunomikoski/feature/automatic-namespaces-for-generated-code
Ensured that the namespace for generated code is the same as the script by default
2 parents ef1543b + 8575942 commit ffb1461

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Scripts/Editor/EditorWindows/CreateCollectionWizard.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ private enum Fields
2929
private const string WAITING_SCRIPTS_TO_RECOMPILE_TO_CONTINUE_KEY = "WaitingScriptsToRecompileToContinueKey";
3030
private const string LAST_COLLECTION_SCRIPTABLE_OBJECT_PATH_KEY = "CollectionScriptableObjectPathKey";
3131
private const string LAST_COLLECTION_FULL_NAME_KEY = "CollectionFullNameKey";
32+
private const string LAST_COLLECTION_NAMESPACE_KEY = "CollectionNamespaceKey";
3233
private const string LAST_GENERATED_COLLECTION_SCRIPT_PATH_KEY = "CollectionScriptPathKey";
3334
private const string LAST_TARGET_SCRIPTS_FOLDER_KEY = "LastTargetScriptsFolder";
3435
private const string GENERATE_INDIRECT_ACCESS_KEY = "GenerateIndirectAccess";
@@ -265,6 +266,9 @@ private int MaximumNamespaceDepth
265266

266267
private static readonly EditorPreferenceString LastCollectionFullName =
267268
new EditorPreferenceString(LAST_COLLECTION_FULL_NAME_KEY, null, true);
269+
270+
private static readonly EditorPreferenceString LastCollectionNamespace =
271+
new EditorPreferenceString(LAST_COLLECTION_NAMESPACE_KEY, null, true);
268272

269273
private static readonly EditorPreferenceString LastScriptsTargetFolder =
270274
new EditorPreferenceString(LAST_TARGET_SCRIPTS_FOLDER_KEY, null, true);
@@ -593,6 +597,8 @@ private string InferScriptFolderFromScriptableObjectFolder(string pathToInferFro
593597

594598
private void CreateNewCollection()
595599
{
600+
LastCollectionNamespace.Value = Namespace;
601+
596602
bool scriptsGenerated = false;
597603
scriptsGenerated |= CreateCollectionItemScript();
598604
scriptsGenerated |= CreateCollectionScript();
@@ -701,6 +707,9 @@ private static void AfterScriptsAreReady()
701707
ScriptableObjectCollectionUtility.CreateScriptableObjectOfType(targetType,
702708
windowInstance.ScriptableObjectFolderPath, windowInstance.CollectionName) as ScriptableObjectCollection;
703709

710+
if (!string.IsNullOrEmpty(LastCollectionNamespace.Value))
711+
SOCSettings.Instance.SetNamespaceForCollection(collectionAsset, LastCollectionNamespace.Value);
712+
704713
Selection.objects = new Object[] {collectionAsset};
705714
EditorGUIUtility.PingObject(collectionAsset);
706715

0 commit comments

Comments
 (0)