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); }
private static string readShaderName(string path) { string shaderCode = Helper.ReadFileIntoString(path); string pattern = @"Shader *""(\w|\/|\.)+"; string ogShaderName = Regex.Match(shaderCode, pattern).Value; ogShaderName = Regex.Replace(ogShaderName, @"Shader *""", ""); return(ogShaderName); }
//load the config from file private static Config LoadConfig() { if (File.Exists(PATH_CONFIG_FILE)) { return(JsonUtility.FromJson <Config>(Helper.ReadFileIntoString(PATH_CONFIG_FILE))); } new Config().save(); return(new Config()); }
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 static void InitInstalledModule(ModuleHeader m) { if (Helper.ClassExists(m.available_module.classname)) { string path = GetModuleDirectoryPath(m) + "/module.json"; if (File.Exists(path)) { m.installed_module = Parser.ParseToObject <ModuleInfo>(Helper.ReadFileIntoString(path)); } } }
private static void LoadThryEditorShaders() { string data = Helper.ReadFileIntoString(PATH.THRY_EDITOR_SHADERS); if (data != "") { shaders = Parser.ParseToObject <List <ThryEditorShader> >(data); } else { SearchAllShadersForThryEditorUsage(); } }
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); } }
private string GetInstalledSDKVersionAndInitPath() { string[] guids = AssetDatabase.FindAssets("version"); string path = null; foreach (string guid in guids) { string p = AssetDatabase.GUIDToAssetPath(guid); if (p.Contains("VRCSDK/version")) { path = p; } } if (path == null || !File.Exists(path)) { return(""); } sdk_path = Regex.Match(path, @".*\/").Value; return(Helper.ReadFileIntoString(path)); }
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); }
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); }
private static bool TestShaderForThryEditor(string path) { string code = Helper.ReadFileIntoString(path); if (ShaderUsesThryEditor(code)) { ThryEditorShader shader = new ThryEditorShader(); shader.path = path; Match name_match = Regex.Match(code, @"(?<=[Ss]hader)\s*\""[^\""]+(?=\""\s*{)"); if (name_match.Success) { shader.name = name_match.Value.TrimStart(new char[] { ' ', '"' }); } Match master_label_match = Regex.Match(code, @"\[HideInInspector\]\s*shader_master_label\s*\(\s*\""[^\""]*(?=\"")"); if (master_label_match.Success) { shader.version = GetVersionFromMasterLabel(master_label_match.Value); } thry_editor_shaders.Add(shader); return(true); } return(false); }
private static bool DoesRSPContainDrawingDLL(string rsp_path) { string rsp_data = Helper.ReadFileIntoString(rsp_path); return(rsp_data.Contains(RSP_DRAWING_DLL_CODE)); }