public void DumpStart() { if (shaderDumpInfo != null) { return; } this.shaderDumpInfo = new ShaderDumpInfo(this.shader); var dumpBtn = this.element.Q <Button>("DumpButton"); // add progress dumpProgress = new DumpProgressUI(); dumpProgress.style.width = 200; dumpBtn.parent.Add(dumpProgress); // dumpBtn.parent.Remove(dumpBtn); EditorApplication.update += Update; }
public void Remove() { this.shaderDumpInfo = null; this.element.parent.Remove(this.element); }
public void OnGUIShader() { if (shader == null) { return; } EditorGUI.indentLevel++; EditorGUILayout.ObjectField(shader, typeof(Shader), false); bool hasShaderCode = HasShaderCode(shader); EditorGUILayout.LabelField("isSupported:" + shader.isSupported); EditorGUILayout.LabelField("shaderCode:" + hasShaderCode); var shaderData = ShaderUtil.GetShaderData(shader); EditorGUILayout.LabelField("SubShader Count:" + shaderData.SubshaderCount); EditorGUILayout.LabelField(""); for (int i = 0; i < shaderData.SubshaderCount; ++i) { var subShader = shaderData.GetSubshader(i); EditorGUILayout.LabelField("SubShader " + i + "(PassCount:" + subShader.PassCount + ")"); EditorGUI.indentLevel++; for (int j = 0; j < subShader.PassCount; ++j) { var pass = subShader.GetPass(j); EditorGUILayout.LabelField("PassName \"" + pass.Name + "\""); EditorGUI.indentLevel++; if (!hasShaderCode || string.IsNullOrEmpty(pass.SourceCode)) { EditorGUILayout.LabelField("No SourceCode"); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(EditorGUI.indentLevel * 11.0f)); if (GUILayout.Button("CopySourceToClip")) { EditorGUIUtility.systemCopyBuffer = pass.SourceCode; } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(EditorGUI.indentLevel * 11.0f)); if (GUILayout.Button("Dump ShaderVaritansts")) { var dumpInfo = new ShaderDumpInfo(shader); string jsonString = JsonUtility.ToJson(dumpInfo); string file = shader.name.Replace("/", "_") + ".json"; System.IO.File.WriteAllText(file, jsonString); Debug.Log(jsonString); EditorUtility.DisplayDialog("Saved", "Dump saved \"" + file + "\"", "ok"); } EditorGUILayout.EndHorizontal(); // Debug /* * DoDrawDefaultInspector(new SerializedObject(shader)); * if(GUILayout.Button("Debug")) * { * DebugSerializedObject(new SerializedObject(shader)); * } */ EditorGUI.indentLevel--; }