-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from badawe/feature/AllowLazyCollectionInitiali…
…zation Feature/allow lazy collection initialization
- Loading branch information
Showing
18 changed files
with
513 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using UnityEditor.Build; | ||
using UnityEditor.Build.Reporting; | ||
|
||
namespace BrunoMikoski.ScriptableObjectCollections | ||
{ | ||
public class CollectionPreprocessBuild : IPreprocessBuildWithReport, IPostprocessBuildWithReport | ||
{ | ||
public int callbackOrder { get { return 0; } } | ||
|
||
void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report) | ||
{ | ||
CollectionsRegistry.Instance.PostBuildProcess(); | ||
} | ||
|
||
void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report) | ||
{ | ||
CollectionsRegistry.Instance.PreBuildProcess(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace BrunoMikoski.ScriptableObjectCollections | ||
{ | ||
[CustomEditor(typeof(CollectionsRegistry))] | ||
public class CollectionRegistryCustomEditor : Editor | ||
{ | ||
private SerializedProperty collections; | ||
|
||
private void OnEnable() | ||
{ | ||
collections = serializedObject.FindProperty("collections"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
DrawCollections(); | ||
} | ||
|
||
private void DrawCollections() | ||
{ | ||
for (int i = 0; i < collections.arraySize; i++) | ||
{ | ||
DrawCollection((ScriptableObjectCollection) collections.GetArrayElementAtIndex(i).objectReferenceValue); | ||
} | ||
} | ||
|
||
private void DrawCollection(ScriptableObjectCollection collection) | ||
{ | ||
using (new EditorGUILayout.VerticalScope("Box")) | ||
{ | ||
using (new EditorGUILayout.HorizontalScope()) | ||
{ | ||
CollectionUtility.SetFoldoutOpen(collection, | ||
EditorGUILayout.Toggle(GUIContent.none, CollectionUtility.IsFoldoutOpen(collection), | ||
EditorStyles.foldout, | ||
GUILayout.Width(13))); | ||
|
||
EditorGUILayout.LabelField(collection.name, CollectionEditorGUI.ItemNameStyle, | ||
GUILayout.ExpandWidth(true)); | ||
} | ||
|
||
if (CollectionUtility.IsFoldoutOpen(collection)) | ||
{ | ||
EditorGUI.indentLevel++; | ||
SerializedObject serializedObject = new SerializedObject(collection); | ||
using (EditorGUI.ChangeCheckScope changeCheck = new EditorGUI.ChangeCheckScope()) | ||
{ | ||
EditorGUILayout.PropertyField(serializedObject.FindProperty("automaticallyLoaded")); | ||
EditorGUILayout.PropertyField(serializedObject.FindProperty("staticFileGenerationType")); | ||
|
||
if (changeCheck.changed) | ||
{ | ||
ObjectUtility.SetDirty(collection); | ||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
EditorGUI.indentLevel--; | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using UnityEditor; | ||
|
||
namespace BrunoMikoski.ScriptableObjectCollections | ||
{ | ||
[InitializeOnLoad] | ||
public class RegistryEditorBehaviour | ||
{ | ||
static RegistryEditorBehaviour() | ||
{ | ||
|
||
EditorApplication.playModeStateChanged += EditorApplicationOnplayModeStateChanged; | ||
} | ||
|
||
private static void EditorApplicationOnplayModeStateChanged(PlayModeStateChange playModeStateChange) | ||
{ | ||
if (playModeStateChange == PlayModeStateChange.EnteredPlayMode) | ||
{ | ||
CollectionsRegistry.Instance.RemoveNonAutomaticallyInitializedCollections(); | ||
} | ||
else if (playModeStateChange == PlayModeStateChange.EnteredEditMode) | ||
{ | ||
CollectionsRegistry.Instance.ReloadCollections(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.