49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
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;
|
|
|
|
protected override IEnumerator DoSomethingDuringApplyScript()
|
|
{
|
|
yield return base.DoSomethingDuringApplyScript();
|
|
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();
|
|
ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch));
|
|
};
|
|
}
|
|
|
|
public override IEnumerator UnloadScript()
|
|
{
|
|
yield return SubWorldGameController.GameExit();
|
|
yield return base.UnloadScript();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载附属场景
|
|
/// </summary>
|
|
/// <param name="project"></param>
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public void Load(string project)
|
|
{
|
|
this.project = project;
|
|
}
|
|
}
|
|
} |