Skip to content

Commit

Permalink
feat: add support for multiple scene operations (#17)
Browse files Browse the repository at this point in the history
* build: update Unity to 2022.2.12f1

* refactor: add default parameter values to loaders

* fix: remove unitask reference from coroutine loader

* add script-templates package

* feat: add interface support for multiple scene ops

* feat: add batch scene operations for scene manager

* build: update to Unity 2022.2.17f1

* feat: add batch scene operation tests

* feat: add addressable batch scene operations

* refactor: improve debug messages

* docs: add docs for ISceneManager batch operations

* feat: add batch scene ops to scene loader interface

* refactor: simplify regular scene operations

* feat: add async scene loader batch scene operations

* test: add scene loader batch scene ops tests

* refactor: minor tweaks and improvements

* docs: update docs regarding batch scene operations

* test: fix loading fader test time

* test: increase timeout

* test: revert test utilities scene unloading method

* ci: fix test workflow syntax

* build: update to unity 2022.3.2f1
  • Loading branch information
joaoborks committed Jun 28, 2023
1 parent 4e8182e commit 87117e0
Show file tree
Hide file tree
Showing 45 changed files with 1,221 additions and 261 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ jobs:
project-path:
- ./
testMode:
- playmode
# TODO: Restore playmode tests once Unity fixes the linux editor tests issue: https://github.com/mygamedevtools/scene-loader/issues/18
# - playmode
- standalone
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}
path: ${{ matrix.project-path }}/Library
key: Library-${{ matrix.project-path }}
restore-keys: |
Library-
- uses: game-ci/unity-test-runner@v2
# TODO: Replace with actual release version once Unity fixes the linux editor tests issue: https://github.com/mygamedevtools/scene-loader/issues/18
- uses: game-ci/unity-test-runner@31086d985910613d75c32ba965f657df9c298820
id: tests
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
projectPath: ${{ matrix.projectPath }}
projectPath: ${{ matrix.project-path }}
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-artifacts
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -45,4 +48,4 @@ jobs:
with:
name: PlayMode
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.tests.outputs.coveragePath }}/**/*.xml
files: ${{ steps.tests.outputs.coveragePath }}/**/*.xml
3 changes: 2 additions & 1 deletion LICENSE.meta → Assets/ScriptTemplates.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using UnityEngine;

#NAMESPACE#public class #SCRIPTNAME# : MonoBehaviour
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using UnityEngine;

#NAMESPACE#public class #SCRIPTNAME# : ScriptableObject
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using Unity.Entities;

#NAMESPACE#public partial struct #SCRIPTNAME# : ISystem
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using Unity.Entities;

#NAMESPACE#public struct #SCRIPTNAME# : IComponentData
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#SIGNATURE#using Unity.Entities;
using UnityEngine;

#NAMESPACE#public class #SCRIPTNAME# : MonoBehaviour
{
public class #SCRIPTNAME#Baker : Baker<#SCRIPTNAME#>
{
public override void Bake(#SCRIPTNAME# authoring)
{

}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#SIGNATURE#using Unity.Entities;

#NAMESPACE#public partial class #SCRIPTNAME# : SystemBase
{
protected override void OnUpdate()
{

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using Unity.Entities;

#NAMESPACE#public class #SCRIPTNAME# : IComponentData
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using System;

#NAMESPACE#public class #SCRIPTNAME#
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using System;

#NAMESPACE#public struct #SCRIPTNAME#
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/ScriptTemplates/80-My Scripts__C# Enum-NewEnum.cs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#SIGNATURE##NAMESPACE#public enum #SCRIPTNAME#
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#SIGNATURE#using System;

#NAMESPACE#public interface #SCRIPTNAME#
{

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"dependencies": {
"com.cysharp.unitask": "2.3.3",
"com.unity.addressables": "1.21.2",
"com.mygamedevtools.script-template": "3.4.0",
"com.unity.addressables": "1.21.12",
"com.unity.feature.development": "1.0.1",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.2",
"com.unity.timeline": "1.7.4",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
Expand Down Expand Up @@ -44,7 +45,8 @@
"url": "https://package.openupm.com",
"scopes": [
"com.cysharp.unitask",
"com.openupm"
"com.openupm",
"com.mygamedevtools"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,35 @@ public interface ISceneLoader
/// </summary>
ISceneManager Manager { get; }

/// <summary>
/// Triggers a transition to a group of scens.
/// It will transition from the current active scene (<see cref="ISceneManager.GetActiveScene()"/>)
/// to a group of scenes (<paramref name="targetScenes"/>), with an optional intermediate loading scene (<paramref name="intermediateSceneInfo"/>).
/// 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.
/// Also, you can provide a scene that wasn't loaded from this scene loader to transition from, as the <paramref name="externalOriginScene"/>,
/// instead of transitioning from the current active scene.
/// The complete transition flow is:
/// <br/><br/>
/// 1. Load the intermediate scene (if provided).<br/>
/// 2. Unload the previous scene. <br/>
/// 3. Load all target scenes.<br/>
/// 4. Unload the intermediate scene (if provided).<br/>
/// </summary>
/// <param name="targetScenes">
/// A reference to all scenes that will be transitioned to.
/// </param>
/// <param name="setIndexActive">
/// Index of the scene in the <paramref name="targetScenes"/> to be set as the active scene.
/// </param>
/// <param name="intermediateSceneInfo">
/// A reference to the scene that's going to be loaded as the transition intermediate (as a loading scene).
/// If null, the transition will not have an intermediate loading scene.
/// </param>
/// <param name="externalOriginScene">
/// A reference to a scene loaded outside of this scene loader, instead of taking the current active scene as the origin scene.
/// </param>
void TransitionToScenes(ILoadSceneInfo[] targetScenes, int setIndexActive, ILoadSceneInfo intermediateSceneInfo = null, Scene externalOriginScene = default);

/// <summary>
/// Triggers a scene transition.
/// It will transition from the current active scene (<see cref="ISceneManager.GetActiveScene()"/>)
Expand All @@ -45,6 +74,14 @@ public interface ISceneLoader
/// </param>
void TransitionToScene(ILoadSceneInfo targetSceneInfo, ILoadSceneInfo intermediateSceneInfo = null, Scene externalOriginScene = default);

/// <summary>
/// Unloads all the scenes from the current scene stack.
/// </summary>
/// <param name="sceneInfos">
/// Reference to all scenes that will be unloaded.
/// </param>
void UnloadScenes(ILoadSceneInfo[] sceneInfos);

/// <summary>
/// Unloads the given scene from the current scene stack.
/// </summary>
Expand All @@ -53,6 +90,17 @@ public interface ISceneLoader
/// </param>
void UnloadScene(ILoadSceneInfo sceneInfo);

/// <summary>
/// Loads all scenes additively on top of the current scene stack, optionally marking one of them as the active scene.
/// </summary>
/// <param name="sceneInfos">
/// Reference to all scenes that will be loaded.
/// </param>
/// <param name="setIndexActive">
/// Which of the scenes should be marked as active? Default is -1.
/// </param>
void LoadScenes(ILoadSceneInfo[] sceneInfos, int setIndexActive = -1);

/// <summary>
/// Loads a scene additively on top of the current scene stack, optionally marking it as the active scene
/// (<see cref="ISceneManager.SetActiveScene(Scene)"/>).
Expand Down

0 comments on commit 87117e0

Please sign in to comment.