コード例 #1
0
        public async void LoadSceneSetAsync(bool additive, int artificialWait, Action <SceneField, int> onSceneLoaded)
        {
            bool firstScene = !additive;

            for (int i = 0, condition = SetScenes.Count; i < condition; i++)
            {
                SceneField scene = SetScenes[i];

                if (scene.SceneAsset || !string.IsNullOrEmpty(scene.SceneName))
                {
#if UNITY_EDITOR
                    if (Application.isPlaying)
                    {
                        SceneManager.LoadSceneAsync(scene, firstScene ? LoadSceneMode.Single : LoadSceneMode.Additive);
                    }
                    else
                    {
                        EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset),
                                                     firstScene ? OpenSceneMode.Single : OpenSceneMode.Additive);
                    }
#else
                    SceneManager.LoadSceneAsync(scene, firstScene ? LoadSceneMode.Single : LoadSceneMode.Additive);
#endif
                    firstScene = false;
                }

                onSceneLoaded.Invoke(scene, i + 1);

                await Task.Delay(artificialWait);
            }
        }
コード例 #2
0
        public static void CreateSceneSetFromScene()
        {
            SceneSet newSceneSet = CreateInstance <SceneSet>();

            SceneField newSceneField = new SceneField
            {
                SceneAsset = Selection.activeObject, SceneName = Selection.activeObject.name
            };

            newSceneSet.SetScenes.Add(newSceneField);

            AssetDatabase.CreateAsset(newSceneSet,
                                      AssetDatabase.GetAssetPath(Selection.activeObject)
                                      .Replace(".unity", " Scene Set.asset"));

            AssetDatabase.Refresh();

            Selection.activeObject = newSceneSet;
        }