Skip to content

Commit

Permalink
Expose initial load method
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvinas01 committed Sep 26, 2024
1 parent 7095613 commit 96ace9b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Packages/com.chark.scriptable-scenes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.0.11](https://github.com/chark/scriptable-scenes/compare/v0.0.10...v0.0.11) - 2023-XX-XX

### Added

- `LoadInitialSceneCollection` method to `ScriptableSceneController`.

### Changed

- Menu item order to use `150` instead of `-1000`. This way `CHARK` won't dominate existing entries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ private enum CollectionLoadMode
{
[Tooltip("Collection will not be loaded automatically")]
// ReSharper disable once UnusedMember.Local
None,
None = 0,

[Tooltip("Automatically load collection in Awake() method")]
Awake,
Awake = 1,

[Tooltip("Automatically load collection in Start() method")]
Start,
Start = 2,
}

#if ODIN_INSPECTOR
Expand Down Expand Up @@ -66,7 +66,7 @@ private enum CollectionLoadMode
private SceneEventHandler sceneEvents = new();

#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Debug", Expanded = true)]
[Sirenix.OdinInspector.FoldoutGroup("Debug")]
[Sirenix.OdinInspector.ShowInInspector]
[Sirenix.OdinInspector.ReadOnly]
#endif
Expand All @@ -93,7 +93,7 @@ private enum CollectionLoadMode
/// Currently loading collection.
/// </summary>
#if ODIN_INSPECTOR
[Sirenix.OdinInspector.FoldoutGroup("Debug", Expanded = true)]
[Sirenix.OdinInspector.FoldoutGroup("Debug")]
[Sirenix.OdinInspector.ShowInInspector]
[Sirenix.OdinInspector.ReadOnly]
#endif
Expand Down Expand Up @@ -123,11 +123,7 @@ private void Awake()
return;
}

#if UNITY_EDITOR
LoadSelectedOrOpenedCollection();
#else
LoadInitialSceneCollection();
#endif
}

private void Start()
Expand All @@ -137,10 +133,18 @@ private void Start()
return;
}

LoadInitialSceneCollection();
}

/// <summary>
/// Load the initial Scene Collection specified in <see cref="initialCollection"/>.
/// </summary>
public void LoadInitialSceneCollection()
{
#if UNITY_EDITOR
LoadSelectedOrOpenedCollection();
LoadSelectedOrOpenedCollectionEditor();
#else
LoadInitialSceneCollection();
LoadInitialSceneCollectionRuntime();
#endif
}

Expand Down Expand Up @@ -192,12 +196,12 @@ public bool TryGetLoadedSceneCollection(out ScriptableSceneCollection collection
}

#if UNITY_EDITOR
private void LoadSelectedOrOpenedCollection()
private void LoadSelectedOrOpenedCollectionEditor()
{
StartCoroutine(LoadSelectedOrOpenedCollectionRoutine());
StartCoroutine(LoadSelectedOrOpenedCollectionRoutineEditor());
}

private IEnumerator LoadSelectedOrOpenedCollectionRoutine()
private IEnumerator LoadSelectedOrOpenedCollectionRoutineEditor()
{
if (ScriptableSceneUtilities.TryGetSelectedCollection(out var selected))
{
Expand All @@ -219,12 +223,12 @@ private IEnumerator LoadSelectedOrOpenedCollectionRoutine()
);
}
#else
private void LoadInitialSceneCollection()
private void LoadInitialSceneCollectionRuntime()
{
StartCoroutine(LoadInitialSceneCollectionRoutine());
StartCoroutine(LoadInitialSceneCollectionRoutineRuntime());
}

private IEnumerator LoadInitialSceneCollectionRoutine()
private IEnumerator LoadInitialSceneCollectionRoutineRuntime()
{
if (initialCollection == false)
{
Expand Down

0 comments on commit 96ace9b

Please sign in to comment.