2025-09-25 19:04:05 +08:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Convention;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
|
|
namespace Demo.Game
|
|
|
|
|
{
|
|
|
|
|
public class SubWorld : ScriptableObject
|
|
|
|
|
{
|
|
|
|
|
public static SubWorld Make()
|
|
|
|
|
{
|
|
|
|
|
return new GameObject().AddComponent<SubWorld>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Content, SerializeField] private string project;
|
|
|
|
|
[Content, SerializeField] private GameController SubWorldGameController;
|
|
|
|
|
|
|
|
|
|
public override IEnumerator LoadScript(string script)
|
|
|
|
|
{
|
|
|
|
|
yield return base.LoadScript(script);
|
|
|
|
|
/*
|
|
|
|
|
// Load
|
|
|
|
|
var content = GameContent.instance;
|
|
|
|
|
// Always
|
|
|
|
|
content.IsCreateNewProject = false;
|
|
|
|
|
// Push Content
|
|
|
|
|
var oldContentRootSourceDir = content.RootSourceDir;
|
|
|
|
|
var oldSetupSongDuration = content.SetupSongDuration;
|
|
|
|
|
var oldSetSongCurrentTime = content.SetSongCurrentTime;
|
|
|
|
|
// Setting New
|
|
|
|
|
content.RootSourceDir = Path.Combine(PlatformIndicator.StreamingAssetsPath, project) + "/";
|
|
|
|
|
content.SetupSongDuration = (x, y) => { };
|
|
|
|
|
content.SetSongCurrentTime = x => { };
|
|
|
|
|
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
|
|
|
|
|
ir.completed += x =>
|
|
|
|
|
{
|
|
|
|
|
SubWorldGameController = (from controller in FindObjectsOfType<GameController>()
|
|
|
|
|
where controller.RootSourcePath == project
|
|
|
|
|
select controller).First();
|
|
|
|
|
};
|
|
|
|
|
yield return ir;
|
|
|
|
|
// Pull Content
|
|
|
|
|
content.RootSourceDir = oldContentRootSourceDir;
|
|
|
|
|
content.SetupSongDuration = oldSetupSongDuration;
|
|
|
|
|
content.SetSongCurrentTime = oldSetSongCurrentTime;
|
|
|
|
|
*/
|
|
|
|
|
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
|
|
|
|
|
IEnumerator after = null;
|
|
|
|
|
ir.completed += x =>
|
|
|
|
|
{
|
|
|
|
|
SubWorldGameController = (from controller in FindObjectsOfType<GameController>()
|
|
|
|
|
where controller.RootSourcePath == project
|
|
|
|
|
select controller).First();
|
|
|
|
|
after = SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch);
|
|
|
|
|
};
|
|
|
|
|
yield return ir;
|
|
|
|
|
yield return after;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerator UnloadScript()
|
|
|
|
|
{
|
|
|
|
|
yield return SubWorldGameController.GameExit();
|
|
|
|
|
yield return base.UnloadScript();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载附属场景
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="project"></param>
|
2025-10-27 20:24:15 +08:00
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
2025-09-25 19:04:05 +08:00
|
|
|
public void Load(string project)
|
|
|
|
|
{
|
|
|
|
|
this.project = project;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|