diff --git a/Source/Editor/CustomEditors/Editors/ObjectSwitcherEditor.cs b/Source/Editor/CustomEditors/Editors/ObjectSwitcherEditor.cs index 4d0c0f662..f2398bbef 100644 --- a/Source/Editor/CustomEditors/Editors/ObjectSwitcherEditor.cs +++ b/Source/Editor/CustomEditors/Editors/ObjectSwitcherEditor.cs @@ -125,7 +125,7 @@ namespace FlaxEditor.CustomEditors.Editors } // Value - var values = new CustomValueContainer(type, (instance, index) => instance, (instance, index, value) => { }); + var values = new CustomValueContainer(type, (instance, index) => instance); values.AddRange(Values); var editor = CustomEditorsUtil.CreateEditor(type); var style = editor.Style; diff --git a/Source/Editor/CustomEditors/Values/CustomValueContainer.cs b/Source/Editor/CustomEditors/Values/CustomValueContainer.cs index 5be61399b..9a09c4cc2 100644 --- a/Source/Editor/CustomEditors/Values/CustomValueContainer.cs +++ b/Source/Editor/CustomEditors/Values/CustomValueContainer.cs @@ -38,15 +38,12 @@ namespace FlaxEditor.CustomEditors /// /// Type of the value. /// The value getter. - /// The value setter. + /// The value setter (can be null if value is read-only). /// The custom type attributes used to override the value editor logic or appearance (eg. instance of ). - public CustomValueContainer(ScriptType valueType, GetDelegate getter, SetDelegate setter, object[] attributes = null) + public CustomValueContainer(ScriptType valueType, GetDelegate getter, SetDelegate setter = null, object[] attributes = null) : base(ScriptMemberInfo.Null, valueType) { - if (getter == null || setter == null) - throw new ArgumentNullException(); - - _getter = getter; + _getter = getter ?? throw new ArgumentNullException(); _setter = setter; _attributes = attributes; } @@ -57,9 +54,9 @@ namespace FlaxEditor.CustomEditors /// Type of the value. /// The initial value. /// The value getter. - /// The value setter. + /// The value setter (can be null if value is read-only). /// The custom type attributes used to override the value editor logic or appearance (eg. instance of ). - public CustomValueContainer(ScriptType valueType, object initialValue, GetDelegate getter, SetDelegate setter, object[] attributes = null) + public CustomValueContainer(ScriptType valueType, object initialValue, GetDelegate getter, SetDelegate setter = null, object[] attributes = null) : this(valueType, getter, setter, attributes) { Add(initialValue); @@ -89,6 +86,8 @@ namespace FlaxEditor.CustomEditors { if (instanceValues == null || instanceValues.Count != Count) throw new ArgumentException(); + if (_setter == null) + return; for (int i = 0; i < Count; i++) { @@ -105,6 +104,8 @@ namespace FlaxEditor.CustomEditors throw new ArgumentException(); if (values == null || values.Count != Count) throw new ArgumentException(); + if (_setter == null) + return; for (int i = 0; i < Count; i++) { @@ -120,6 +121,8 @@ namespace FlaxEditor.CustomEditors { if (instanceValues == null || instanceValues.Count != Count) throw new ArgumentException(); + if (_setter == null) + return; for (int i = 0; i < Count; i++) {