public async void LoadSceneSetAsync(bool additive, float 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)
                    {
                        await SceneManager.LoadSceneAsync(scene,
                                                          firstScene?LoadSceneMode.Single : LoadSceneMode.Additive);
                    }
                    else
                    {
                        EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset),
                                                     firstScene ? OpenSceneMode.Single : OpenSceneMode.Additive);
                    }
#else
                    await SceneManager.LoadSceneAsync(scene, firstScene?LoadSceneMode.Single : LoadSceneMode.Additive);
#endif
                    firstScene = false;
                }

                onSceneLoaded.Invoke(scene, i + 1);

                await Task.Delay((int)(artificialWait * 1000));
            }
        }
        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;
        }
Exemple #3
0
        /// <summary>
        ///     Draws the scene entry
        /// </summary>
        private void DrawSceneEntry(SceneField scene)
        {
            EditorGUILayout.ObjectField(scene.SceneAsset, typeof(SceneAsset), true);

            if (SOFlowEditorUtilities.DrawColourButton("Load", SOFlowEditorSettings.AcceptContextColour))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Additive);
            }

            if (SOFlowEditorUtilities.DrawColourButton("Replace", Color.yellow))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Single);
            }

            if (SOFlowEditorUtilities.DrawColourButton("Unload", SOFlowEditorSettings.DeclineContextColour))
            {
                EditorSceneManager
                .CloseScene(SceneManager.GetSceneByPath(AssetDatabase.GetAssetPath(scene.SceneAsset)), true);
            }
        }
        /// <summary>
        /// Draws the scene entry
        /// </summary>
        private void DrawSceneEntry(SceneField scene)
        {
            EditorGUILayout.ObjectField(scene.SceneAsset, typeof(SceneAsset), true);

            if (GUILayout.Button("Load"))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Additive);
            }

            if (GUILayout.Button("Replace"))
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(scene.SceneAsset), OpenSceneMode.Single);
            }

            if (GUILayout.Button("Unload"))
            {
                EditorSceneManager
                .CloseScene(SceneManager.GetSceneByPath(AssetDatabase.GetAssetPath(scene.SceneAsset)), true);
            }
        }