void DrawConstants() { constantsFolded_.boolValue = Utils.Foldout("Constants", constantsFolded_.boolValue); if (!constantsFolded_.boolValue) { return; } ++EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PropertyField(constants_); if (templateParser_ != null && templateParser_.constants) { var style = new GUIStyle(EditorStyles.miniButtonLeft); style.fixedWidth = 64; if (GUILayout.Button("Use Default", style)) { constants_.objectReferenceValue = templateParser_.constants; } } } EditorGUILayout.EndHorizontal(); --EditorGUI.indentLevel; }
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 DrawBasics() { basicFolded_.boolValue = Utils.Foldout("Basic", basicFolded_.boolValue); if (basicFolded_.boolValue) { ++EditorGUI.indentLevel; EditorGUILayout.PropertyField(name_); EditorGUILayout.PropertyField(shader_); template_.Draw(); --EditorGUI.indentLevel; } }
void DrawConstants() { constantsFolded_.boolValue = Utils.Foldout("Constants", constantsFolded_.boolValue); if (!constantsFolded_.boolValue) { return; } ++EditorGUI.indentLevel; EditorGUILayout.PropertyField(constants_); --EditorGUI.indentLevel; }
void DrawMaterialReferences() { materialsFolded_.boolValue = Utils.Foldout("Material References", materialsFolded_.boolValue); if (!materialsFolded_.boolValue) return; ++EditorGUI.indentLevel; var materials = Utils.FindMaterialsUsingShader(shader_.objectReferenceValue as Shader); if (materials.Count > 0) { foreach (var material in materials) { EditorGUILayout.ObjectField(material, typeof(Material), false); } } else { EditorGUILayout.LabelField("No material using this shader."); } --EditorGUI.indentLevel; }
public void Draw() { var preFolded = folded.boolValue; folded.boolValue = Utils.Foldout(name, folded.boolValue); if (!folded.boolValue) { if (preFolded) { GUI.FocusControl(""); } return; } if (!preFolded) { GUI.FocusControl(name); } var minHeight = GUILayout.MinHeight(Common.Editor.minHeight); var maxHeight = GUILayout.MaxHeight(Screen.height); scrollPos_ = EditorGUILayout.BeginScrollView(scrollPos_, minHeight, maxHeight); { var style = new GUIStyle(GUI.skin.textArea); style.padding = new RectOffset(6, 6, 6, 6); style.font = font_; style.fontSize = Common.Editor.fontSize; style.wordWrap = Common.Editor.wordWrap; var editedCode = editor_.Draw(code, style, GUILayout.ExpandHeight(true)); if (editedCode != code) { code = editedCode; } } EditorGUILayout.EndScrollView(); EditorGUILayout.Space(); }
override public void OnGUI( UnityEditor.MaterialEditor materialEditor, MaterialProperty[] properties) { if (!cachedEditor_) { var material = materialEditor.target as Material; var shader = material.shader; var generators = Utils.FindAllAssets <Generator>(); Generator targetGenerator = null; foreach (var generator in generators) { if (generator.shaderReference == shader) { targetGenerator = generator; break; } } if (targetGenerator) { cachedEditor_ = Editor.CreateEditor(targetGenerator); } } if (cachedEditor_) { cachedEditor_.OnInspectorGUI(); EditorGUILayout.Space(); } folded_ = Utils.Foldout("Material Properties", folded_); if (folded_) { ++EditorGUI.indentLevel; base.OnGUI(materialEditor, properties); --EditorGUI.indentLevel; } }