Ensure all component fields can be changed at runtime and can be set via UnityEvents
See original GitHub issueBecause a public field cannot be set by a UnityEvent this means that components cannot use public fields for data input otherwise they require scripts to set field data.
A property can be set by a UnityEvent by anything that extends from UnityEngine.Object can’t be set to null via a property unity event.
This means any field that wants a value to be updatable and also potentially requires any configuration to run when the value is changed needs to be backed by the following pattern
#region MyType
[Tooltip("Documentation here"), SerializeField]
private Type myType;
/// <summary>
/// Documentation here
/// </summary>
public virtual Type MyType
{
get { return myType;}
set
{
myType = value;
....Any extra setup
}
}
/// <summary>
/// Clears MyType
/// </summary>
public virtual void ClearMyType()
{
MyType = null;
}
#endregion
This will allow a private field to store the data, a public Property to allow setting via a UnityEvent and a method for setting the field to null
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Inconsistent Public Member Access in UnityEvents
I've been getting frustrated setting public members via the UnityEvent interface, so I decided to do a little testing. From what I can...
Read more >UnityEvents
UnityEvents are a way of allowing user driven callback to be persisted from edit time to run time without the need for additional...
Read more >Unity3D: Custom UnityEvent AddListener not firing
As far as the Inspector, I added a persistent callback, but as soon as I start the project, it goes blank and says...
Read more >The MMFeedbacks component - Feel Documentation
The main component you'll interact with is called MMFeedbacks. To use it, create an empty game object, and add a MMFeedbacks component to...
Read more >Events or UnityEvents????????? - YouTube
We usually use C# events when designers are not supposed to touch or change things (C# events is more natural for our coders...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I propose rather than one big commit, many smaller commits that focus on each namespace/prefab at a time
Yes! This is resolved by a big mixture of Malimbe features, using Malimbe here in Zinnia and making some previously nested types MonoBehaviours. All done!