public static void         RecreateCache()
 {
     File.Delete(EditorTools.GetFerrDirectory() + cacheFile);
     trackTypes = null;
     components = null;
     CheckInitialization();
 }
        static bool LoadCache()
        {
            StreamReader reader = new StreamReader(EditorTools.GetFerrDirectory() + cacheFile);

            string[] lines = reader.ReadToEnd().Split('\n');

            if (lines.Length > 0 && lines[0] != "v" + version)
            {
                Debug.LogFormat("Cache version mismatch, rebuilding! {0}->{1}", lines[0], "v" + version);
                reader.Close();
                return(false);
            }

            Type currType = null;

            for (int i = 1; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (line.StartsWith("["))
                {
                    line     = line.Replace("[", "").Replace("]", "");
                    currType = GetTypeFromName(line);
                }
                else if (line != "")
                {
                    AddComponent(currType, line);
                }
            }
            reader.Close();

            return(true);
        }
 static bool HasCache()
 {
     if (!File.Exists(EditorTools.GetFerrDirectory() + cacheFile))
     {
         return(false);
     }
     return(true);
 }
        static void SaveCache()
        {
            if (!Directory.Exists(Path.GetDirectoryName(EditorTools.GetFerrDirectory() + cacheFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(EditorTools.GetFerrDirectory() + cacheFile));
            }

            string file = "v" + version + "\n";

            foreach (var itemList in components)
            {
                file += "\n[" + itemList.Key.Name + "]\n";
                foreach (var item in itemList.Value)
                {
                    file += item.Key + "\n";
                }
            }

            StreamWriter writer = new StreamWriter(EditorTools.GetFerrDirectory() + cacheFile);

            writer.Write(file);
            writer.Close();
        }
Exemplo n.º 5
0
        static void LoadCache()
        {
            StreamReader reader = new StreamReader(EditorTools.GetFerrDirectory() + cacheFile);

            string[] lines = reader.ReadToEnd().Split('\n');

            Type currType = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (line.StartsWith("["))
                {
                    line     = line.Replace("[", "").Replace("]", "");
                    currType = GetTypeFromName(line);
                }
                else if (line != "")
                {
                    AddComponent(currType, line);
                }
            }
            reader.Close();
        }