void TableView_ShaderSelected(object selected, int col) { ShaderItem foo = selected as ShaderItem; if (foo == null) { Debug.LogErrorFormat("the selected object is not a valid one. ({0} expected, {1} got)", typeof(ShaderItem).ToString(), selected.GetType().ToString()); return; } List <Material> materials = null; if (_otherMaterials.TryGetValue(foo.ShaderName, out materials)) { List <object> matEntries = new List <object>(); foreach (var m in materials) { MaterialItem si = new MaterialItem(); si.MatName = m.name; si.MatPath = AssetDatabase.GetAssetPath(m); si.MatObj = m; matEntries.Add(si); } _matList.RefreshData(matEntries); } else { _matList.RefreshData(null); } }
void RefreshTables() { Debug.LogFormat("Looking for shaders..."); List <Shader> shaders = PAAssetUtil.FindByType <Shader>(); Debug.LogFormat("{0} shaders found.", shaders.Count); Debug.LogFormat("Looking for materials..."); List <Material> materials = PAAssetUtil.FindByType <Material>(); Debug.LogFormat("{0} materials found.", materials.Count); _shaderDict.Clear(); foreach (var s in shaders) { _shaderDict[s] = 0; } Dictionary <Shader, int> otherShaderDict = new Dictionary <Shader, int>(); foreach (var m in materials) { if (_shaderDict.ContainsKey(m.shader)) { _shaderDict[m.shader]++; } else { if (otherShaderDict.ContainsKey(m.shader)) { otherShaderDict[m.shader]++; } else { otherShaderDict[m.shader] = 1; } } if (!_otherMaterials.ContainsKey(m.shader.name)) { _otherMaterials.Add(m.shader.name, new List <Material>()); } _otherMaterials[m.shader.name].Add(m); } List <object> entries = new List <object>(); foreach (var p in _shaderDict) { ShaderItem si = new ShaderItem(); si.ShaderName = p.Key.name; si.ShaderRefCount = p.Value; entries.Add(si); } _shaderRefTable.RefreshData(entries); List <object> otherEntries = new List <object>(); foreach (var p in otherShaderDict) { ShaderItem si = new ShaderItem(); si.ShaderName = p.Key.name; si.ShaderRefCount = p.Value; otherEntries.Add(si); } _otherShaderRefTable.RefreshData(otherEntries); _matList.RefreshData(null); }
public abstract void PushShader(ShaderItem shader);