using Convention; using Demo.Attr; using System.Collections; using System.IO; using System.Linq; using UnityEngine; using UnityEngine.SceneManagement; namespace Demo.Game { [Scriptable] public class SubWorld : ScriptableObject { public static SubWorld Make() { return new GameObject().AddComponent(); } [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() 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(); } /// /// 加载附属场景 /// /// [Convention.RScript.Variable.Attr.Method] public void Load(string project) { this.project = project; } } }