Exemplo n.º 1
0
        public static void Save()
        {
            string lastPath = ")@#(*$";
            var    time     = FileManager.GetTime();

            FileManager.Create("Temp");
            using (var output = new StreamWriter("Temp/FileManager.data", false)){
                output.WriteLine("[Files]");
                foreach (var item in FileManager.filesByType)
                {
                    var extension = item.Key;
                    var files     = item.Value;
                    output.WriteLine("(" + extension + ")");
                    foreach (var file in files)
                    {
                        FileManager.SaveData(file, output, ref lastPath);
                    }
                }
                output.WriteLine("[Folders]");
                foreach (var item in FileManager.folders)
                {
                    FileManager.SaveData(item.Value, output, ref lastPath);
                }
            }
            if (FileManager.clock)
            {
                Debug.Log("[FileManager] : Save cache complete -- " + (FileManager.GetTime() - time) + " seconds.");
            }
        }
Exemplo n.º 2
0
        public static void Save()
        {
            string lastPath  = ")@#(*$";
            var    time      = FileManager.GetTime();
            var    cachePath = Application.isEditor ? "Temp/FileManager.data" : FileManager.root + "/FileManager.data";

            if (Application.isEditor)
            {
                FileManager.Create("Temp");
            }
            using (var output = new StreamWriter(cachePath, false)){
                foreach (var item in FileManager.filesByType)
                {
                    var extension = item.Key;
                    var files     = item.Value;
                    output.WriteLine("(" + extension + ")");
                    foreach (var file in files)
                    {
                        FileManager.SaveData(file, output, ref lastPath);
                    }
                }
            }
            if (FileManager.clock)
            {
                Debug.Log("[FileManager] : Save cache complete -- " + (FileManager.GetTime() - time) + " seconds.");
            }
        }
Exemplo n.º 3
0
        public static void WriteFile(string path, byte[] bytes)
        {
            if (!FileManager.Exists(path))
            {
                FileManager.Create(path);
            }
            FileStream   stream = new FileStream(path, FileMode.Create);
            BinaryWriter file   = new BinaryWriter(stream);

            file.Write(bytes);
            file.Close();
            stream.Close();
        }
Exemplo n.º 4
0
        public static void WriteFile(string path, byte[] bytes)
        {
            var folder = path.GetDirectory();

            if (!FileManager.Exists(folder))
            {
                FileManager.Create(folder);
            }
            FileStream   stream = new FileStream(path, FileMode.Create);
            BinaryWriter file   = new BinaryWriter(stream);

            file.Write(bytes);
            file.Close();
            stream.Close();
        }
        public static ScriptableObject CreateSingleton(string path, bool createPath = true)
        {
            var name   = path.GetPathTerm();
            var folder = Application.dataPath + "/" + path.TrimLeft("Assets/").GetDirectory();

            if (createPath)
            {
                FileManager.Create(folder);
            }
            AssetDatabase.ImportAsset(folder.GetAssetPath());
            try{
                var instance = ScriptableObject.CreateInstance(name);
                AssetDatabase.CreateAsset(instance, path + ".asset");
                AssetDatabase.Refresh();
                return(instance);
            }
            catch { Debug.LogWarning("[Utility] No scriptableObject exists named -- " + name + ".asset"); }
            return(null);
        }
Exemplo n.º 6
0
        public static FileData Create(string path)
        {
            path = Path.GetFullPath(path).Replace("\\", "/");
            var data = new FileData(path);

            if (!data.name.IsEmpty())
            {
                var folder = path.GetDirectory();
                if (!FileManager.Exists(folder))
                {
                    FileManager.Create(folder);
                }
                File.Create(path).Dispose();
            }
            else
            {
                data.isFolder = true;
                Directory.CreateDirectory(path);
            }
            FileManager.BuildCache(data);
            return(data);
        }
Exemplo n.º 7
0
        public static void SaveCSS(string path, GUISkin skin)
        {
            var output    = new StringBuilder();
            var emptySkin = ScriptableObject.CreateInstance <GUISkin>();

            foreach (var item in skin.GetVariables <GUIStyle>(null, ObjectExtension.publicFlags))
            {
                var defaultStyle = emptySkin.GetVariable <GUIStyle>(item.Key);
                output.Append(Style.SaveCSS(item.Value, defaultStyle));
            }
            foreach (var style in skin.customStyles)
            {
                if (style.IsNull())
                {
                    continue;
                }
                output.Append(Style.SaveCSS(style, null, false));
            }
            if (output.Length > 0)
            {
                var file = FileManager.Create(path + "/" + skin.name.Split("-")[0] + "/" + skin.name + ".css");
                file.WriteText(output.ToString().Trim());
            }
        }