private void SaveSummaryToFile() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Shader Name").Append(',') .Append("Shader Types").Append(',') .Append("Pass Types").Append(',') .Append("Variant Count").Append(',') .Append("Keywords").Append(',') .Append('\n'); int totalVariantCount = 0; HashSet <string> totalKeywords = new HashSet <string>(); foreach (KeyValuePair <string, ShaderInfo> kv in m_ShaderInfos) { ShaderInfo shaderInfo = kv.Value; totalVariantCount += shaderInfo.VariantCount; foreach (string keyword in shaderInfo.Keywords) { totalKeywords.Add(keyword); } stringBuilder.Append(kv.Key).Append(',') .Append(string.Join(";", shaderInfo.ShaderTypes)).Append(',') .Append(string.Join(";", shaderInfo.PassTypes)).Append(',') .Append(shaderInfo.VariantCount).Append(',') .Append(string.Join(";", shaderInfo.Keywords)).Append(',') .Append('\n'); } string reportString = stringBuilder.ToString(); stringBuilder.Clear() .Append("Total Variant Count").Append(',').Append(totalVariantCount).Append('\n') .Append("Total Keywords").Append(',').Append(string.Join(";", totalKeywords)).Append('\n') .Append('\n'); reportString = stringBuilder.ToString() + reportString; try { string path = m_ReportDirectory + "/Summary.csv"; File.WriteAllText(path, reportString); MDebug.Log("Shader" , "Save PreprocessShaderReport Summary to " + MDebug.FormatPathToHyperLink(path)); } catch (Exception e) { MDebug.LogError("Shader" , "Save PreprocessShaderReport Summary Exception:\n" + e.ToString()); } stringBuilder.Clear(); stringBuilder.Append("Shader Name").Append(',') .Append("Variant Count").Append(',') .Append("\n"); foreach (KeyValuePair <string, int> kv in m_BuiltinShaders) { stringBuilder.Append(kv.Key).Append(",") .Append(kv.Value).Append(",") .Append("\n"); } try { string path = m_ReportDirectory + "/Builtin.csv"; File.WriteAllText(path, stringBuilder.ToString()); MDebug.Log("Shader" , "Save PreprocessShaderReport Builtin to " + MDebug.FormatPathToHyperLink(path)); } catch (Exception e) { MDebug.LogError("Shader" , "Save PreprocessShaderReport Builtin Exception:\n" + e.ToString()); } }