Comments (6)
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.
That thread is very helpful, thank you!
from scriptable-events.
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.
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.
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.
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)
- 2020 LTS and generic serialization HOT 2
- Add Scene events & listeners HOT 1
- Add support for `Action<TArg>` type listeners
- Add `is` prefix to boolean fields
- Event icons HOT 1
- Release 2.1.0
- Fallback editor not working with Odin
- Listener component Editor improvements HOT 3
- Event creator improvements HOT 1
- Bug: Can not search scriptable event in listener HOT 1
- Add CHARK prefix to namespaces
- Multi-source event listeners HOT 13
- Do you intend to add Unity Visual Scripting support? HOT 3
- Listen to event without parameters in code HOT 3
- Update documentation to include Addressables
- Remove Base* prefixes
- "Is Suppress Exceptions" should be enabled by default
- Migrate to UI Toolkit
- Optional package support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scriptable-events.