示例#1
0
        public override IEnumerable <QuickOpenEntryMeta> GetQuickOpenEntries()
        {
            var           cacheFile = PathManager.OpenedSceneFileCachePath();
            List <string> ids       = null;

            if (File.Exists(cacheFile))
            {
                ids = File.ReadAllLines(cacheFile).Reverse().ToList();
            }

            var guids = AssetDatabase.FindAssets("t:Scene");

            if (ids != null)
            {
                foreach (var id in guids)
                {
                    if (ids.Contains(id))
                    {
                        continue;
                    }
                    ids.Add(id);
                }
            }
            else
            {
                ids = guids.ToList();
            }

            List <QuickOpenEntryMeta> data = new List <QuickOpenEntryMeta>();

            foreach (var id in ids)
            {
                if (string.IsNullOrEmpty(id))
                {
                    continue;
                }

                QuickOpenEntryMeta meta = new QuickOpenEntryMeta();
                meta.id = id;

                var scenePath = AssetDatabase.GUIDToAssetPath(id);
                meta.label       = Path.GetFileNameWithoutExtension(scenePath);
                meta.description = Path.GetDirectoryName(scenePath).Replace("\\", "/");
                meta.icon        = "scene";

                data.Add(meta);
            }

            return(data);
        }
示例#2
0
        private void SaveOpenedId(string id)
        {
            var cacheFile = PathManager.OpenedSceneFileCachePath();

            if (File.Exists(cacheFile))
            {
                var ids = File.ReadAllLines(cacheFile).ToList();
                if (ids.Contains(id))
                {
                    ids.Remove(id);
                }

                ids.Add(id);

                File.WriteAllLines(cacheFile, ids.ToArray());
            }
            else
            {
                File.WriteAllLines(cacheFile, new string[] { id });
            }
        }