Skip to content

Commit 0f0d17e

Browse files
committed
Update addressable samples
1 parent 7f32a56 commit 0f0d17e

29 files changed

+4568
-1911
lines changed

Editor/Authoring/MyUnityTools.SceneLoading.Authoring.asmdef

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "MyUnityTools.SceneLoading.Authoring",
33
"rootNamespace": "",
44
"references": [],
5-
"includePlatforms": [],
5+
"includePlatforms": [
6+
"Editor"
7+
],
68
"excludePlatforms": [],
79
"allowUnsafeCode": false,
810
"overrideReferences": false,

Runtime/Interfaces/IAddressableLoadSceneInfo.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@
1010

1111
namespace MyUnityTools.SceneLoading.AddressablesSupport
1212
{
13+
/// <summary>
14+
/// Interface to standardize addressable scene unload info.
15+
/// Can be created with either the target scene's <see cref="AsyncOperationHandle{TObject}"/> (<see cref="AddressableLoadSceneInfoOperationHandle"/>),
16+
/// the <see cref="SceneInstance"/> (<see cref="AddressableLoadSceneInfoInstance"/>) or its name (<see cref="AddressableLoadSceneInfoName"/>).
17+
/// </summary>
1318
public interface IAddressableLoadSceneInfo
1419
{
15-
AsyncOperationHandle<SceneInstance> UnloadSceneAsync(IAddressableSceneManager sceneManager);
20+
/// <summary>
21+
/// Unloads the provided scene asynchronously.
22+
/// Internally calls <see cref="UnityEngine.AddressableAssets.Addressables.UnloadSceneAsync(AsyncOperationHandle, bool)"/>.
23+
/// </summary>
24+
/// <param name="sceneManager">The reference to the <see cref="IAddressableSceneManager"/> that keeps track of the active scenes.</param>
25+
/// <param name="autoReleaseHandle">Should the <see cref="AsyncOperationHandle{TObject}"/> be released automatically?</param>
26+
/// <returns>The unload <see cref="AsyncOperationHandle{TObject}"/>.</returns>
27+
AsyncOperationHandle<SceneInstance> UnloadSceneAsync(IAddressableSceneManager sceneManager, bool autoReleaseHandle = true);
1628
}
1729
}
1830
#endif

Runtime/Interfaces/IAddressableLoadSceneReference.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
* Created on: 8/24/2022 (en-US)
66
*/
77

8-
using UnityEngine.AddressableAssets;
98
using UnityEngine.ResourceManagement.AsyncOperations;
109
using UnityEngine.ResourceManagement.ResourceProviders;
1110
using UnityEngine.SceneManagement;
1211

1312
namespace MyUnityTools.SceneLoading.AddressablesSupport
1413
{
1514
/// <summary>
16-
/// Interface to standardize addressable scene information.
17-
/// Can be created with either the target scene's <see cref="AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>) or the scene's runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
15+
/// Interface to standardize addressable scene load reference.
16+
/// Can be created with either the target scene's <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>) or the scene's runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
1817
/// </summary>
1918
public interface IAddressableLoadSceneReference
2019
{
2120
/// <summary>
2221
/// Loads the provided scene asynchronously.
23-
/// Internally calls <see cref="Addressables.LoadSceneAsync(object, LoadSceneMode, bool, int)"/>.
22+
/// Internally calls <see cref="UnityEngine.AddressableAssets.Addressables.LoadSceneAsync(object, LoadSceneMode, bool, int)"/>.
2423
/// </summary>
24+
/// <param name="sceneManager">The reference to the <see cref="IAddressableSceneManager"/> that keeps track of the active scenes.</param>
2525
/// <returns>The load <see cref="AsyncOperationHandle{TObject}"/>.</returns>
2626
AsyncOperationHandle<SceneInstance> LoadSceneAsync(IAddressableSceneManager sceneManager);
2727
}

Runtime/Interfaces/IAddressableSceneLoader.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,66 @@
77

88
namespace MyUnityTools.SceneLoading.AddressablesSupport
99
{
10+
/// <summary>
11+
/// Interface to standardize addressable scene operations.
12+
/// </summary>
1013
public interface IAddressableSceneLoader
1114
{
15+
/// <summary>
16+
/// The addressable Scene Manager, responsible for keeping track of the loaded addressable scene stack.
17+
/// </summary>
1218
IAddressableSceneManager SceneManager { get; }
1319

20+
/// <summary>
21+
/// Triggers a scene transition.
22+
/// It will transition from the current active scene (<see cref="IAddressableSceneManager.GetActiveSceneHandle"/>)
23+
/// to the target scene (<paramref name="targetSceneReference"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneReference"/>).
24+
/// If the <paramref name="intermediateSceneReference"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
25+
/// The complete transition flow is:
26+
/// <br/><br/>
27+
/// 1. Load the intermediate scene (if provided).<br/>
28+
/// 2. Load the target scene.<br/>
29+
/// 3. Unload the intermediate scene (if provided).<br/>
30+
/// 4. Unload the previous scene
31+
/// </summary>
32+
/// <param name="targetSceneReference">
33+
/// The scene that's going to be transitioned to.
34+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
35+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
36+
/// </param>
37+
/// <param name="intermediateSceneReference">
38+
/// The scene that's going to be loaded as the transition intermediate (as a loading scene).
39+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
40+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
41+
/// If null, the transition will not have an intermediate loading scene.
42+
/// </param>
1443
void TransitionToScene(IAddressableLoadSceneReference targetSceneReference, IAddressableLoadSceneReference intermediateSceneReference = null);
1544

16-
void LoadScene(IAddressableLoadSceneReference sceneReference, bool setActive = false);
17-
45+
/// <summary>
46+
/// Unloads the given scene from the current scene stack.
47+
/// </summary>
48+
/// <param name="sceneInfo">
49+
/// Target scene info.
50+
/// Can be the scene's addressable <see cref="UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{TObject}"/> (<see cref="AddressableLoadSceneInfoOperationHandle"/>),
51+
/// its <see cref="UnityEngine.ResourceManagement.ResourceProviders.SceneInstance"/> (<see cref="AddressableLoadSceneInfoInstance"/>),
52+
/// or its name (<see cref="AddressableLoadSceneInfoName"/>).
53+
/// </param>
1854
void UnloadScene(IAddressableLoadSceneInfo sceneInfo);
55+
56+
/// <summary>
57+
/// Loads a scene additively on top of the current scene stack, optionally marking it as the active scene
58+
/// (<see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>).
59+
/// </summary>
60+
/// <param name="sceneInfo">
61+
/// The scene that's going to be loaded.
62+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
63+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
64+
/// </param>
65+
/// <param name="setActive">
66+
/// Should the loaded scene be marked as active?
67+
/// Equivalent to calling <see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>.
68+
/// </param>
69+
void LoadScene(IAddressableLoadSceneReference sceneReference, bool setActive = false);
1970
}
2071
}
2172
#endif

Runtime/Interfaces/IAddressableSceneLoaderAsync.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,63 @@
1010

1111
namespace MyUnityTools.SceneLoading.AddressablesSupport
1212
{
13+
/// <summary>
14+
/// Interface to standardize async addressable scene operations.
15+
/// </summary>
1316
public interface IAddressableSceneLoaderAsync : IAddressableSceneLoader
1417
{
18+
/// <summary>
19+
/// Triggers a scene transition asynchronously.
20+
/// It will transition from the current active scene (<see cref="IAddressableSceneManager.GetActiveSceneHandle"/>)
21+
/// to the target scene (<paramref name="targetSceneReference"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneReference"/>).
22+
/// If the <paramref name="intermediateSceneReference"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
23+
/// The complete transition flow is:
24+
/// <br/><br/>
25+
/// 1. Load the intermediate scene (if provided).<br/>
26+
/// 2. Load the target scene.<br/>
27+
/// 3. Unload the intermediate scene (if provided).<br/>
28+
/// 4. Unload the previous scene
29+
/// </summary>
30+
/// <param name="targetSceneReference">
31+
/// The scene that's going to be transitioned to.
32+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
33+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
34+
/// </param>
35+
/// <param name="intermediateSceneReference">
36+
/// The scene that's going to be loaded as the transition intermediate (as a loading scene).
37+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
38+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
39+
/// If null, the transition will not have an intermediate loading scene.
40+
/// </param>
41+
/// <returns>The transition awaitable <see cref="Task{TResult}"/>"/> with the resulting <see cref="SceneInstance"/>.</returns>
1542
Task<SceneInstance> TransitionToSceneAsync(IAddressableLoadSceneReference targetSceneReference, IAddressableLoadSceneReference intermediateSceneReference = null);
1643

44+
/// <summary>
45+
/// Loads a scene additively asynchronously on top of the current scene stack, optionally marking it as the active scene
46+
/// (<see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>).
47+
/// </summary>
48+
/// <param name="sceneInfo">
49+
/// The scene that's going to be loaded.
50+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
51+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
52+
/// </param>
53+
/// <param name="setActive">
54+
/// Should the loaded scene be marked as active?
55+
/// Equivalent to calling <see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>.
56+
/// </param>
57+
/// <returns>The load awaitable <see cref="Task{TResult}"/>"/> with the resulting <see cref="SceneInstance"/>.</returns>
1758
Task<SceneInstance> LoadSceneAsync(IAddressableLoadSceneReference sceneReference, bool setActive = false);
1859

60+
/// <summary>
61+
/// Unloads the given scene asynchronously from the current scene stack.
62+
/// </summary>
63+
/// <param name="sceneInfo">
64+
/// Target scene info.
65+
/// Can be the scene's addressable <see cref="UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{TObject}"/> (<see cref="AddressableLoadSceneInfoOperationHandle"/>),
66+
/// its <see cref="UnityEngine.ResourceManagement.ResourceProviders.SceneInstance"/> (<see cref="AddressableLoadSceneInfoInstance"/>),
67+
/// or its name (<see cref="AddressableLoadSceneInfoName"/>).
68+
/// </param>
69+
/// <returns>The unload awaitable <see cref="Task"/>.</returns>
1970
Task UnloadSceneAsync(IAddressableLoadSceneInfo sceneInfo);
2071
}
2172
}

Runtime/Interfaces/IAddressableSceneLoaderUniTask.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,63 @@
1010

1111
namespace MyUnityTools.SceneLoading.AddressablesSupport.UniTaskSupport
1212
{
13+
/// <summary>
14+
/// Interface to standardize async addressable scene operations with <see cref="UniTask"/>.
15+
/// </summary>
1316
public interface IAddressableSceneLoaderUniTask : IAddressableSceneLoader
1417
{
18+
/// <summary>
19+
/// Triggers a scene transition asynchronously.
20+
/// It will transition from the current active scene (<see cref="IAddressableSceneManager.GetActiveSceneHandle"/>)
21+
/// to the target scene (<paramref name="targetSceneReference"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneReference"/>).
22+
/// If the <paramref name="intermediateSceneReference"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
23+
/// The complete transition flow is:
24+
/// <br/><br/>
25+
/// 1. Load the intermediate scene (if provided).<br/>
26+
/// 2. Load the target scene.<br/>
27+
/// 3. Unload the intermediate scene (if provided).<br/>
28+
/// 4. Unload the previous scene
29+
/// </summary>
30+
/// <param name="targetSceneReference">
31+
/// The scene that's going to be transitioned to.
32+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
33+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
34+
/// </param>
35+
/// <param name="intermediateSceneReference">
36+
/// The scene that's going to be loaded as the transition intermediate (as a loading scene).
37+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
38+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
39+
/// If null, the transition will not have an intermediate loading scene.
40+
/// </param>
41+
/// <returns>The transition awaitable <see cref="UniTask{TResult}"/>"/> with the resulting <see cref="SceneInstance"/>.</returns>
1542
UniTask<SceneInstance> TransitionToSceneAsync(IAddressableLoadSceneReference targetSceneReference, IAddressableLoadSceneReference intermediateSceneReference = null);
1643

44+
/// <summary>
45+
/// Loads a scene additively asynchronously on top of the current scene stack, optionally marking it as the active scene
46+
/// (<see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>).
47+
/// </summary>
48+
/// <param name="sceneInfo">
49+
/// The scene that's going to be loaded.
50+
/// Can be the scene's addressable <see cref="UnityEngine.AddressableAssets.AssetReference"/> (<see cref="AddressableLoadSceneReferenceAsset"/>)
51+
/// or runtime key (<see cref="AddressableLoadSceneReferenceKey"/>).
52+
/// </param>
53+
/// <param name="setActive">
54+
/// Should the loaded scene be marked as active?
55+
/// Equivalent to calling <see cref="IAddressableSceneManager.SetActiveSceneHandle(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{UnityEngine.ResourceManagement.ResourceProviders.SceneInstance})"/>.
56+
/// </param>
57+
/// <returns>The load awaitable <see cref="UniTask{TResult}"/>"/> with the resulting <see cref="SceneInstance"/>.</returns>
1758
UniTask<SceneInstance> LoadSceneAsync(IAddressableLoadSceneReference sceneReference, bool setActive = false);
1859

60+
/// <summary>
61+
/// Unloads the given scene asynchronously from the current scene stack.
62+
/// </summary>
63+
/// <param name="sceneInfo">
64+
/// Target scene info.
65+
/// Can be the scene's addressable <see cref="UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle{TObject}"/> (<see cref="AddressableLoadSceneInfoOperationHandle"/>),
66+
/// its <see cref="UnityEngine.ResourceManagement.ResourceProviders.SceneInstance"/> (<see cref="AddressableLoadSceneInfoInstance"/>),
67+
/// or its name (<see cref="AddressableLoadSceneInfoName"/>).
68+
/// </param>
69+
/// <returns>The unload awaitable <see cref="UniTask"/>.</returns>
1970
UniTask UnloadSceneAsync(IAddressableLoadSceneInfo sceneInfo);
2071
}
2172
}

0 commit comments

Comments
 (0)