• Stars
    star
    287
  • Rank 143,577 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A PropertyAttribute/PropertyDrawer combination that allows for properties in Unity

SetProperty

A PropertyAttribute/PropertyDrawer combination that allows for properties in Unity

Example

Unity allows you to serialize private fields with [SerializeField]. Use the new [SetProperty] attribute to have a public property set every time the field is modified in Unity's inspector. NOTE: It is okay to have private setters for public properties. Vanilla classes (i.e. non-MonoBehaviours) also work as well.

[SerializeField, SetProperty("Number")]
private float number;
public float Number
{
	get
	{
		return number;
	}
	private set
	{
		number = Mathf.Clamp01(value);
	}
}