/// <inheritoc/> protected internal override void Initialize(int layoutIndex) { if (property != null) { guiField = new GUIColorGradientField(new GUIContent(title)); guiField.OnChanged += OnFieldValueChanged; layout.AddElement(layoutIndex, guiField); } }
/// <summary> /// Creates a new material parameter GUI. /// </summary> /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of color type.</param> /// <param name="material">Material the parameter is a part of.</param> /// <param name="layout">Layout to append the GUI elements to.</param> internal MaterialParamColorGUI(ShaderParameter shaderParam, Material material, GUILayout layout) : base(shaderParam) { LocString title = new LocEdString(shaderParam.name); var guiToggle = new GUIToggle(new GUIContent( EditorBuiltin.GetEditorToggleIcon(EditorToggleIcon.AnimateProperty), new LocString("Animate"))); guiColor = new GUIColorField(title); guiColorGradient = new GUIColorGradientField(title); bool isAnimated = material.IsAnimated(shaderParam.name); guiColor.Active = !isAnimated; guiColorGradient.Active = isAnimated; fieldLayout = layout.AddLayoutX(); fieldLayout.AddElement(guiColor); fieldLayout.AddElement(guiColorGradient); fieldLayout.AddSpace(10); fieldLayout.AddElement(guiToggle); guiColor.OnChanged += (x) => { material.SetColor(shaderParam.name, x); EditorApplication.SetDirty(material); }; guiColorGradient.OnChanged += x => { material.SetColorGradient(shaderParam.name, x); EditorApplication.SetDirty(material); }; guiToggle.OnToggled += x => { guiColor.Active = !x; guiColorGradient.Active = x; if (x) { ColorGradient gradient = material.GetColorGradient(shaderParam.name); if (gradient.NumKeys == 0) { material.SetColorGradient(shaderParam.name, new ColorGradient(material.GetColor(shaderParam.name))); } } }; }
private static extern void Internal_create2(GUIColorGradientField managedInstance, LocString labelText, string style);
private static extern void Internal_create3(GUIColorGradientField managedInstance, string style);
private static extern void Internal_create0(GUIColorGradientField managedInstance, ref GUIContent labelContent, string style);