void CheckShaderUpdate() { if (!hasShaderReference) { return; } ClearError(); try { var shaderPath = GetShaderPath(); using (var reader = new StreamReader(shaderPath)) { var code = reader.ReadToEnd(); var parser = new ShaderTemplateParser(code); foreach (var kv in parser.blocks) { var prop = FindProperty(blocks_, kv.Key); if (prop != null) { var value = prop.FindPropertyRelative("value"); value.stringValue = kv.Value; } } } } catch (System.Exception e) { AddError(e.Message); } }
void OnTemplateChanged() { templateParser_ = new ShaderTemplateParser(template_.text); foreach (var kv in templateParser_.conditions) { if (FindProperty(conditions_, kv.Key) != null) { continue; } var prop = AddProperty(conditions_, kv.Key); prop.FindPropertyRelative("key").stringValue = kv.Key; prop.FindPropertyRelative("value").boolValue = kv.Value; } foreach (var kv in templateParser_.blocks) { if (FindProperty(blocks_, kv.Key) != null) { continue; } var prop = AddProperty(blocks_, kv.Key); prop.FindPropertyRelative("key").stringValue = kv.Key; prop.FindPropertyRelative("value").stringValue = kv.Value; prop.FindPropertyRelative("folded").boolValue = false; } foreach (var kv in templateParser_.variables) { if (FindProperty(variables_, kv.Key) != null) { continue; } var prop = AddProperty(variables_, kv.Key); var hasDefaultValue = (kv.Value.Count >= 1); prop.FindPropertyRelative("key").stringValue = kv.Key; prop.FindPropertyRelative("value").stringValue = hasDefaultValue ? kv.Value[0] : ""; } }