private void CreateSubShaderMenu(Foldout subShaderFold, int idx, ShaderData.Subshader subShader) { subShaderFold.text = "SubShader " + idx + " PassNum:" + subShader.PassCount; for (int i = 0; i < subShader.PassCount; ++i) { var pass = subShader.GetPass(i); var label = new Label("PassName:" + pass.Name); subShaderFold.Add(label); } }
void ProcessShader(Shader target, bool force = false) { // Reset if (target == null) { m_Keywords.Clear(); m_Passes.Clear(); m_SelectedPass = -1; m_Target = null; m_PassNames = null; } else if (target != m_Target || force) { m_Keywords.Clear(); m_Passes.Clear(); if (!force) { m_SelectedPass = 0; } m_Target = target; ShaderData data = ShaderUtil.GetShaderData(target); List <string> names = new List <string>(); StringBuilder sb = new StringBuilder(k_MaxHintLength * 3); for (int sub = 0; sub < data.SubshaderCount; sub++) { ShaderData.Subshader subshader = data.GetSubshader(sub); for (int p = 0; p < subshader.PassCount; p++) { PassInfo passInfo = new PassInfo(); passInfo.subShader = sub; passInfo.pass = subshader.GetPass(p); passInfo.name = passInfo.pass.Name; ParseKeywords(passInfo.pass.SourceCode, ref passInfo.keywords); // Create some label hints for (int i = 0; i < passInfo.keywords.Count; i++) { for (int j = 0; j < passInfo.keywords[i].Count; j++) { if (passInfo.keywords[i][j].Length > 0) { sb.Append(passInfo.keywords[i][j]); if (sb.Length > k_MaxHintLength) { sb.Remove(k_MaxHintLength, sb.Length - k_MaxHintLength); sb[15] = '.'; sb[16] = '.'; sb[17] = '.'; break; } else if (sb.Length == k_MaxHintLength) { break; } else if (j < passInfo.keywords[i].Count - 1) { sb.Append(','); } } } passInfo.keywordHint.Add(sb.ToString()); sb.Clear(); } m_Passes.Add(passInfo); names.Add(passInfo.name); } } if (m_SelectedPass < 0) { m_SelectedPass = 0; } else if (m_SelectedPass >= m_Passes.Count) { m_SelectedPass = m_Passes.Count - 1; } SetSelectedPass(m_SelectedPass, true); m_PassNames = names.ToArray(); } }