void DrawConditions() { if (templateParser_.conditions.Count == 0) { return; } conditionsFolded_.boolValue = Utils.Foldout("Conditions", conditionsFolded_.boolValue); if (!conditionsFolded_.boolValue) { return; } ++EditorGUI.indentLevel; foreach (var kv in templateParser_.conditions) { var prop = FindProperty(conditions_, kv.Key); var value = prop.FindPropertyRelative("value"); var name = Utils.ToSpacedCamel(kv.Key); var isSelected = EditorGUILayout.Toggle(name, value.boolValue); if (value.boolValue != isSelected) { value.boolValue = isSelected; } } --EditorGUI.indentLevel; }
void DrawVariables() { if (templateParser_.variables.Count == 0) { return; } variablesFolded_.boolValue = Utils.Foldout("Variables", variablesFolded_.boolValue); if (!variablesFolded_.boolValue) return; ++EditorGUI.indentLevel; var constVars = new Dictionary<string, string>(); foreach (var kv in templateParser_.variables) { var prop = FindProperty(variables_, kv.Key); if (prop == null) continue; var value = prop.FindPropertyRelative("value"); var name = Utils.ToSpacedCamel(kv.Key); var constValue = ToConstVariable(kv.Key); string changedValue; if (constValue != null) { changedValue = constValue; constVars.Add(name, constValue); } else { if (kv.Value.Count <= 1) { changedValue = EditorGUILayout.TextField(name, value.stringValue); } else { var index = kv.Value.IndexOf(value.stringValue); if (index == -1) index = 0; index = EditorGUILayout.Popup(name, index, kv.Value.ToArray()); changedValue = kv.Value[index]; } } if (value.stringValue != changedValue) { value.stringValue = changedValue; } } if (constVars.Count > 0) { constVarsFolded_ = EditorGUILayout.Foldout(constVarsFolded_, "Constants"); if (constVarsFolded_) { ++EditorGUI.indentLevel; foreach (var kv in constVars) { Utils.ReadOnlyTextField(kv.Key, kv.Value); } --EditorGUI.indentLevel; } } --EditorGUI.indentLevel; }
void DrawBlocks() { foreach (var kv in templateParser_.blocks) { var prop = FindProperty(blocks_, kv.Key); var value = prop.FindPropertyRelative("value"); var folded = prop.FindPropertyRelative("folded"); var name = Utils.ToSpacedCamel(kv.Key); ShaderCodeEditor editor = null; if (editors_.ContainsKey(name)) { editor = editors_[name]; } else { editor = new ShaderCodeEditor(name, value, folded); editors_.Add(name, editor); } editor.Draw(); } }