コード例 #1
0
        private IEnumerator PreloadDefaultSabers()
        {
            FirstFetch = false;

            //Logger.Log("Preloading default sabers!", LogLevel.Debug);
            //HarmonyInstance harmony = HarmonyInstance.Create("CustomSaberHarmonyInstance");
            //harmony.PatchAll(Assembly.GetExecutingAssembly());

            Logger.Log("Loading GameCore scene");
            SceneManager.LoadSceneAsync("GameCore", LoadSceneMode.Additive);
            Logger.Log("Loaded!");

            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Count() > 1));

            Logger.Log("Got sabers!");

            foreach (var s in Resources.FindObjectsOfTypeAll <Saber>())
            {
                Logger.Log($"Saber: {s.name}, GameObj: {s.gameObject.name}, {s.ToString()}");
                if (s.name == "LeftSaber")
                {
                    LeftSaber = Saber.Instantiate(s);
                }
                else if (s.name == "RightSaber")
                {
                    RightSaber = Saber.Instantiate(s);
                }
            }
            Logger.Log("Finished! Got default sabers! Setting active state");

            if (LeftSaber)
            {
                Object.DontDestroyOnLoad(LeftSaber.gameObject);
                LeftSaber.gameObject.SetActive(false);
                LeftSaber.name = "___OriginalSaberPreviewB";
            }

            if (RightSaber)
            {
                Object.DontDestroyOnLoad(RightSaber.gameObject);
                RightSaber.gameObject.SetActive(false);
                RightSaber.name = "___OriginalSaberPreviewA";
            }

            Logger.Log("Unloading GameCore");
            SceneManager.UnloadSceneAsync("GameCore");

            //Logger.Log("Unloading harmony patches", LogLevel.Debug);
            //harmony.UnpatchAll("CustomSaberHarmonyInstance");
        }