Eflatun.SceneReference icon indicating copy to clipboard operation
Eflatun.SceneReference copied to clipboard

Add support for SceneReference type properties in Unity Events in inspector

Open Shain-Allen opened this issue 10 months ago • 2 comments

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

image

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

Shain-Allen avatar Mar 23 '24 21:03 Shain-Allen

That's interesting, I would expect it to work. I'll take a look.

starikcetin avatar Mar 24 '24 02:03 starikcetin

I probably should have mentioned, I am on Unity Version 2023.2.14f1

Shain-Allen avatar Mar 24 '24 02:03 Shain-Allen

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.

starikcetin avatar May 13 '24 16:05 starikcetin

I have an idea. We will see how it goes.

starikcetin avatar May 30 '24 20:05 starikcetin

I implemented a workaround in #102. It will be included in the next release.

starikcetin avatar Jun 02 '24 13:06 starikcetin

Included in 4.1.0.

starikcetin avatar Jun 15 '24 23:06 starikcetin