Skip to content

Commit 872ee58

Browse files
authored
feat: add new scene transition methods (#46)
* update scene loader interface * add new transitions to scene loaders * add transitiontoscenesfromscenes test * add transitiontoscenesfromall test * add documentation for new transition methods
1 parent 4d868bb commit 872ee58

File tree

6 files changed

+419
-17
lines changed

6 files changed

+419
-17
lines changed

Runtime/Interfaces/ISceneLoader.cs

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface ISceneLoader : IDisposable
1515
ISceneManager Manager { get; }
1616

1717
/// <summary>
18-
/// Triggers a transition to a group of scens.
18+
/// Triggers a transition to a group of scenes from the active scene.
1919
/// It will transition from the current active scene (<see cref="ISceneManager.GetActiveScene()"/>)
2020
/// to a group of scenes (<paramref name="targetScenes"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
2121
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
@@ -39,7 +39,7 @@ public interface ISceneLoader : IDisposable
3939
void TransitionToScenes(ILoadSceneInfo[] targetScenes, int setIndexActive, ILoadSceneInfo intermediateSceneInfo = null);
4040

4141
/// <summary>
42-
/// Triggers a scene transition.
42+
/// Triggers a transition to the target scene from the active scene.
4343
/// It will transition from the current active scene (<see cref="ISceneManager.GetActiveScene()"/>)
4444
/// to the target scene (<paramref name="targetSceneInfo"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
4545
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
@@ -59,6 +59,105 @@ public interface ISceneLoader : IDisposable
5959
/// </param>
6060
void TransitionToScene(ILoadSceneInfo targetSceneInfo, ILoadSceneInfo intermediateSceneInfo = null);
6161

62+
/// <summary>
63+
/// Triggers a transition to a group of scenes from another group of scenes.
64+
/// It will transition from the provided group of scenes (<paramref name="fromScenes"/>)
65+
/// to a group of scenes (<paramref name="targetScenes"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
66+
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
67+
/// The complete transition flow is:
68+
/// <br/><br/>
69+
/// 1. Load the intermediate scene (if provided).<br/>
70+
/// 2. Unload all provided scenes.<br/>
71+
/// 3. Load all target scenes.<br/>
72+
/// 4. Unload the intermediate scene (if provided).<br/>
73+
/// </summary>
74+
/// <param name="targetScenes">
75+
/// A reference to all scenes that will be transitioned to.
76+
/// </param>
77+
/// <param name="fromScenes">
78+
/// A reference to all scenes that will be unloaded in the transition.
79+
/// </param>
80+
/// <param name="setIndexActive">
81+
/// Index of the scene in the <paramref name="targetScenes"/> to be set as the active scene.
82+
/// </param>
83+
/// <param name="intermediateSceneInfo">
84+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
85+
/// If null, the transition will not have an intermediate loading scene.
86+
/// </param>
87+
void TransitionToScenesFromScenes(ILoadSceneInfo[] targetScenes, ILoadSceneInfo[] fromScenes, int setIndexActive, ILoadSceneInfo intermediateSceneInfo = null);
88+
89+
/// <summary>
90+
/// Triggers a transition to the target scene from a group of scens.
91+
/// It will transition from the provided group of scenes (<paramref name="fromScenes"/>)
92+
/// to the target scene (<paramref name="targetSceneInfo"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
93+
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
94+
/// The complete transition flow is:
95+
/// <br/><br/>
96+
/// 1. Load the intermediate scene (if provided).<br/>
97+
/// 2. Unload all provided scenes.<br/>
98+
/// 3. Load the target scene.<br/>
99+
/// 4. Unload the intermediate scene (if provided).<br/>
100+
/// </summary>
101+
/// <param name="targetSceneInfo">
102+
/// A reference to the scene that's going to be transitioned to.
103+
/// </param>
104+
/// <param name="fromScenes">
105+
/// A reference to all scenes that will be unloaded in the transition.
106+
/// </param>
107+
/// <param name="intermediateSceneInfo">
108+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
109+
/// If null, the transition will not have an intermediate loading scene.
110+
/// </param>
111+
void TransitionToSceneFromScenes(ILoadSceneInfo targetSceneInfo, ILoadSceneInfo[] fromScenes, ILoadSceneInfo intermediateSceneInfo = null);
112+
113+
/// <summary>
114+
/// Triggers a transition to a group of scenes from all loaded scenes.
115+
/// It will transition from all loaded scenes
116+
/// to a group of scenes (<paramref name="targetScenes"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
117+
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
118+
/// The complete transition flow is:
119+
/// <br/><br/>
120+
/// 1. Load the intermediate scene (if provided).<br/>
121+
/// 2. Unload all loaded scenes.<br/>
122+
/// 3. Load all target scenes.<br/>
123+
/// 4. Unload the intermediate scene (if provided).<br/>
124+
/// </summary>
125+
/// <param name="targetScenes">
126+
/// A reference to all scenes that will be transitioned to.
127+
/// </param>
128+
/// <param name="setIndexActive">
129+
/// Index of the scene in the <paramref name="targetScenes"/> to be set as the active scene.
130+
/// </param>
131+
/// <param name="intermediateSceneInfo">
132+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
133+
/// If null, the transition will not have an intermediate loading scene.
134+
/// </param>
135+
void TransitionToScenesFromAll(ILoadSceneInfo[] targetScenes, int setIndexActive, ILoadSceneInfo intermediateSceneInfo = null);
136+
137+
/// <summary>
138+
/// Triggers a transition to the target scene from all loaded scenes.
139+
/// It will transition from the provided group of scenes (<paramref name="fromScenes"/>)
140+
/// to the target scene (<paramref name="targetSceneInfo"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
141+
/// If the <paramref name="intermediateSceneInfo"/> is not set, the transition will have no intermediate loading scene and will instead simply load the target scene directly.
142+
/// The complete transition flow is:
143+
/// <br/><br/>
144+
/// 1. Load the intermediate scene (if provided).<br/>
145+
/// 2. Unload all provided scenes.<br/>
146+
/// 3. Load the target scene.<br/>
147+
/// 4. Unload the intermediate scene (if provided).<br/>
148+
/// </summary>
149+
/// <param name="targetSceneInfo">
150+
/// A reference to the scene that's going to be transitioned to.
151+
/// </param>
152+
/// <param name="fromScenes">
153+
/// A reference to all scenes that will be unloaded in the transition.
154+
/// </param>
155+
/// <param name="intermediateSceneInfo">
156+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
157+
/// If null, the transition will not have an intermediate loading scene.
158+
/// </param>
159+
void TransitionToSceneFromAll(ILoadSceneInfo targetSceneInfo, ILoadSceneInfo intermediateSceneInfo = null);
160+
62161
/// <summary>
63162
/// Unloads all the scenes from the current scene stack.
64163
/// </summary>

Runtime/Interfaces/ISceneLoaderAsync.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,78 @@ public interface ISceneLoaderAsync<TAsyncScene, TAsyncSceneArray> : ISceneLoader
4949
/// </returns>
5050
TAsyncScene TransitionToSceneAsync(ILoadSceneInfo targetSceneReference, ILoadSceneInfo intermediateSceneReference = default);
5151

52+
/// <summary>
53+
/// Async version of the <see cref="ISceneLoader.TransitionToScenesFromScenes(ILoadSceneInfo[], ILoadSceneInfo[], int, ILoadSceneInfo)"/>
54+
/// </summary>
55+
/// <param name="targetScenes">
56+
/// A reference to all scenes that will be transitioned to.
57+
/// </param>
58+
/// <param name="fromScenes">
59+
/// A reference to all scenes that will be unloaded in the transition.
60+
/// </param>
61+
/// <param name="setIndexActive">
62+
/// Index of the scene in the <paramref name="targetScenes"/> to be set as the active scene.
63+
/// </param>
64+
/// <param name="intermediateSceneReference">
65+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
66+
/// If null, the transition will not have an intermediate loading scene.
67+
/// </param>
68+
/// <returns>
69+
/// The transition operation.
70+
/// </returns>
71+
TAsyncSceneArray TransitionToScenesFromScenesAsync(ILoadSceneInfo[] targetScenes, ILoadSceneInfo[] fromScenes, int setIndexActive, ILoadSceneInfo intermediateSceneReference = default);
72+
73+
/// <summary>
74+
/// Async version of the <see cref="ISceneLoader.TransitionToSceneFromScenes(ILoadSceneInfo, ILoadSceneInfo[], ILoadSceneInfo)"/>
75+
/// </summary>
76+
/// <param name="targetSceneReference">
77+
/// A reference to the scene that's going to be transitioned to.
78+
/// </param>
79+
/// <param name="fromScenes">
80+
/// A reference to all scenes that will be unloaded in the transition.
81+
/// </param>
82+
/// <param name="intermediateSceneReference">
83+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
84+
/// If null, the transition will not have an intermediate loading scene.
85+
/// </param>
86+
/// <returns>
87+
/// The transition operation.
88+
/// </returns>
89+
TAsyncScene TransitionToSceneFromScenesAsync(ILoadSceneInfo targetSceneReference, ILoadSceneInfo[] fromScenes, ILoadSceneInfo intermediateSceneReference = default);
90+
91+
/// <summary>
92+
/// Async version of the <see cref="ISceneLoader.TransitionToScenesFromAll(ILoadSceneInfo[], int, ILoadSceneInfo)"/>
93+
/// </summary>
94+
/// <param name="targetScenes">
95+
/// A reference to all scenes that will be transitioned to.
96+
/// </param>
97+
/// <param name="setIndexActive">
98+
/// Index of the scene in the <paramref name="targetScenes"/> to be set as the active scene.
99+
/// </param>
100+
/// <param name="intermediateSceneReference">
101+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
102+
/// If null, the transition will not have an intermediate loading scene.
103+
/// </param>
104+
/// <returns>
105+
/// The transition operation.
106+
/// </returns>
107+
TAsyncSceneArray TransitionToScenesFromAllAsync(ILoadSceneInfo[] targetScenes, int setIndexActive, ILoadSceneInfo intermediateSceneReference = default);
108+
109+
/// <summary>
110+
/// Async version of the <see cref="ISceneLoader.TransitionToSceneFromAll(ILoadSceneInfo, ILoadSceneInfo)"/>
111+
/// </summary>
112+
/// <param name="targetSceneReference">
113+
/// A reference to the scene that's going to be transitioned to.
114+
/// </param>
115+
/// <param name="intermediateSceneReference">
116+
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
117+
/// If null, the transition will not have an intermediate loading scene.
118+
/// </param>
119+
/// <returns>
120+
/// The transition operation.
121+
/// </returns>
122+
TAsyncScene TransitionToSceneFromAllAsync(ILoadSceneInfo targetSceneReference, ILoadSceneInfo intermediateSceneReference = default);
123+
52124
/// <summary>
53125
/// Async version of the <see cref="ISceneLoader.LoadScenes(ILoadSceneInfo[], int)"/>.
54126
/// </summary>

0 commit comments

Comments
 (0)