![]() ![]() Is there anyone else over at Unity I should be asking about how to approach this?Ĭlick to expand.There are many ways around it. Like you, it feels to me like this is something addressables should address "out of the box" - especially since we are both following well respected (and Unity promoted) architectural guidelines. It seems like a perfect fit for addressables, but as everyone is saying it's incompatible with the Richard Fine/Ryan Hipple approach, so I may have to go with small scenes loaded additively, each scene only containing a few prefabs.įor me, the other option does seem to be to use addressables but maintain my own ServiceLocator style map of ScriptableObjects to address and replace the duplicate entries - but that seems messy and goes against the grain of the whole Dependency Injection architecture I'm using. ![]() My use case is specific: to dynamically load/unload parts of the app to conserve memory. I experimented with AssetReferenceT a bit - hit the same asynchronous issues. It works wonderfully - until you try to use addressables. My approach is also based on Ryan Hipple's presentation from Austin 2017. Yes, that's pretty much exactly where I am. The advantage is, I can use assetreferenced SO's throughout my code, without concern for whether they have been retrieved or not, and be quite safe in the knowledge that, as long as I follow the arcane rules, it'll work. It's a real pain, and I wish I hadn't had to spend so much time on something that seems like it should just work, but hey, onwards and upwards. I've done this by putting everything under a "Game Controller" object, that I turn off, and if I turn it on to do some editing, and forget to turn it off, everything goes pear shaped when I play, so I've gotten used to noticing that weird behaviour. The final, and most annoying part, is that then all objects with any Monobehaviour that has these marker interfaces has to start out disabled, otherwise startup code that relies on the availability of the SO might run. Then, at startup, a loader object is responsible for going through all objects that implement the marker interface and resolving their asset references. ![]() Every Monobehaviour (and some others, but that complicates it even further) that has an AssetReference to a SO implements this marker interface, and references the SO through a wrapper class. In the end, I created a system based on marker interfaces. I ended up using AssetReferences, but this didn't solve my problem either, as being asynchronous, I had no way of knowing easily when a reference was available to use, without flooding my code with tonnes of annoying code to check and get if not ready. I had to build a complex system of initialisation. I didn't find a suitable solution out of the box I'm afraid. I had a similar problem, using ScriptableObjects all over the place, following Ryan Hipple's great presentation, and found that all addressable SO's were being duplicated, voiding the hole purpose of addressables if you ask me. Now I just refrain from using scriptable objects for states at all costs as a result.īottomline: it sucks but thats just how it works. I had some trouble with that as well at some point. If converting references to static references is not possible or too much work, one workaround would be loading in the scriptable objects at the start and have any other object then load in the scriptable object by AssetReference as well.Īs long as the scriptable object isn't unloaded it should get the same reference. if you have stats for a monster -> load in the scriptable object stats -> copy stat values to the instance of the monster -> unload the scriptable object. So what I now tend to do is use scriptable objects strictly for copies of data only. So instead of sharing states using scriptable objects I reverted back to static singleton classes that contain the state. At some point I thought that using scriptable objects for shared states was nice to have but together with addressables it is a bit of a hell due to new instances of the scriptable object. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |