GithubHelp home page GithubHelp logo

Comments (6)

Edvinas01 avatar Edvinas01 commented on June 10, 2024 1

I think you're right. I did a some snooping around and stumbled upon quite a few threads regarding this issue. Additionally some other packages providing SO event architecture also seem to have encountered this issue (e.g., unity-atoms).

Anyway, looks like this thread has some possible workarounds:
https://forum.unity.com/threads/scriptableobject-references-in-addressables.777155/

from scriptable-events.

njelly avatar njelly commented on June 10, 2024 1

That thread is very helpful, thank you!

from scriptable-events.

njelly avatar njelly commented on June 10, 2024 1

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!

from scriptable-events.

Edvinas01 avatar Edvinas01 commented on June 10, 2024

Hello and thank you for reporting the issue!

I'm quite busy at the moment with another project and won't be able to spend a lot of time debug this properly. But in short, the behavior you're describing is not expected. My guess is that it has something to do with the way addressables are setup on your project. The reason for this is that we don't use any preprocessor directives to execute code differently on Editor vs Build. Additionally, I have not used this package in a project that heavily relies on addressables (personally I try avoid addressables 😅).

When you mention that you've tried loading in the event raiser/listener in the same scene without using prefab instances, were they also loaded using addressables? Also in your builds, did you notice any exceptions in player.log/logcat?

Finally, you mentioned "I am noticing that while the event is getting raised" - how did you test this? As in, did you have some Game Objects subscribe to this event using one approach and some Game Objects subscribing using the "in the scene" approach? Perhaps the key is this difference?

from scriptable-events.

njelly avatar njelly commented on June 10, 2024

I understand and appreciate your fast response! I went ahead and put together a Unity project to actually demonstrate the issue I'm describing.

https://github.com/njelly/addressables-scriptableobjects-test

I think this has to do with the way Unity serializes ScriptableObjects, so not necessarily a bug but a user-unfriendly "feature" on Unity's end. Essentially spawning with a direct Prefab reference will maintain the link between raiser/listener but a reference spawned via an AssetReference will only maintain that link in the editor.

There are no exceptions in logcat. I have the ScriptableEvent asset set to isDebug to log when events are subscribed and raised. As far as I can tell and understand, the ScriptableEvent on the AssetReference instance is a separate instance entirely, and so it doesn't have any references to subscribers in the scene.

from scriptable-events.

Edvinas01 avatar Edvinas01 commented on June 10, 2024

Thanks for the update after investigating! I've created an issue to document this based on your findings for future travelers :D

from scriptable-events.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.