Setting the Value of a Property in the Inspector in Unity
Max O'Didily
Setting the Value of a Property in the Inspector in Unity
Greetings, in this Unity tutorial we shall be looking at how to show C# properties in the Unity inspector so you can see and set their values in the Unity editor.
Exposing Properties in the Inspector is really easy to do, all you need to do is include the following line above your C# property in your Unity game:
[field: SerializeField]
In Unity, [field: SerializeField] works for properties because it explicitly targets the backing field of the property. In contrast, [SerializeField] on its own does not work for properties because it applies to the property itself, and Unity does not serialize properties, only fields.
This tutorial will show you how to expose a property to the Inspector in the same way as a field in Unity.
If you found this tutorial on how to expose properties in the unity inspector be sure to subscribe for more Unity tutorials.
Thanks for watching this tutorial on how to show properties in the inspector in Unity.
Setting the Value of a Property in the Inspector in Unity
Exposing C# Properties in the Inspector In Unity, can I expose C# Properties in the Inspector Window Exposing Properties in the Inspector Properties and the Inspector Setting the Value of a Property in the Inspector ... https://www.youtube.com/watch?v=FlGi5MUpX4I
4983736 Bytes