Beispiel #1
0
        private static void AddDrawingDLLToRSP(string rsp_path)
        {
            string rsp_data = Helper.ReadFileIntoString(rsp_path);

            rsp_data += RSP_DRAWING_DLL_CODE;
            Helper.WriteStringToFile(rsp_data, rsp_path);
        }
Beispiel #2
0
        private static void GenerateRSP(string name)
        {
            string mcs_data = "-r:System.Drawing.dll";

            Helper.WriteStringToFile(mcs_data, MCS_NEEDED_PATH + name + ".rsp");
            AssetDatabase.Refresh();
            CheckMCS();
        }
        private void removeProperty(string path, string property, string value)
        {
            string       shaderCode = Helper.ReadFileIntoString(path);
            string       pattern    = @"\r?\n.*" + Regex.Escape(property) + " ?= ?" + value;
            RegexOptions options    = RegexOptions.Multiline;

            shaderCode = Regex.Replace(shaderCode, pattern, "", options);

            Helper.WriteStringToFile(shaderCode, path);
        }
        private void addProperty(string path, string property, string value)
        {
            string       shaderCode = Helper.ReadFileIntoString(path);
            string       pattern    = @"Properties.*\n?\s*{";
            RegexOptions options    = RegexOptions.Multiline;

            shaderCode = Regex.Replace(shaderCode, pattern, "Properties \r\n  {" + " \r\n      " + property + "=" + value, options);

            Helper.WriteStringToFile(shaderCode, path);
        }
        private void revertEditor(string path)
        {
            string shaderCode = Helper.ReadFileIntoString(path);
            string pattern    = @"//originalEditor.*\n";
            Match  m          = Regex.Match(shaderCode, pattern);

            if (m.Success)
            {
                string orignialEditor = m.Value.Replace("//originalEditor", "");
                pattern    = @"//originalEditor.*\n.*\n";
                shaderCode = Regex.Replace(shaderCode, pattern, orignialEditor);
                Helper.WriteStringToFile(shaderCode, path);
            }
        }
        public static void thry_vrc_tools_file_list_callback(string s)
        {
            string[] fileNames = Regex.Split(s, @"\r?\n");
            string   path      = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("ThrySettings")[0]);

            path = Regex.Replace(path, @"/Editor/ThrySettings.cs", "/ThryTools/");
            foreach (string file in fileNames)
            {
                Helper.downloadFileToPath(THRY_VRC_TOOLS_REPO_URL + file, path + file);
            }
            Helper.WriteStringToFile(thry_vrc_tools_version, path + THRY_VRC_TOOLS_VERSION_PATH + ".txt");
            has_vrc_tools = true;
            thry_vrc_tools_installed_version = thry_vrc_tools_version;
            Helper.RepaintEditorWindow(typeof(Settings));
        }
Beispiel #7
0
 private static void InstallModule(string url, string name)
 {
     EditorUtility.DisplayProgressBar(name + " download progress", "", 0);
     Helper.DownloadStringASync(url, delegate(string s)
     {
         if (s.StartsWith("404"))
         {
             Debug.LogWarning(s);
             return;
         }
         //Debug.Log(s);
         ModuleInfo module_info   = Parser.ParseToObject <ModuleInfo>(s);
         string thry_modules_path = ThryEditor.GetThryEditorDirectoryPath();
         string temp_path         = "temp_" + name;
         if (thry_modules_path == null)
         {
             thry_modules_path = "Assets";
         }
         thry_modules_path  += "/thry_modules";
         string install_path = thry_modules_path + "/" + name;
         string base_url     = url.RemoveFileName();
         Helper.WriteStringToFile(s, temp_path + "/module.json");
         int i = 0;
         foreach (string f in module_info.files)
         {
             //Debug.Log(base_url + f);
             Helper.DownloadFileASync(base_url + f, temp_path + "/" + f, delegate(string data)
             {
                 i++;
                 EditorUtility.DisplayProgressBar("Downloading files for " + name, "Downloaded " + base_url + f, (float)i / module_info.files.Count);
                 if (i == module_info.files.Count)
                 {
                     EditorUtility.ClearProgressBar();
                     if (!Directory.Exists(thry_modules_path))
                     {
                         Directory.CreateDirectory(thry_modules_path);
                     }
                     Directory.Move(temp_path, install_path);
                     AssetDatabase.Refresh();
                 }
             });
         }
     });
 }
        private void replaceEditorInShader(string path, string newEditor)
        {
            string shaderCode = Helper.ReadFileIntoString(path);
            string pattern    = @"CustomEditor ?.*\n";
            Match  m          = Regex.Match(shaderCode, pattern);

            if (m.Success)
            {
                string oldEditor = "//originalEditor" + m.Value;
                shaderCode = Regex.Replace(shaderCode, pattern, oldEditor + "CustomEditor \"" + newEditor + "\"\r\n");
            }
            else
            {
                pattern = @"SubShader.*\r?\n?\s*{";
                RegexOptions options = RegexOptions.Multiline;
                shaderCode = Regex.Replace(shaderCode, pattern, "CustomEditor \"" + newEditor + "\" \r\n    SubShader \r\n  {", options);
            }

            Helper.WriteStringToFile(shaderCode, path);
        }
Beispiel #9
0
        public static void backupSingleMaterial(Material m)
        {
            if (restoring_in_progress)
            {
                return;
            }
            string[] mats = new string[0];
            if (!File.Exists(MATERIALS_BACKUP_FILE_PATH))
            {
                File.CreateText(MATERIALS_BACKUP_FILE_PATH).Close();
            }
            else
            {
                mats = Helper.ReadFileIntoString(MATERIALS_BACKUP_FILE_PATH).Split(new string[] { "\n" }, System.StringSplitOptions.None);
            }
            bool   updated   = false;
            string matGuid   = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m.GetInstanceID()));
            string newString = "";

            for (int mat = 0; mat < mats.Length; mat++)
            {
                if (mats[mat].Contains(matGuid))
                {
                    updated    = true;
                    newString += matGuid + ":" + Helper.getDefaultShaderName(m.shader.name) + ":" + m.renderQueue + "\r\n";
                }
                else
                {
                    newString += mats[mat] + "\n";
                }
            }
            if (!updated)
            {
                newString += matGuid + ":" + Helper.getDefaultShaderName(m.shader.name) + ":" + m.renderQueue;
            }
            else
            {
                newString = newString.Substring(0, newString.LastIndexOf("\n"));
            }
            Helper.WriteStringToFile(newString, MATERIALS_BACKUP_FILE_PATH);
        }
Beispiel #10
0
 public void save()
 {
     Helper.WriteStringToFile(JsonUtility.ToJson(this), PATH_CONFIG_FILE);
 }
Beispiel #11
0
 private static void Save()
 {
     Helper.WriteStringToFile(Parser.ObjectToString(thry_editor_shaders), PATH.THRY_EDITOR_SHADERS);
 }