Example #1
0
        public static string[] GetScenesInBuild(bool includeDisabled = false)
        {
            var scenesForBuild = EditorBuildSettings.scenes;
            var scenesInBuild  = new List <string>(scenesForBuild.Length);

            foreach (var sceneInBuild in scenesForBuild)
            {
                if (sceneInBuild.enabled || includeDisabled)
                {
                    scenesInBuild.Add(CSPathTools.EnforceSlashes(sceneInBuild.path));
                }
            }
            return(scenesInBuild.ToArray());
        }
Example #2
0
        public static void ReSaveAllScenes()
        {
            EditorUtility.DisplayProgressBar("Re-saving scenes...", "Looking for scenes...", 0);
            var allScenesGuids = AssetDatabase.FindAssets("t:Scene");

            for (var i = 0; i < allScenesGuids.Length; i++)
            {
                var guid = allScenesGuids[i];
                EditorUtility.DisplayProgressBar("Re-saving scenes...", string.Format("Scene {0} of {1}", i + 1, allScenesGuids.Length), (float)i / allScenesGuids.Length);

                var scenePath = AssetDatabase.GUIDToAssetPath(guid);
                scenePath = CSPathTools.EnforceSlashes(scenePath);

                var result = OpenScene(scenePath);

                EditorSceneManager.MarkSceneDirty(result.scene);
                EditorSceneManager.SaveScene(result.scene);

                CloseOpenedSceneIfNeeded(result);
            }

            EditorUtility.ClearProgressBar();
        }
        public static bool IsValueMatchesAnyFilterOfKind(string value, FilterItem[] filters, FilterKind onlyThisKind, bool strict = false)
        {
            var match     = false;
            var directory = string.Empty;
            var filename  = string.Empty;
            var extension = string.Empty;

            foreach (var filter in filters)
            {
                if (onlyThisKind != FilterKind.NotSet)
                {
                    if (filter.kind != onlyThisKind)
                    {
                        continue;
                    }
                }

                switch (filter.kind)
                {
                case FilterKind.Path:
                case FilterKind.Type:
                    match = FilterMatchHelper(value, filter, strict);
                    break;

                case FilterKind.Directory:
                    if (directory == string.Empty)
                    {
                        directory = Path.GetDirectoryName(value);
                        if (directory != null)
                        {
                            directory = CSPathTools.EnforceSlashes(directory);
                        }
                    }

                    if (directory != null)
                    {
                        match = FilterMatchHelper(directory, filter, strict);
                    }
                    break;

                case FilterKind.FileName:
                    if (filename == string.Empty)
                    {
                        filename = Path.GetFileName(value);
                        if (filename != null)
                        {
                            filename = CSPathTools.EnforceSlashes(filename);
                        }
                    }
                    if (filename != null)
                    {
                        match = FilterMatchHelper(filename, filter, strict);
                    }
                    break;

                case FilterKind.Extension:
                    if (extension == string.Empty)
                    {
                        extension = Path.GetExtension(value);
                    }
                    match = string.Equals(extension, filter.value, StringComparison.OrdinalIgnoreCase);
                    break;

                case FilterKind.NotSet:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (match)
                {
                    break;
                }
            }

            return(match);
        }