question-mark
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.

Different behavior in Editor vs Build

See original GitHub issue

Hello, I was attempting to write my own solution, stumbled upon this project which does exactly what I was trying to make, so am seeing if I can just use this instead. In both my own solution and yours I am noticing different behavior in the editor vs on a build (Android).

I have a MonoBehaviour class, Damageable. This script exists on my enemy prefabs, which I am loading via an Addressable AssetReference and spawning with an ObjectPool. It has a reference to a DamageableScriptableEvent instance that exists in the project. I have a DamageableScriptableEventListener (created with the wizard) that exists in the scene and is loaded with the scene. When a Damageable is instantiated and then enabled, my intention is to Raise the DamageableScriptableEvent and have a listener that spawns health bars on the canvas. All of this is working great in the Editor.

However on a build, I am noticing that while the event is getting raised, my listener (which exists in the scene and is loaded with the scene) simply ignores the event on a build. This is not the same behavior in the editor, where the event is listened to and the health bar is spawned. I’ve noticed that when an event raiser/listener pair is loaded in the scene, everything works as expected on a build, but if the event raiser is an instance of a loaded prefab, the listener only receives the callback in the editor. Is this expected behavior? Is there a good solution for this situation? Is this just how ScriptableObjects work?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
njellycommented, Jun 1, 2023

Addendum: in the repo above I added a workaround for this issue, which is to mark the ScriptableEvent as addressable as well as load the scene via addressables. Hopefully it’s useful for whoever might stumble across this problem with your repo!

1reaction
njellycommented, May 31, 2023

That thread is very helpful, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

gameObject behaves different between Build and Editor.
I have different behaviour, which I believe is primarily with the gameobject that holds the script `Road Generator`, between the Build and ...
Read more >
Scriptable Objects behave different in Editor vs. Build
A good example is a SO for a monster. It contains their default stats. Monster spawns and loads these stats into a script...
Read more >
Things that can make a difference in Unity's play mode ...
I've often seen people disappointed because their build unexpectedly runs differently than the project tested in the editor's play mode.
Read more >
Unity raycast with different behavior between editor and build
I am trying to build a curved mesh in Unity. The idea is to put all of the GameObject on a sphere and...
Read more >
Different behavior with packaged build
I have a multiplayer RTS style game that works great when you play in editor, or standalone game, or “launch” from the editor...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found