SerializedProperty CreateProperty( string title, System.Func<T> get, System.Action<T> set, System.Attribute[] attributes, SerializedObject parent )
SerializedProperty CreateProperty( string title, SerializedObject so, System.Attribute[] attributes, SerializedObject parent )

robot_2Generated
code_blocksInput

Description

The CreateProperty method in the Sandbox.Internal.TypeLibrary class is used to create a serialized property within the Sandbox environment. This method allows you to define a property with a title, getter, setter, and additional attributes, and associate it with a parent serialized object.

Usage

To use the CreateProperty method, you need to provide the following parameters:

  • title (string): The title or name of the property.
  • get (Func<T>): A function that returns the current value of the property.
  • set (Action<T>): An action that sets the value of the property.
  • attributes (Attribute[]): An array of attributes to apply to the property.
  • parent (SerializedObject): The parent serialized object to which this property belongs.

The method returns a SerializedProperty object representing the created property.

Example

// Example of using CreateProperty
var myProperty = TypeLibrary.CreateProperty(
    "MyProperty",
    () => myObject.PropertyValue, // Getter
    value => myObject.PropertyValue = value, // Setter
    new Attribute[] { new SomeAttribute() }, // Attributes
    mySerializedObject // Parent
);

// Accessing the serialized property
var value = myProperty.GetValue();
myProperty.SetValue(newValue);