Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure all component fields can be changed at runtime and can be set via UnityEvents

See original GitHub issue

Because 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;}
    myType = value;
    ....Any extra setup
/// <summary>
/// Clears MyType
/// </summary>
public virtual void ClearMyType()
  MyType = null;  

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:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

thestonefoxcommented, Nov 13, 2018

I propose rather than one big commit, many smaller commits that focus on each namespace/prefab at a time

bddckrcommented, Mar 23, 2019

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!

Read more comments on GitHub >

github_iconTop 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 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found