Eflatun.SceneReference
Eflatun.SceneReference copied to clipboard
Add support for SceneReference type properties in Unity Events in inspector
While this is minor and can be easily worked around, I did notice that when you create a method like this one
public void LoadSceneAdditive(SceneReference sceneReference)
{
if (sceneReference.State == SceneReferenceState.Unsafe)
{
Debug.LogError($"scene reference is unsafe!: {sceneReference.UnsafeReason}");
return;
}
SceneManager.LoadSceneAsync(sceneReference.BuildIndex, LoadSceneMode.Additive);
}
then in the inspector for something like a button, it doesn't show up when registering it for a unity event
again, this is a very minor issue as it's straightforward to work around with a separate script that can sit on each button to hold the ScreenReference but it would be a nice QOL thing to have added
That's interesting, I would expect it to work. I'll take a look.
I probably should have mentioned, I am on Unity Version 2023.2.14f1
It turns out this is a limitation of UnityEvent
. It supports predefined (static) calls with primitive arguments, and arguments of type UnityEngine.Object
. Since SceneReference
is none of those, it can only be used with dynamic calls.
I have an idea. We will see how it goes.
I implemented a workaround in #102. It will be included in the next release.
Included in 4.1.0.