On Value Changed Attribute

OnValueChanged works on properties and fields, and calls the specified function whenever the value has been changed via the inspector.

[OnValueChanged("CreateMaterial")] public Shader Shader; [ReadOnly, InlineEditor(InlineEditorModes.LargePreview)] public Material Material; private void CreateMaterial() { if (this.Material != null) { Material.DestroyImmediate(this.Material); } if (this.Shader != null) { this.Material = new Material(this.Shader); } }