예제 #1
0
        private static void InstallModuleFilesDownloaded(Module module, string temp_dir)
        {
            string modules_path = "Assets/thry_modules";

            if (!Directory.Exists(modules_path))
            {
                AssetDatabase.CreateFolder("Assets", "thry_modules");
            }
            string install_path = modules_path + "/" + module.id;

            module.installed_module = module.available_module;
            string guid = AssetDatabase.CreateFolder(modules_path, module.id);

            SaveModuleLocationData(module, guid);

            FileHelper.WriteStringToFile(Parser.ObjectToString(module.available_module), temp_dir + "/module.json");
            foreach (string d in Directory.GetDirectories(temp_dir))
            {
                Directory.Move(d, install_path + "/" + Path.GetFileName(d));
            }
            foreach (string f in Directory.GetFiles(temp_dir))
            {
                File.Move(f, install_path + "/" + Path.GetFileName(f));
            }
            Directory.Delete(temp_dir);
            AssetDatabase.Refresh();
        }
예제 #2
0
        private static void Save()
        {
            Dictionary <string, List <Material> > save_linked_materials = new Dictionary <string, List <Material> >(linked_materials);

            List <string[]>  save_structre          = new List <string[]>();
            HashSet <string> has_already_been_saved = new HashSet <string>();

            foreach (KeyValuePair <string, List <Material> > link in save_linked_materials)
            {
                if (has_already_been_saved.Contains(link.Key))
                {
                    continue;
                }
                string[] value = new string[link.Value.Count + 1];
                value[0] = System.Text.RegularExpressions.Regex.Split(link.Key, @"###")[1];
                int i = 1;
                foreach (Material m in link.Value)
                {
                    string guid = UnityHelper.GetGUID(m);
                    has_already_been_saved.Add(guid + "###" + value[0]);
                    value[i++] = guid;
                }
                save_structre.Add(value);
            }
            FileHelper.WriteStringToFile(Parser.ObjectToString(save_structre), PATH.LINKED_MATERIALS_FILE);
        }
예제 #3
0
        private static void SaveModuleLocationData(Module m, string guid)
        {
            ModuleLocationData locationData = new ModuleLocationData();

            locationData.guid      = guid;
            locationData.classname = m.installed_module.classname;
            locationData.files     = m.installed_module.files.ToArray();
            FileHelper.SaveValueToFile(m.id, Parser.ObjectToString(locationData), PATH.MODULES_LOCATION__DATA);
        }
예제 #4
0
        private void TextureSettingsGUI()
        {
            EditorGUIUtility.labelWidth = 100;
            EditorGUIUtility.fieldWidth = 150;
            EditorGUILayout.LabelField("Texture options:", EditorStyles.boldLabel);
            bool changed = GuiHelper.GUIDataStruct <TextureData>(textureSettings, new string[] { "name" });

            if (changed)
            {
                FileHelper.SaveValueToFile("gradient_texture_options_" + prop.name, Parser.ObjectToString(textureSettings), PATH.PERSISTENT_DATA);
                UpdateGradientPreviewTexture();
            }
        }
 public void OnDestroy()
 {
     if (gradient_has_been_edited)
     {
         if (data.preview_texture.GetType() == typeof(Texture2D))
         {
             string  file_name = GradientFileName(data.gradient, prop.targets[0].name);;
             Texture saved     = Helper.SaveTextureAsPNG((Texture2D)data.preview_texture, "Assets/Textures/Gradients/" + file_name, textureSettings);
             file_name = Regex.Replace(file_name, @"\.((png)|(jpg))$", "");
             Helper.SaveValueToFile(file_name, Parser.ObjectToString(data.gradient), ".thry_gradients");
             prop.textureValue = saved;
         }
     }
     else
     {
         UpdatePreviewTexture(privious_preview_texture);
     }
 }
예제 #6
0
 public void OnDestroy()
 {
     if (gradient_has_been_edited)
     {
         if (data.preview_texture.GetType() == typeof(Texture2D))
         {
             string  file_name = GradientFileName(data.gradient, prop.targets[0].name);
             Texture saved     = TextureHelper.SaveTextureAsPNG((Texture2D)data.preview_texture, PATH.TEXTURES_DIR + "/Gradients/" + file_name, textureSettings);
             file_name = Regex.Replace(file_name, @"\.((png)|(jpg))$", "");
             FileHelper.SaveValueToFile(file_name, Parser.ObjectToString(data.gradient), PATH.GRADIENT_INFO_FILE);
             prop.textureValue = saved;
         }
     }
     else
     {
         UpdatePreviewTexture(privious_preview_texture);
     }
 }
예제 #7
0
 private static void Save()
 {
     Helper.WriteStringToFile(Parser.ObjectToString(thry_editor_shaders), PATH.THRY_EDITOR_SHADERS);
 }
예제 #8
0
파일: Parser.cs 프로젝트: rurre/ThryEditor
 public static string Serialize(object o)
 {
     return(Parser.ObjectToString(o));
 }