Yes this is possible. One way is to Build With the Groups set as Local and then do a full build so it bundles everything together, You can then change the groups to be remote and do another build later if they need updating. You can then perform a catalog update to detect that the groups are available remotely and can be updated.This user is doing the same https://forum.unity.com/threads/case-1343032-updating-localization-through-addressables-causes-system-exception.1125758/
#📦┃addressables
1 messages · Page 8 of 1
i have french and spanish versions of a project. is there any way i can make a spanish build from the editor that only includes spanish audio files by using addressables?
Thank you. This workaround works however as far as I know assets that's set as remote are also kept locally on build. My other addressable assets is reachable with no internet connection except Localization. We're using Unity Cloud Build and making this change all the time before builds is hard and not time efficient. It'd be awesome if it works the way other addressables work.
Localization groups work exactly the same as normal addressable groups, there's no difference. So if it works normally for other groups then it should also work for localization ones. Is there a difference in the configuration between the 2 groups?
No they are exactly the same. Addressables.InitializeAsync ends but LocalizationSettings.SelectedLocaleAsync never ends when there is no internet connection. So, I can get my regular game objects, images, etc. but not localization string tables.
But now that I think, I access the other game objects directly until they are loaded. After they are loaded I update them from asset references. But with localization we don't directly use string tables and use string table asset references so it makes sense that they are not working the same way.
Would anyone be able to elaborate how to use Addressable's Labels as an alternative to Resources.LoadAll()?
hi all! noob question: how to batch loading if i have AssetReference[] array? I see Addressables.LoadAssetsAsync which requires IList<IReourceLocation> but how to use it with bunch of AssetReference?
Use one of these versions: https://docs.unity3d.com/Packages/com.unity.addressables@1.18/api/UnityEngine.AddressableAssets.Addressables.html#UnityEngine_AddressableAssets_Addressables_LoadAssetsAsync__1_IList_System_Object__Action___0__UnityEngine_AddressableAssets_Addressables_MergeMode_ that takes keys instead of IREsourceLocations
and use the keys from the AssetReferences?
not sure if that would be ref.runtimeKey or the ref itself
I don't think you can pass the array of AssetReferences to LoadAssetsAsync. However, you can loop over your asset references, take their RuntimeKey and add them to a list (or array - whatever floats tickles your fancy.)
List<object> keys = new List<object>(assetRefs.Length);
foreach(var assetRef in assetRefs)
{
keys.Add(assetRef.RuntimeKey);
}
Addressables.LoadAssetsAsync(keys);
How the heck does everyone only seem to use equivalents of Resources.Load, and nobody uses Resources.LoadAll? Does no one need to load multiple objects of a certain type? There's absolutely no tutorials on how to do this
That's what the discussions right above you are about
@low halo @shrewd geyser thank you for answer. I have tried to extract RunTimeKey and it seems like simple code but something goes wrong and produces errors which is something about key invalidation so i have finished with just AssetReference.LoadAssetAsync and counter.
I'm trying to understand it but I can't seem to get even the most basic example working. I also don't know where labels come into play in regard to this.
It doesn't seem like I can load anything that isn't a gameobject
I can't load a Sprite or a TextAsset file
the error I get is:
Exception encountered in operation Resource<GameObject>(DrySoil.yaml), status=Failed, result= : Unable to load asset of type UnityEngine.GameObject from location Assets/Resources_moved/Defs/Tiles/Base/DrySoil/DrySoil.yam
Any ideas?
bump
don't you try to load not gameobject as a gameobject?
I save it an a list where I define the type, such as List<GameObject> Assets
It's weird because it works flawlessly for actual gameObjects
But when I change it to
List<Sprite> Assets
And try to load a sprite
I get that error
It should work because my method takes a generic T parameter, aka Object. And sprite derives from object. So I'm not sure what I'm doing wrong
The exception says that you trying to load DrySoil.yam
Does anyone know how I would take multiple asyncHandlerOperations and wait for them all to complete before triggering an callback ?
Keep a HashSet of the operations you're waiting for. When any of them complete, remove it from the set, and check if the set is empty. If it's empty, do what you want to do.
sounds like a good idea
I am.
I need to load assets other than gameobjects
What's wrong with that? Loading yaml files and images?
Here's my ENTIRE code. The only thing I'd expect that I need to change is the type of the Assets List, I don't need GameObjects but Sprites in my case
and this still doesn't work
Can someone please help me out?
Well, the exception says that you can't get GameObject from YAML file
GameObject assets are in PREFAB files
I know what the exception says...
What I want is to load a non-gameobject
Like a text file or a string
@frank panther
Are you just experimenting? From the first look it seems strange that you're loading assets on Start, why not just reference them, i.e., without using Addressables?
When is this script loaded?
Let me explain what I need and why. I am storing my data about let's say a certain tile (Grass) in a Grass.yaml file. There I can set the walkspeed variables, generationHeight variable and even more importantly, which texture should be used for this Tile (by only writing the name)
I'm pretty sure I NEED to load .yaml files on Start, and as a bonus, I should be able to reload them whenever I want and see changes in real-time in game
But even leaving all of that behind, what I currently want to figure out, that would probably make the rest of it make sense, is why the above code just doesn't want to load a sprite
It's a generic type T : Object so any Unity object should get loaded, including Sprite or TextAsset
T is generic, but you're passing object of concrete class, which in your example is Sprite
Okay
Do you have any advice on how I should handle this?
public static async Task InitAsset<T>(string assetLabel, List<T> createdObjs) where T : Object
{
var locations = await Addressables.LoadResourceLocationsAsync(assetLabel).Task;
foreach (var location in locations)
{
createdObjs.Add(await Addressables.LoadAssetAsync<T>(location).Task);
}
}
public static async Task InitSprite(string spriteLabel, List<Sprite> createdSprites)
{
var locations = await Addressables.LoadResourceLocationsAsync(spriteLabel).Task;
foreach (var location in locations)
{
createdSprites.Add(await Addressables.LoadAssetAsync<Sprite>(location).Task);
}
}
InitSprite is basically the same method but specialized for loading a sprite
would this work?
As I see your problem - you have marked different types with some label, and are trying to load them as one type
One way to fix this would be to use a label on one type of assets
I don't think that is the problem
I've only ever tried to load the one type at once
and further more
I've just tried it again with this "Sprite-specialized" code
still getting this error
I'm trying load a .png file which is set as a "Sprite (2D and UI)" in the settings
I want to make my code clean, so back to my problem. If i have multiple AssetReference, then how can i load them in one task?
I see that there is Addressables.LoadAssetsAsync, but many of them are marked as obsolete. And i need some IList<IResourceLocation> and i see Addressables.LoadResourceLocationsAsync which is obsolete as well. So is there a NOT obsolete solution to batch asset reference loading or any other way to load bundles in addressables?
Have you checked the overloads that aren't obsolete?
And in what way is the solution we provided yesterday not working or sufficiently clean?
I give up. Not a single person here can explain to me how I can load a batch of Sprites XD
I use addressables extensively, but I don't know what your issue is exactly. I also don't use async and Tasks, so perhaps it has something to do with that. I'd say it looks fine, but apparently it doesn't.
Additionally, loading sprites, especially from atlases has been a point of issue throughout Addressable releases, so I wouldnt be surprised if something is just plain broken in there.
Thank you for reading my message, holy hell!
I don't think loading sprites marked by labels should be an issue
Checking this though, you seem to try and load the PNG file... AFAIK, that isn't a Sprite asset, that's just the raw Texture file...?
Oh...
Perhaps I'm wrong about that.
Well, I'm not sure, I'm waiting for a build to complete to see if I can determine what the internal structure of a sprite versus texture is :p
oh man...
I just tried
and it works
Okay, I just need ONE MORE THING to work, which is how to load .yaml files
internally I think it's represented as a TextAsset type
Are .yaml files considered TextAssets by default? I don't think they are... I was searching for that yesterday to add them to the list of recognized text assets, but I don't think it is.
Unity uses yaml internally, but they do so under different extensions, and not under the yaml extension.
foreach (var baseTileType in Resources.LoadAll(Settings.BASE_TILES_PATH, typeof(TextAsset)))
{
var baseTile = Deserializer.Deserialize<BaseTile.Initializer>(((TextAsset) baseTileType).text);
BaseTileInstances.Add(baseTile.Name, baseTile.CreateInstance());
}
this is how I deserialize a .yaml file
I'm using YamlDotNet from nuget
so it seems to be a regular TextAsset
Hmmm. Perhaps this is another Addressables oddity of which file types it can pick up in the whole system
what's confusing me is why didn't it work before when I used the generic T where T : Object
Texture2D is also probably an Object
should've worked
apparently Texture2D inherits from Texture and it inherits from Object
I wonder if that's why it didn't work xd
and also yes, it seems like TextAsset type doesn't work sadly. Doesn't want to load it.
nevermind
it works
I forgot to change the label
Either way, thank you for taking the time to help me solve this!
For the text asset stuff, perhaps this can be of help?
https://forum.unity.com/threads/loading-a-file-with-a-custom-extension-as-a-textasset.625078/
No problem. :)
So to summarize
The generic T parameter works as long as your object directly inherits from Object
Because Texture2D inherits from Texture and not Object directly, it seems to throw an error.
Hmmm, that shouldn't be right. Im loading several things that have longer type chains than just directly inheriting from Object
Not sure how to explain it then
Simply doesn't work when I try to load a Texture2D as a generic
Depends. Is the .png registered as Texture2D when you check it in the Inspector?
Yes, it is
I have found proper combination of methods, thank you. Yesterday i have encountered with some unclear errors
@orchid crypt Ok! :)
Hmmm...
I suppose it sort of works now
but it's giving me all kinds of weird behavior
it's loading 1 sprite twice for some reason
@rigid shadow That's perhaps also the reason why it isn't loadable as type of Sprite. When it's a Texture2D in the inspector, then I think there's no Sprite. When you change the mode to 2D and UI, you'll get a sprite asset that you can load.
I assume you mean
it doesn't recognize that it's been changed to a sprite, correct?
That could also be the case. When you add an asset to an Addressables group, it creates some data in the background inside the group, and I'm not sure whether it updates in realtime.
So how I've made it work with all types is just like this:
private List<Object> Assets { get; } = new List<Object>();
It has to be of Object type explicitly
but now I have another problem, it seems like everything is getting loaded twice
var locations = await Addressables.LoadResourceLocationsAsync(assetLabel).Task;
for each address, this stores 2 values
any ideas why that might happen?
I have no idea on that front, unfortunately :/
I finished with this code. Have no idea why there is no BundleReference or BundleGroupReference which can do the same but just as AssetReference.LoadAssetAsync
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using System;
using System.Threading.Tasks;
namespace FantasyTavernManager
{
[CreateAssetMenu(fileName = "NewAddressablesCollection", menuName = "Addressables/AddressablesCollection")]
public class AddressablesCollection : ScriptableObject
{
[SerializeField]
private AssetReferenceGameObject[] assets;
public async Task<IList<GameObject>> LoadAssetsAsync(Action<GameObject> onElementLoad)
{
IEnumerable<object> GetLocations()
{
var list = new List<object>();
foreach(var item in assets)
list.Add(item.RuntimeKey);
return list;
}
return await Addressables.LoadAssetsAsync
(
await Addressables.LoadResourceLocationsAsync(GetLocations(), Addressables.MergeMode.Union, typeof(GameObject)).Task,
onElementLoad
).Task;
}
}
}
using UnityEngine;
namespace FantasyTavernManager.Test
{
public class AddressablesTest : MonoBehaviour
{
[SerializeField]
private AddressablesCollection addressablesCollection;
private async void Start()
{
var result = await addressablesCollection.LoadAssetsAsync((GameObject go) => { Debug.Log($"{go.name} has been loaded"); });
var loadingReport = "loading completed: ";
foreach(var item in result)
loadingReport += $" {item.name},";
Debug.Log(loadingReport);
}
}
}
What's the point of having multiple groups?
Can multiple groups share a similar label? What's the most common usecase to seperate stuff in different groups?
I'm not an expert, but I think it's so you can have different bundle strategies. You can tell the Addressable system to have 1 bundle per Group, for example.
I've noticed the Addressable's C# code uses a special syntax for certain strings such as {UnityEngine.AddressableAssets.Addressables.RuntimePath}
Am I able to also take advantage of that in my code when I call, for example, the LoadContentCatalog method?
Also I believe you can tell some groups to be local, and others to be remote, etc.
Thank you
i have french and spanish versions of a mobile project with french and spanish specific assets that are addressables. is there any way i can build a spanish edition of my project without including the french assets? I don't want each build to have spanish & french if they only need one or the other
or point me to a guide that tells me how to do so? i've been stuck on this problem for about a week
Is there a way to store AssetReference in blittable data? I mean to restore AssetReference from some blittable data in build. I see only AssetGUID which is string
basically the GUID is the best you can get in my experience - turn it into a https://docs.microsoft.com/en-us/dotnet/api/system.guid?view=net-5.0 and that should be blittable I think?
Otherwise turn it into two longs. It's basically just a 16 byte integer
Is there any way to perform loading (or any other operations) ONLY on a certain Group?
Such as if I had a general asset loading procedure, probably using labels and such, but I could also pass the Group name as a parameter
is that how it works?
No, groups are non-existing at runtime. Either give all assets in a group a unique group label, or put all assets of the same type in a group.
I see, thank you!
I think the strategy you want is to have two Groups. One for French and one for Spanish. You'll have to populate the contents of each Group with solely French or Spanish assets, however.
does AssetGUID stable between editor and build?
They should be, since they refer to the actual asset used in the project to keep or store the reference. If they'd change, your project would break constantly.
And otherwise, the AssetReference struct wouldn't work either when using it in your classes to assign them through the inspector.
What i want is to store AssetReference inside IComponentData (dots ecs component) which fields must be blittable data. It is possible to use Untiy.Collections.FixedString/32/64/etc.
But i have faced today a new trouble. I use label to load group of assets and then i want to store loaded asset GUID, but i use IResourceLocation and see no way to get AssetGUID through it.
Here is my code.
public async Task<IList<GameObject>> LoadAssetsAsync(Action<GameObject> onElementLoad)
{
return await Addressables.LoadAssetsAsync
(
await Addressables.LoadResourceLocationsAsync(label.RuntimeKey, typeof(GameObject)).Task,
onElementLoad
).Task;
}
So i want to extract AssetGUID from every IResourceLocation which was gotten from Addressables.LoadResourceLocationsAsync(label.RuntimeKey, typeof(GameObject)).Task
I can use SO to store AssetReference array and extract AssetGUID from asset references. But having just AssetReferenceLabel field instead of custom SO is much more compact
I have seen 2 threads with dramatic truth about impossible to do it in a simple way
@lunar shard thank you for your response! i've played around with groups a little bit, but i'm not very comfortable with them because there's so many settings (packed assets? no schema? build path, load path, unique provider, asset bundle crc, chunked transfer, bundle mode, bundle naming, asset provider... omg!). even if i do group them, won't both localized files be included in the build anyways? how do i determine which assets i'll build if i use the default script? sorry if this is dragging on, but this has been giving me a headache for a long time. i've tried using this documentation for content catalogs & groups, but it's too vague for me (https://docs.unity3d.com/Packages/com.unity.addressables@1.8/manual/AddressableAssetsGettingStarted.html). if you're not sure of the answer, do you have any other documentation recommendations i can look at?
I'm trying to use Addressable with WebGL and Unity Cloud Build.
It is configured to build them as part of the cloud build. The build succeeds normally.
But when I call
List<AssetDefinition> definitions = Addressables.LoadAssetsAsync<AssetDefinition>(DEFINITIONS_KEY, null).WaitForCompletion().ToList();
It freezes infinitely with no errors or output. This same line works on other platforms correctly.
(I know I could get past the infinite freeze by not waiting on them with WaitForCompletion, but either way, it never finishes, nor outputs any messages)
Has anyone gotten addressables to work with WebGL? What about WebGL and Unity cloud build?
(Unity 2020.3.4f1, Addressables v1.18.9)
Sorry man, no experience with either of them. :/
No doubt. I'm actually somewhat new to the whole Addressable system myself, but have a good amount of experience with Asset Bundles (which is what Addressables are underneath the hood, ultimately).
When you mark an Asset as Addressable, it puts it into the default Group. You can then open the Group window and manually drag that Addressable into a new group. In that way, you can make sure each group only contains French or Spanish assets.
If you haven't gone through this yet, I highly recommend it. https://learn.unity.com/project/getting-started-with-addressables
I'd also suggest going to https://learn.unity.com and searching for Addressables in their search bar.
I find the whole Addressable system to be pretty intimidating as well, and have many years of Unity experience under my belt, so that's natural.
If there are multiple prefabs in an addressable bundle which reference the same texture, the addressable system seems to cache the texture while one of the prefabs is loaded, making the loading time for the other prefab take less. I'm currently using this to reduce the loading time of my prefab (which is loaded on-demand during a loading screen) by asynchronously loading a separate prefab (which only contains spriterenderers with sprites assigned) during the main menu scene. This seems to work pretty well and it reduces the load times by a lot. Now, for people familiar with the addressable system, do you know if loading a single sprite from a texture is enough to load and cache the entire texture? I've attempted both loading a single sprite from the texture and loading all of them, but the result seem inconsistent and all over the place.
Has anyone had issues with addressables and textmeshpro? Everything works fine in Editor but both in android and IOS builds there's an issue of texts being invisible. If we're instantiating a prefab that was loaded with Addressables, any TMP_Text(UI) component that's inside the prefab will be invisible. If the prefab with TMP components is being instantiated by direct reference or is simply included in the scene, then it works fine. I've tried to debug this with Rider and stumbled across something weird. For some components, the color field of the TMP component appears as (0,0,0,0), which explains why its invisible as there are no shader errors. However, while debugging, some of the text fields suddenly start working. I'm guessing that TMP is trying to load some things in the background but the code execution doesn't wait for its results. Since debugging slows this down, things start working more properly.
I've tried searching online but found nothing
Has anyone got invalid key exception ? and know how I can debug this?
Ok so it turns out, some how when packing
the addressibles
they get corrupt lol
I reverted to an older commit with addressibles folder moved it in and it worked
so something is going on with the addressibles package over time that causes a corruption
this is a bit concerning lol
doing a diff on the folder now
Okay guys, does anyone know of the most stable version of addressibles ? And the editor version you must have to keep it stable ?
I previously ran with version 1.13.1 for a long time and currently am using 1.17.17 in Unity 2018.4.34 (pretty outdated by now). These 2 addressables version seem to be the most stable ones in a long while (as we've been using these without issues while any other in-between version had issues in our project). Although not sure about the current 1.18.9 version, since it's been a while since an update has been posted. Perhaps it is considered stable enough that no new updates have appeared?
But I also guess it depends on what features of the package you're using. I don't have any sprite atlases, or remote content stashed etc. So there might be issues hidden somewhere in there that might pop up in your use-cases.
so in my game I added the GameJolt API, but in another script for the gameplay, for connect the API with the gameplay, I need to put using GameJolt.API, but it doesn't work, it says something like this: "(Is a using directive or assembly reference missing?)"
And this is the image
Yeah I use remote content with game objects it seems hit and miss
You are asking this question in wrong section. You should ask this kind of questions in #💻┃code-beginner or #archived-code-general. If you installed gamejolt library correctly, close your code editor. Then, in the unity menu, regenerate csproj with edit>preferences>external tools> regenerate project files button.
tried your version ran into an issue lol, this seems really buggy, all I want to do is load a game object why is this so inconsistent ...
BuildPath for group 'Default Local Group' is set to the dynamic-lookup version of StreamingAssets, but LoadPath is not.
BuildPath: '[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]'
LoadPath: '{UnityEngine.Application.persistentDataPath}/WEAssets/Wardrobe/PonyTailsHairGreen'
what do this even mean this worked before
no wonder barely anyone uses this system
Do you know how build profiles work? Or did it work like this before with another version of Addressables?
I sorta understand through a tutorial how these profiles work. This did work in the verified version of Addressables
Understanding the Addressables’ Settings in this tutorial
https://www.raywenderlich.com/14494028-introduction-to-modding-unity-games-with-addressables
This is the extent of the understanding of the system I have
and reading various articles around the internet
So what are Build Path and Load Path?
LocalBuildPath: [UnityEngine.Application.dataPath]/Exported
LocalLoadPath: {UnityEngine.Application.dataPath}/Resources/Mods
What does that mean? LocalBuildPath is where Unity will export the mod. Look at the folders in the Project window and you’ll see an empty Exported folder. The mod will build to this folder. UnityEngine.Application.dataPath points to the Assets folder of the Unity project.
@shrewd geyser
Well, I know there's check in place that compares the build and load path at build-time, but from my point of view, it's not something that would work anyway.
When you say that it should build them at [UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget], then that means it will store them in your Library folder somewhere during build time. This is the default build location. The content catalog file that gets generated for these files will assume that your content will live inside the player build, since it will copy them over to the player when wrapping up the build.
When you say next that your load path is {UnityEngine.Application.persistentDataPath}/WEAssets/Wardrobe/PonyTailsHairGreen, they don't correspond to the paths generated in the content catalog file (you define your load path to be from an external path - the persistent data path in this case. And it may work in theory, but in this case, only by coincidence, I think). So Addressables does a check for what it builds to the default path, should also be loadable from the default path.
In case you can, I recommend reverting these values to their defaults:
[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]
{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]
@shrewd geyser I am trying to load this remotely, so the expectation is, where it should build wouldn't matter?
Prior in 1.15
I would use the exported folder to output to a build path, it provides to be a catalog and hash and a bundle
Then
{UnityEngine.Application.persistentDataPath}/WEAssets/Wardrobe/PonyTailsHairGreen
I would take the files and put them in this folder and have them loaded a run time in the game
it would work like 80% of the time
sometimes I would get a dependency error
or a key error
this allowed my app to have DLC
Well, where it builds them does matter, especially when it's the default build location.
When you say a remote location (but I assume in this case for testing just a local folder somewhere on your system, right?), then both the build and load path should point to that location. If you leave the build path to the default location, it will assume the load path to be there as well, and in this case throws the error you're seeing. So I'd set the RemoteBuildPath and RemoteLoadPath to correspond with each other in the Profile, or... You can set a custom build/load path in each of the Addressables group that should be loaded from the {UnityEngine.Application.persistentDataPath}/WEAssets/Wardrobe/PonyTailsHairGreen location, and leave the Profile values to their defaults.
@shrewd geyser I am confused, why would the build path matter? other than to retrieve the files? to be used as content at run time down the line?
I figure load path is the only thing that matters here.
Right, I'm checking out the tutorial you linked and how he fixes the support for modding.
What's your current build path?
So unless I'm wrong (this confused the hell out of me for a while, apologies if you already got this) - where your bundle is ultimately downloaded from is actually the remote load path. No idea why you'd expect to know that ahead of time. In addition, I think in 1.17 or 1.18, there seems to be a bug where the Remote load path is basically ignored. Hugely confusing things.
My expectation is, as long as I have a bundle, hash and catalog file. I should be able to load the bundle at runtime and then load the key. It should be as simple as that.....
interesting yeah I don't exactly have a download path yet either
That's a reasonable expectation, but not one Addressables accepts when building. This is the check Addressables perform during build, and why you get to see the message:
bool buildLocal = buildPath.Contains("[UnityEngine.AddressableAssets.Addressables.BuildPath]");
bool loadLocal = loadPath.Contains("{UnityEngine.AddressableAssets.Addressables.RuntimePath}");
if (buildLocal && !loadLocal)
{
message = "BuildPath for group '" + assetGroup.Name + "' is set to the dynamic-lookup version of StreamingAssets, but LoadPath is not. \n";
}
else if (!buildLocal && loadLocal)
{
message = "LoadPath for group " + assetGroup.Name + " is set to the dynamic-lookup version of StreamingAssets, but BuildPath is not. These paths must both use the dynamic-lookup, or both not use it. \n";
}
So when you say pretty much the same build path he has, it's not, because in your earlier message, in your load path, you have {UnityEngine.Application.persistentDataPath}, which doesn't correspond to the load path's value because you use the default. (I'm not making the rules on this one 😅 )
Hasn't been anywhere near that simple for us. You also get very different behaviour depending on the combo of bundle naming etc settings, the addressable versions, whether you're using compressed (don't if you have any issues at all) and so many more things.
I don't understand, why this is that complicated it's like they didn't even ask for feedback when building this, is it crazy that I want that specific functionality am I doing it wrong? aren't they supposed to study the domain around the use case and model it after that?
how do I look at the source on this ?
My guess is that most of the issues have their reasons. It isn't a straight-forward problem because addressables cares a lot about dependencies and versions. So it can't be as simple as bundle + hash. That said, the bugs, lack of docs, mess of an api and much more though make the whole thing a total nightmare imo. We've got something working but it feels very much in-spite of, rather than thanks-to. You'll also probably be hit by path lengths at some point - put your build nested a couple of folders deeper and notice everything break.
We've got something working but it feels very much
in-spite of, rather thanthanks-to
I concur 😅
So from what I understand there are two settings, one for the group and one for the whole folder (Addressible Asset Settings).
The one for the whole folder has all these extra options such as buid remote catalog, and the two build and load pathes we discussed
The lets say we have the Default Local Group
It has a build and load path
What is the difference between those two sets of build and load pathes?
Another question what does
{UnityEngine.AddressableAssets.Addressables.RuntimePath} convert to at the end of the day?
The load and build paths on the group are essentially overrides specifically for the assets defined in that group compared to those defined in the settings.
But I shouldn't have suggested that as I think it make your situation more complicated than it probably already is.
ahh I see
So from what I understand what you are saying here... is my use case is no longer supported?
Well, it is (I think), but only with properly defining of build and load paths. Just pick a different build location other than having it in the default location:
BuildPath: 'Path/to/somewhere/on/your/system/Export'
LoadPath: '{UnityEngine.Application.persistentDataPath}/WEAssets/Wardrobe/PonyTailsHairGreen'
After the build is done, you can copy these file from the build path, past them in the persistent path location you use for testing.
that's what I have been doing, but I get dependency failures sometimes and then key lookup failures
but sometimes it bundle's it correctly :S
Is it possible to show this dependency failure message you get? (I mean the full message and exception stack)
yep one second
this might take a while, I deleted the library folder to test a few things out
No problem :)
Tag me when you have it, I'll check it out as soon as I can
@shrewd geyser
OperationException : Dependency operation failed with System.Exception: Unable to load asset of type UnityEngine.GameObject from location PonyTailsGreen-Hair..
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1/<>c__DisplayClass57_0<UnityEngine.GameObject>:<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>)
DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>) (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.ResourceManagement.ResourceManager:Update (single)
MonoBehaviourCallbackHooks:Update () (at Library/PackageCache/com.unity.addressables@1.18.11/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:26)
And there isn't any error or exception happening before that?
(Related to Addressables at least)
@shrewd geyser none sadly only this
Exception encountered in operation Resource<GameObject>(PonyTailsGreen-Hair), status=Failed, result= : Unable to load asset of type UnityEngine.GameObject from location PonyTailsGreen-Hair.
UnityEngine.AsyncOperation:InvokeCompletionEvent ()
sadly now the lighting in my project is borked lol
And the PonyTailsGreen-Hair bundle is available at the expected location?
Could you perhaps share the content catalog file?
yeah for sure ill share it
this should be the lookup key "PonyTailsGreen-Hair" @shrewd geyser
Thanks, I'll check it out in a minute.
yeah no worries
Hey all, I have a question about what version of the Addressables package is the version that's considered "stable".
1.16.19 is listed as "verified", and then there is a huge group of preview version in the version 1.17 group, but above that is some more of the 1.17 group and then the 1.18 group that is not listed as preview.
So is 1.16.19 the stable version and anything after it is unstable? Or is 1.18 officially recommended for use by Unity, or what?
its hard to say I got something working with 1.16.19 on editor 2020.3.7
it works, but the packaging aspect of the bundles for my specific use case does not
I suggest going through the change logs and seeing what issues are important to you. I think all of the latest versions have critical fixes so we're using the latest. Doesn't mean it's stable.
@cedar loom
So you have copied over the files etc. to {UnityEngine.Application.persistentDataPath}/WEAssets/Hair/LongTwintailsGreen/, right?
Are you testing in editor, or in a player build?
And can you share how you try to load that asset? Is it through an asset reference? Or Do you call something like Addressables.LoadAssetAsync<GameObject>("PonyTailsGreen-Hair")?
I am testing it in both the editor and in the release standalone version
both fail
I can share it for sure, it loads for everything else but this asset
@shrewd geyser
public void Instantiate(string key,
string attachPoint,
Vector3 position,
Quaternion rotation,
Transform parent,
Action<GameObject> assetCallBack)
{
//InstantiationParameters instParams = new InstantiationParameters(position, rotation, parent);
//AsyncOperationHandle<GameObject> handle = Addressables.InstantiateAsync(key, instParams, true);
AsyncOperationHandle<GameObject> handle = Addressables.InstantiateAsync(key, trackHandle: true);
didFinishLoadingAsset += assetCallBack;
handle.Completed += OnLoadDone;
attachPointForAddressibleKey[attachPoint] = handle;
}
and I guess the key that gets used is PonyTailsGreen-Hair?
yep!
I'm wondering whether the key is the problem... Since in your content catalog, the key PonyTailsGreen-Hair isn't present on its own. It has a whole bunch of other things before it:
Assets/Models/BaseModel/BaseModelHair/PonyTailsHair/PonyTailsGreen-Hair.prefab
interesting, wouldn't there be a key error in that case ?
thats also a good point
Could you either try with the full address, or simplify the address and try again? (after a rebuild, I guess, since the catalog file still contaisn the old, longer key then)
I think it would, though I'm not too sure... 😅
"{UnityEngine.Application.persistentDataPath}/WEAssets/Hair/ShortHairGreen/shorthairgreen_assets_all_dd412fe1ac5adeb61a9a45f9dd66e5ea.bundle",
"Assets/Models/BaseModel/BaseModelHair/ShortHair/ShortHairGreen-Hair.prefab"
this is what is in the working one
doesn't seem to contain the key in plain text in the catalog.json
hmmm
whats odd is comparing them
I am gonna check that key's string
it's base 64 decoded
So you have working mods that have been build and tested in the same way? And is it just one? Or multiple that you have working?
I have like 80% of them working haha
theres like 20% where when I build it
it works
then its fine
then I think oh if I follow the same process it will work for the remaining 19%
I follow the same process
and the remaining 19% fail
so its driving me instane
Funny story, when I first started using unity, I had thought, that unity crashes on null exceptions and used it like that for 7 months
it turns out, it was a unity bug
so this is another unity break or make it story for me
@shrewd geyser maybe I should write a unity forums post on this maybe it will be helpful to other people
Hmm... If they are all set up in the same way, and some work while other don't, then I'm not very sure where to look at :/
Since it seems alright from the files, and if you do the same for each one, then I wouldn't know why some fail, while others wouldn't.
It could be caching ?
Hmm, could be, though I haven't used 'remote' assets, so I haven't used the cache
So no experience on my end for any advice or pointers.
I just got very lucky, so I have two asset bundles, of the same type
one that works and one that doesn't
I am gonna do a compare
I checked out the decode base 64 of the data inside the catalog, and it does contain the previously mentioned key... So I guess that one's ok.
@shrewd geyser thanks for your help so far, it means a lot just to even clarify if I am on the right track of thinking
It sounds like you're the right track indeed. But I do suggest to also make a forum post as you mentioned earlier. Some other people with the same goals might probably jump in over there.
Honestly, just a simple idea "to load asset in editor script", and after that idea came up to my head i have found myself reading this post and asking myself will i have to learn something else then unity soon 😕
https://forum.unity.com/threads/how-to-use-addressable-system-in-editor-script.715163/
Damn theres an addressables channel now? awesome
I mean how would unity get feedback from this project without it 😉
@mild flax hey do you know if we can just walk through the addressable code? is it open source? I didn't really check just yet possibly a stupid question right here haha
It's a package. AFAIK we can view the code of any package
@frank panther kk thanks! sorry not a native c# person
@cedar loom You can. Like I showed in the screenshot, you can open the scripts through that already. However, when using the 'Go To Definition' utility in VSCode, it will open up the assembly information rather than the script.
Most likely, you've downloaded the package through the package manager. That way, it will keep the actual code 'hidden' from your code editor. What you can do (and what I did in our project), is to move the Addressables package in your project. By default, packages are stored in the Library/PackageCache folder. When you cut&paste the com.unity.addressables@xyz folder (with xyz being the version number of the package) to the Packages folder (lives next to the Library folder), it will open up scripts just fine. :)
perfect thankyou
You can also enable csproj's e.g. for built-in packages and then VS will just take you to definition like normal:
Oh this is even better thank you!
https://forum.unity.com/threads/addressable-with-dependency-operation-failed-as-well-as-key-not-found-errors.1137691/ welp this is the post pray the unity devs see it and respond, its quite a bit to unpack D:
Does the Reference Count management system system that Addressables has only work if you use the InstantiateAsync method?
I'm a bit confused by the documentation.
and by work, I mean, work on its own without my involvement in interacting with handling counting stuff myself
Anyone had some luck with Editor Hosting?
hey, I'm having some issues with addressables
this is the view in my game
then I try and build for android and al the addressables won't show up
This is the in game view
Ignore the weird shading I'll have to fix that separately
But the robot and all it's parts won't show up
has anyone found that loading defs is really, really slow?
as in, when I try to load lots of assets asynchronously, when I await them in a foreach loop and debug.log them, they log out really really slowly
almost like they're capped somehow
How are you awaiting them all? Maybe you are causing them to load in sequence by accident?
public static async Task InitSprites(string assetLabel)
{
var locations = await Addressables.LoadResourceLocationsAsync(assetLabel, typeof(Sprite)).Task;
foreach (var location in locations)
{
Sprite sprite = await Addressables.LoadAssetAsync<Sprite>(location).Task;
AllSprites.Add(sprite.name, sprite);
}
}
yeah you're doing them in sequence
Get all the tasks first
put the tasks in a list
then await those? 🤔
Could you please give me a concrete code example?
Addressables confuse the heck out of me
I barely managed to scrape this together
Oh wait actually use this: https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.whenall?redirectedfrom=MSDN&view=net-5.0#overloads
get all the tasks in a list, then call await Task.WhenAll(listOfTasks);
umm
at what point after calling that do I add the loaded sprites to my dictionary?
public static async Task InitSprites(string assetLabel)
{
var locations = await Addressables.LoadResourceLocationsAsync(assetLabel, typeof(Sprite)).Task;
List<AsyncOperationHandle<Sprite>> tasks = new List<AsyncOperationHandle<Sprite>>();
foreach (var location in locations)
{
tasks.Add(Addressables.LoadAssetAsync<Sprite>(location));
}
foreach (var task in tasks)
{
Sprite sprite = await task.Task;
Debug.Log($"LOADED IMAGE");
AllSprites.Add(sprite.name, sprite);
}
}
@low halo is something like this not correct?
Still not correct because you're awaiting them one by one
List<Task<Sprite>> tasks = new List<Task<Sprite>>();
I've got this list
but can't figure out how to add Tasks in it
you are doing that right
var locations = await Addressables.LoadResourceLocationsAsync(assetLabel, typeof(Sprite)).Task;
List<Task<Sprite>> tasks = new List<Task<Sprite>>();
foreach (var location in locations)
{
tasks.Add(location);
}
var test = await Task.WhenAll(tasks);
foreach (var thing in test)
{
AllSprites.Add(thing.name, thing);
}
This is what I've got
just can't figure out where to get the tasks that I need to add
you have it right here
that doesn't work?
no
tasks.Add(Addressables.LoadAssetAsync<Sprite>(location).Task);```
oh
then
var test = await Task.WhenAll(tasks);
foreach (var thing in test)
{
AllSprites.Add(thing.name, thing);
}```
I messed something up...
Awesome man, it works now. Seems a lot faster than before. Thank you so much!
np I'm glad and kinda surprised because I rarely use async await haha
Does anyone know how to clear Addressables cache?
Similar to how you can use AssetDatabase.Refresh() in the old system.
I am trying to re-load definitions at runtime (I read my information from YAML files, so I want to change then when the game is running, and reload with the new information)
Addressables.ClearDependencyCacheAsync(allLocations);
Caching.ClearCache();
I've tried these two options but none of them seem to work
Also, is there any way to change the folder name from "Resources_moved" to anything else a bit more coherent?
I've just had a bit of a surprise. AssetReference is a reference type and also has no hash support or equality operator. Does anyone else find this surprising?
hi guys! I don't have much experience with Addressables and I know that I might be looking at it on the side that it wasn't designed for, but - is it possible to get the address of an asset from its instance? for example - i've got a SO which is addressable. I've got instance of it (in memory). How one would try to obtain address of this asset in this situation?
Has anyone gotten addressables working with WebGL? It fails to load for me and gives me no information whatsoever.
This isn't possible. Addressables, at runtime, is a one-way street from address to asset.
I think there are quite a few WebGL topics on the fora, but I don't have experience running Addressables on WebGL, so can't comment or help on that unfortunately.
Hi guys, sorry Im new to addressable, lets say I have set one of my scene to be addressable and I make some change to one of the script that used in the scene, do I have to re-built the addressable data?
Depends on the changes of the script. If it's pure the logic of functioning that has changed, but nothing related to data that is serielized, e.g. you didn't add a field that needs to assigned through the inspector or something, then you don't need to rebuild.
If it does have a such a change, it will need a rebuild.
oh ok, thanks for sharing this info 😀
I'm getting two really useful console errors when I try to build addressables. Nothing is coming up in my google searches, wondering/hoping someone else has come across these and knows what's going on
path
UnityEditor.GenericMenu:CatchMenu (object,string[],int)```
Addressable content build failure (duration : 0:00:00)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)```
If you use LoadSceneAsync, then activate the Scene. then swap to an other scene, and you want to come back to your Addressable Scene... Is there a way to do it?
If I do LoadSceneAsync again, it will fail saying it's loaded, if I try ActivateScene, will tell me scene already loaded
Does anyone know how to clear Addressables cache?
Also, is there any way to change the folder name from "Resources_moved" to anything else a bit more coherent?
System.IO.DirectoryInfo.CheckPath (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.DirectoryInfo..ctor (System.String path, System.Boolean simpleOriginalPath) (at <695d1cc93cca45069c528c15c9fdd749>:0)
(wrapper remoting-invoke-with-check) System.IO.DirectoryInfo..ctor(string,bool)
System.IO.Directory.CreateDirectoriesInternal (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.CreateDirectory (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode.MoveFileToDestinationWithTimestampIfDifferent (System.String srcPath, System.String destPath, UnityEditor.Build.Pipeline.Interfaces.IBuildLogger log) (at Library/PackageCache/com.unity.addressables@1.18.9/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:938)```
I get this error when attempting to build addressables with the RemoteLoadPath set to a web address.
Maybe I am using the remote load path wrong? I thought it was supposed to be the eventual path where I will upload the addressable content? Idk why it would try to build there. Shouldnt it build to the remote build path? not build to the load path?
Also, is there any way to change the folder name from "Resources_moved" to anything else a bit more coherent?
I don't think so. It's just so named so that it doesn't include those assets in resources, and thus in a player build. If you want it changed, you'll have to change it in the source code as I don't think there's a setting available where you can change that neatly.
And what cache do you need cleared? The runtime cache? Or the build cache?
uhh
the runtime cache
I asked a question here a while ago
but no one seems to know
There is two method to clear cache but neither work with latest version I use
if (Directory.Exists(Caching.defaultCache.path))
Directory.Delete(Caching.defaultCache.path, true);
Yeah, seems like there are a few issues with clearing cache. Never had to use it because I use local bundles only.
Method that should work is either Caching.ClearCache() or Addressables.ClearDependencyCacheAsync
What does the remote build path look like?
tried both of those and didn't work
So use the direct method like I do
if (Directory.Exists(Caching.defaultCache.path))
Directory.Delete(Caching.defaultCache.path, true);```
the "unity" method use to work in previous version but not anymore... the DIrectory.Delete does work, you just need to make sure it's execute before you call anything about addressables
Right, but that would mean Unity would start an upload to that address, which it doesn't do.
You have to define an address that you can write to during build (like an actual folder on your system that you're building on), and it will place the bundles there. Then you're supposed to upload those contents to the location that resembles your remote load path.
so I have to swap out the RemoteLoadPath every time I build addressables, then put it back for actual build so it can load from there?
lol yes you need Alebasco... it's really fun 🙂
Once your build script is setup, it goes well, but it's a pain
😮
Wait, to be clear, both your remote build and remote load path point to the same address right?
no, RemoteBuildPath is ServerData/[BuildTarget]
Right, so the default value of the profile?
I just tried it, it doesn't seem to work
What is the default cache path on windows?
Do a watch in debug for Caching.defaultCache.path
This is my setup. I thought it would build to the build path, and only use the load path when.. loading?
or give me a minute
as said, it won't work if you have initialized Addressables
C:/Users/----/AppData/LocalLow/Unity/YOURGAMEBUILDNAME
How do I know if they're initialized
in your game, as soon as you do a command about Addressables, like DownloadContent, it is initialized
I load them like so
Do I need to release anything to uninitialize them?
or how does it work
when you do LoadAssetAync
you need to clear the cache BEFORE, after is possible, but would need to look in addressable code and it's a total mess
Yeah, you're right, but I asked for the remote build path, and you gave me the remote load path, so it got me confused. (And you never know what someone types in those fields, so wanted to make sure).
The exception apparently stems from this... But I have no idea which character is supposed to be invalid though.
I did once to find out why the % downloaded was not working, and I will try to avoid
Not often, I only use it for development purposes
I load all of my data from YAML files
then you can delete manually
I can change stuff in yaml, and while the game is running, I want to delete the cache and load all the stuff again with the new values
then run that command as the first thing to run in your game... or before any addressable command and it should work
I can't find my game at that directory
Looks like it never creates the cache here, hence why I cant delete it
Where else could it be?
Unity 2020 and addressables 1.16.19
yes, I've debugged and looked at that "Caching.defaultCache.path"
it points here
and there's nothing here
appdata\locallow\YOURNAMEGAME does it exist?
yes, but before the game name it's company name
Ah! sorry I gave the wrong path. It errors though when looking at the RemoteLoadPath, but I dont know why it is looking at that path at all while building? Still very confused as to what I am doing wrong
locallow\company\gamename
these are the settings in the adressables object
anything to do with this, perhaps?
that's ok, what's there?
if you work locally BTW there is no cache
under that ocallow\company\gamename do you see a folder that look like a GUID?
no, nothing
I dont even know what or where these paths are
How can it be so complicated to find a cache xD
gg unity
@cedar jungle
Hmmm, I'm running 1.17.1, and I see that some functions don't have the same name anymore, so they definitely changed some things up in there between then and your version (1.18.9), so perhaps this is a regression issue, because on my end they use the Schema's buildpath, or so it says in the code... Perhaps this value is overridden somewhere else that it becomes the load path...
var path = schema.BuildPath.GetValue(assetGroup.Settings);
...
var targetPath = Path.Combine(path, outputBundles[i]);
you have no cache if you are local
uhh
how would I achieve what I need then?
am I even using the correct terminology?
I need to clear whatever data is saved when loading by address at runtime
Do you plan to distribute your data by addressable?
is your editor setup to use cache data?
I'm not sure...
the 1st one just bypass all addressable configuration and use the asset like a resource folder (or close to)
Documentation is not addressable forte
Addressable is a like a pot of boiling oil, and you need to fetch something in it with your bare hand... so you go only if you "REALLY REALLY" need to 🙂
you aren't far from wrong
yes, the default build script
this is how I always rebuild
and file have appear in the proper folder?
not sure what folder I'm looking for
do you download your addressable?
it's one level before your asset folder
Next to your Library folder in the project's folder structure
thank @shrewd geyser 🙂
nope... that's the build path, and you only have the hash/json, so you are building nothing
I need to make addressables forget everything it's loaded completely, and then do it again from scratch, at runtime
what is in your data group?
could you please clarify
downgraded to 1.17.17 and got the same result
https://hatebin.com/bevogvmpuz
what do you mean by data group?
relatively new to addressables so don't know where to look
btw, I really appreciate you trying to help me
no problem 🙂
see what? what am I looking for?
nothing changes when I build, unless I'm missing something
Hmmm, can you check out what it actually tries to use as a path? Or set a try-catch around the Create directory and then print out the problematic path
your build script could not be configure properly...
http:\myname.s3-website-us-west-2.amazonaws.com\Addressables\StandaloneWindows64
So, the RemoteLoadPath for this platform
missing a \
But I'm literally using the default one
did you follow the step on the addressable doc page? on how to use?
right, it shouldnt be using this path at all. Its trying to convert a webpath to a local directory..
ok sorry
you should start by that @rigid shadow been I while since I configure mine, and you may be missing something that I don't see
Instead on the global addressables settings, have you perhaps edited on one of the group's settings where the build path has become the load path?
I have no idea what to do... Could you atleast link me to the specific documentation? Also, it doesn't make sense this doesn't work because addressables are clearly loading my assets. Every time I restart the game, I get new values from my YAML files. I'm just looking to not have to restart for that to happen...
yes...
omg. I'm such a moron. hahahahaa I've changed it so many times as I try to get WebGL to work...
Thanks. Now I can go back to trying to figure out everything else...
Glad to have sorted that out! :D
thanks for walking through it with me. Now if only I can get WebGL to work with addressables...
Yeah, can't offer any help or experience with that one I'm afraid. I'm keeping my games on standalone 😅
I wish I could stick to just standalone. Haha company really wants me to test on WebGL, but I cant get it to load anything from addressables successfully so far 🤷♂️
okay, so I have some info on why my WebGL build is not working. It is looking for
StreamingAssets/aa/settings.json
Which doesn't exist. I found the file in the library though, so I could copy it into the project... But can anyone tell me what this file is? (And for bonus points, why it wants it to be in streaming assets, and if there is any way to have the general build process to handle this like I would expect it to?)
If anyone's interested - to fix this I had to create a new packed group, set that to default and delete the old default (the default group auto created)
I copied it into the correct folder and rebuilt, and it still can't find it apparently?
curious if anyone can assist me in setting up a good work flow deploying Addressable bundles through the built in Cloud Build Delivery. As I currently understand it, each time a build completes the content is uploaded to the bucket and old files are removed from the bucket, then a new release is created. Is there a way to ensure that old versions of the app can still see the old files? I want to associate each version of our app with a release of these buckets. Currently I don't see an easy way to do this without doing some custom scripting
ideally we could inject the Release ID from the cloud bucket release version back into the RemoteLoad path
Nothing built-in that would let you do that automatically as far as I’m aware. I might think about an editor script that changed the remote load path each build to a versioned directory. If you’re addressable builds are separate from your app builds, obviously you’d need to think about what that would mean.
Could not load StyleSheets/Extensions/fonts/ınter.uss
I'm getting this message at the start of a project. What should I do?
It started to happen after I switch to visual studio code, I don't know if it relates
I hope I'm asking in the right channel
Edit: After some restarting, it is not shown anymore.
@mild flax yah my current idea is to set remote load path to a version code badge. After cloud build finished just set this badge when my CI system uploads to the stores
just update, did what I described above and worked well
i've recently entered in this chat, someone must have passed through this, could mention a hint about missing default shaders in android using existing build?
oh, got it build scripts are different from editor, so i had to build them to see, android-only
hope unity has a work around for calling shaders for editor support
Anyone has any idea how addressables handles nested prefabs? For example if both a master prefab and its sub children nested prefabs are addressable assets, if I load the master prefab it handles the internal prefabs as part of the master prefab or solves them through addressable assets?
I think anything that is referenced inside the prefab comes along with it when you load it
Meshes, textures, audio clips, other prefabs, etc..
Does anyone know if addressables work on google play or app store
I have no experience myself, but perhaps this can help?
https://forum.unity.com/threads/using-addressables-along-with-google-play-asset-delivery.905831/
@shrewd geyser thanks! that was very helpful
I stumbled into another problem, and when I load addressables scenes, the scripts in the new scene become like this, anyone knows why?
And this error is thrown
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) ```
There is a workaround for that.
You can change the Graphics api in standalone windows player settings to OpenGLES3 (remove direct11, leave opengles only) and shaders should load as they would on Android. (Yes, settings for windows player affect editor for some reason).
It kinda works for me, but it was crashing on one of the scenes I've got in the project - might be something wrong with one of the custom shaders though
(or the graphics api settings for mac/linux, whatever system you're on)
Someone explain to me why taking c sharp that has virtual pointers anyway and going full circle away from them and then reimplemented as another layer of abstraction makes the sense
you mean object vs Object?
or that you should be releasing handles?
i mean at the highest level for the whole system here
its a layer of abstraction into managed code where pointers get virtualized and generally arn't advised where you develope an entire subsystem and abstraction just to get back to pointers again
Sorry for the noob question but I would like to know if my use case fits Addressables:
I want to add modding support to my VR game. For code I can easily design a mod loading system but for assets I have no good idea how to allow third party programmers to load assets at runtime and use them in their code. Is this something that can be solved with Addressables?
From modding in RimWorld I got this working myself by using the exact same version of Unity as the original game and exporting asset bundles. It’s cumbersome and unintuitive especially if you want to support multiple platforms. It breaks easily if the game updates its Unity version too.
I found https://answers.unity.com/questions/1300001/can-a-unity-game-createload-assets-at-runtime.html - is there anything else that can help me make this a nice experience for mod developers?
Any comments on using https://github.com/atteneder/glTFast ?
I honestly prefer glTF over assetbundles and desperately want Unity to support gltf without us having to grab 3rd party code
The benefits of Assetbundles are things like, being able to do some pre-processing in Unity before exporting the bundle
So you can add script references and such to an asset and Unity will hook them back up for you (as long as the script exists in the project)
However for 3d assets you can make them significantly smaller using GLTF thanks to tech like draco. And more flexibile thanks to texture tech like BasisU.
Unity supports neither inside of asset bundles
Hey all, I'm looking for some eyes on this scene preloader code that uses Addressables in a WebGL build — I'm getting a bizarre build-crashing error when the download completes and can't figure out what might be causing it. Any and all help appreciated! https://forum.unity.com/threads/webgl-build-crashes-when-addressables-downloaddependenciesasync-reaches-completion.1147703/
So if you need to stream lots of stuff over the internet, I really like GLTF for that.
If you don't, assetbundles are fine, but there is a possibility they can break between Unity versions (it is rare) and you have to rebuild them from the base assets using a newer version of Unity.
Using a newer version of Unity to make assetbundles for a game build using a lower version of Unity is probably also not good. I have never tried that personally.
@fresh furnace btw
Addressables still uses assetbundles underneath its layer of code. So no changes there. All the same limitations still exist.
In theory, if you directed people on how to create catalogs with specific names and how to name their addresses for their assets players could load their own assets that way, yes.
Basically everything in Addressables can be grabbed by string like grabbing something out of a Dictionary, so if your game can support that then you can allow players to control those strings.
That sounds like a nightmare to support. I was one of the users of that myself in RimWorld where I was the first to import asset bundles and I had to match the Unity version exactly to the game.
Most modders are coding beginners
I want an easy way to code and have some custom assets too. The typical modding scenario
See I am surprised to hear it was that sensitive for Rimworld. I have worked with asset bundles in the past and used bundles that were built in pretty old versions of Unity that loaded fine in newer ones.
But like you said, they CAN break eventually.
And Unity's solution is "rebuild the bundles from scratch"
GLTF is potentially easier from a standpoint of asset longevity. But it will require a lot more work for you personally because Unity doesn't support it out of the box.
You'd have to extend GLTF's JSON spec to pass in material info if you have complex materials and shaders that can be a pain in the ass.
Also your players would need to preprocess textures, turning them into DDS, Crunch, or Basis (if you wanted to use Basis) compression
You can make tools to make that easier yourself, of course
We are talking about modders here. You know, those who disassemble dll’s to look at the source code, which normally is partly private, and then make it do stuff that it wasn’t intended to do.
If I can at least document how to get assets (like meshes and shaders) into the game and also document how to do stuff in code that you normally would do in the editor, it should be better than nothing.
There aren’t many games out there that support bringing assets into the game. I can at least try
Make all my code very modular and with lots of public submethods. Maybe use gltf myself and by doing so create some helper code that modders can use too. I’m at the core a low level coder anyway and prefer to do a lot of thing algorithmically anyway instead of having lots of logic invisible in the editor.
RimWorld has defs - xml that is deserialized when the game or a mod has such files in it. I hate it and rather create stuff from code. It’s a different mind set.
What is missing is the way to get the raw material into the game and have it independent because mod and game have its own lifecycle
Yeah, so, there is no other way to get completely new shaders into Unity besides Assetbundles (that I am aware of)
If you want to allow custom shaders, you could in theory import them in an Assetbundle first and then after you import your GLTF model, ask all materials to use that freshly imported shader
Will that Assetbundle with the shader break in the future? Maybe. But you'll only have to rebuild the bundle or bundles containing the shaders instead of all of your assets.
True. The biggest complain I have is that asset bundles are platform specific. So one has to create 3 files for Mac/Win/Linux and then in the loading code again choose the right one. Not very elegant
Yes, that is because of two things. Compiled shaders for that platform, and texture compression formats. Also probably other minor reasons since assetbundles can have all sorts of stuff in them besides just meshes and textures.
Basis is supposed to solve the latter, but I haven't experimented with it myself. If you don't need to support arbitrary custom shaders, you can potentially use GLTF+Basis to create textured 3d assets that will work on any platform that supports loading Basis textures at this time.
That sounds promising, thnx!
Hello.
I just don't get it that "Addressables" is a replacement of "Asset Bundle"
when to choose "Addressables" over "Asset bundle download and caching"
Unity is making something awesome but does not make any fujking documentation. So who is gonna use this super feature?
Unity developers, please with all my respect, hire someone who can write a DOCUMENTATION. and make some Q&A videos
regarding this addressables.
Addressables, in my experience, has been a layer that exists ontop of asset bundles to help build and manage them
but it is quite complicated to work with
there is definitely documentation for them, but I feel like the way people stream assets varies wildly
right now I'm running into problems in using Addressables if I'm unsure a catalog will exist on my webhost, for example
seems Addressables just throws a bunch of errors that I can't catch myself
LoadResourceLocationsAsync is marked as obsolete.... I can't find any documentation saying what you are supposed to replace it with
does anyone know?
https://forum.unity.com/threads/deprecated-versions-of-loadassetsasync.959658/
nvm, i think they just swapped IList for IEnumerable is all
Anyone else losing references in scene-objects in addressable scenes?
It seems to be happening at random to me.
Wrapping the entire scene content in a prefab and loading the prefab as addressable works fine, keeping all the references, but why aren't addressable scenes working as they should?
nope, not a problem iv had with it. Though iv had times where i'v updated the scene. Had my build scripts set to 'use existing build' & then because I didn't rebuild the package, it would not be maintained. That's frustrating. Are you sure it's not the scenario your running into?
nope, I found the reproduction steps though
When a scene object references a component in a prefab - the reference is gone in a built scene.
If you add a reference to the prefab as a gameobject in the same script - all is well. Seems like a bug to me 🤔 , Imma submit a bug report with that
Seems like Unity made a stealth fix for that - yesterday's version 1.18.15 kinda fixes it - it still doesn't work out of the box, but marking the prefab with the referenced component as addressable fixes it now.
I say it's a "stealth fix" cause they didn't bother to create a changelog for 1.18.14 or 1.18.15 ... C'mon unity
Hello everyone !
Did any of you managed to make a "Hello world!" example with multi-project addressables ? (https://docs.unity3d.com/Packages/com.unity.addressables@1.18/manual/MultiProject.html)
Guys! Is anyone having problems loading addressable additive scenes. It keeps loading and there is no other task running alongside
nope, works fine for me - are you getting any errors in the console, or logs saying that some bundle is not found?
no, guess must be some configuration maybe, right?
Hello.
I really need to learn this. really appreciated in advance if you help me out!
I quit using asset bundles.
and want to use "addressable system"
my question is : I have 10 book store in my database and all of them have their asset bundles.
in order to download and use one of the book store, I need to specify my "ADDRESSABLE PROFILES" right? because my remote load path is going to download the content
I mean should I store my "addressable profiles" in database and download this first and convert it into "scriptible object" and assign it into my "profile"?
is that correct?
No, the profile only tells the build where to get the bundles from, you don't change anything with the profile after you built the game
In order to download one of the 10 "book stores" you need to store it's address somewhere, so the game knows what it should download.
Or you can use labels and LoadResourceLocations: https://docs.unity3d.com/Packages/com.unity.addressables@1.18/manual/LoadResourceLocations.html
what address are you talking about? let me explain little bit more and visual. thanks for the help
Every addressable asset has an address, that's like the whole thing about this system. It's visible in the inspector and in the addressable groups window
But I will have more than 10.000 book stores and more than 1.000.000 book assets.
let me explain with an example.
I launched my application and went to a bookstore. According to my location, the bookstore where I am in will be detected and will start downloading the content (all the book assets) and I will use these book assets in my application. (AR application)
So, in addressables, I should write the "remote load path" before I build asset bundles.
@ionic shadow
but at the same time when I download the content, I like to save them into the local storage and if there is no new version, my application will use the one it has, otherwise it should download the new version of the content
what should I do I do notknow
maybe the asset bundle system is much more suitable for this?
make asset bundles for each "book store" (1000 books in an asset bundle) with their manifest file. Put them into the server. Download the manifest first and find the asset you do not have. download it and cache into the local storage and use... what do you think?
Addressables is a system built on top of asset bundles, it's still working with asset bundles in the end.
You can preload and cache bundles using DownloadDependenciesAsync: https://docs.unity3d.com/Packages/com.unity.addressables@1.18/manual/DownloadDependenciesAsync.html
Bundles are cached automatically in addressables - just like they are in asset bundles when you supply the bundle version hash.
You should IMO have every book store in a separate bundle, and figure out a system to get the correct bundle from a location - something as simple as a naming convention would work, but you could also go with creating a ScriptableObject that holds a Dictionary<StoreLocation, BookStoreBundleAddress>, keep that as addressable and make sure it's always up to date.
But it's a project-specific use case, so there's no built-in solution.
thanks I should read over it again!
yep
so, I do not need to use "profile" to retrieve the data.
Tries to get it from cache first, if it's not there- downloads it and caches it
the profile is basically just settings for the system - so it know where to get bundles from groups marked as "local" and where to get the ones from "remote" groups
but I have more than 1 remote asset groups (different book stores) how can I change my adressables direction?
I have to do that in runtime
I took too much time, this is the last 🙂
I'm not sure I follow
Do you want to keep those assets in different services with different urls?
if so, then I guess you'd need to look into this: https://docs.unity3d.com/Packages/com.unity.addressables@1.18/manual/AddressableAssetsDevelopmentCycle.html#customizing-url-evaluation
I keep all my bundles in one place though, didn't have a need for that kind of thing
yes because more than 100 bookstore that have more than 1.000 books
"The content update process creates a new version of the catalog (with the same file name) to overwrite the file at the previously specified load path."
My previous content is 10gb and I made a tiny changes on one of my content for 10mb
Do I have to overwrite all the 10gb+10mb ?
Or is there a smart solution?
I believe using the "update previous build" option rebuilds only the changed groups, and not the entire thing. So unless you keep everything in a single 10GB bundle, you won't be replacing everything, only the changed files.
@steady quiver are you loading more than one scene? or trying to do other adressable command after loading the scene?
thanks
Hey everyone, I'm stuck on something with my addressables and I could use some help. I added some materials to the default group (no label), these materials use a custom shader. I build my app for WebGL and tried to load a material and assign it to a mesh. According to my debug.log the material is found and assigned to the mesh but I get the hidden/InternalErrorShader aka Pink meshes. I've included the custom shaders to the "Always include list" in the graphics settings but that did not help. Any idea what I'm missing? Can someone shed a light on his. It my first time using addressable and I got the feeling I overlooked something obvious..
Is this happening in the editor or in the build?
It happened in both, i just got it working in the build now however, stupid coding mistake on my end. In editor i still get the error. I assume its the same old bug of not being able to use webgl bundles in editor?
Yeah, that's what I assumed, since that's what's happening on android for me
Jesus, why are addressables losing references at random?
-they lose references when an object references a component in a prefab (not the entire gameobject) and the prefab is not marked as addressable
-Referencing a prefab as a gameobject works without having to mark it as addressable
-BUT NOT ALWAYS, as it seems - everything is fine in the editor, but in an android build - references to random gameobjects are getting lost, crashing the game whenever the reference is used.
The error that's showing up is:
The file 'none' is corrupted! Remove it and launch unity again!
[Position out of bounds!]
Marking the prefabs that are "gone" as addressable explicitly and rebuilding the bundles fixes it...
Addressables are cool, but they are SO BUGGY
You know you have to rebuild bundles everytime you update something inside them? If you dont rebuild it in unity before throwing it at your phone, your addressables wont be ther eor faulty @ionic shadow
Of course I'm rebuilding them. It's not an issue with me making changes and not building them. It's an issue of addressable objects losing references at random during the build process
Using BUILT bundles in editor works fine. Using THE SAME, BUILT bundles on a windows build - nope, this reference is gone, and this one as well. You have 20 other objects setup the same way and they're working? Too bad, this one won't work, even though there's nothing special about it ¯_(ツ)_/¯
It might also be partially caused by our project using Unity beta 😐
well... 😄
this part might be important
Anyone have a way to preview which bundle need update before doing a build? I have an issue that if I build multiple time my game, some addressables bundle keep needing update even if nothing change
@ionic shadow for the "none is corrupted", look under addressable analysis and fix the Duplicate rule... that's how I fix it on mine
and speaking of addressable, I love that one also, so cryptic, just like we love them
i'm having a great time (jk) handling unload operations, the first time it unloads it's fine, but after that, i'm getting errors. From what I know Unloading scenes is like Releasing so I wouldn't need to use Adr.Release to clear the handle, right? Also the process is unloading in different variable instantiations, so anyone know an explanation for this?
ok, so i've figure out SceneInstance nor AsyncOperationHandles are being correctly stored to later pe used to unload the scene. The question that stays is how are you handling scene reference persistence for later unload?
I'm using Lists and Dictionaries, but i guess thats not the point instead the process to save it in this structures
Hello.
Addressables.LoadContentCatalogAsync
Addressables.DownloadDependenciesAsync
what is the difference between them?
When we want to bound the addressable to the remote catalog, which one should we go for it
One is just the catalog, you don't need it
@kind relic and the others then new question comes 🙂
what is the difference between Addressables.InitializeAsync and Addressables.DownloadDependenciesAsync
you can bound your remote catalog to the addressable system by just initializing. Right? If so, why on earth do we want to use DownloadDependencies?
or we should first initialize and later on download dependincies ?
DownloadDependenciesAsync - you pass in an assetreference/label in there, and it downloads and caches the bundles related to that asset/bundles with assets marked with that label, I use it at the start of the game to prepare everything for smooth experience later on.
InitializeAsync- initializes the addressables system basically, it's done automatically be default - you can disable it in addressables settings if you want to
if you don't use DownloadDependenciesAsync, you'll have players downloading stuff only when they use it for the first time, which might be bad- for example if you keep all your scenes addressable and suddenly when going between them, a player has to wait XX seconds to download a large scene bundle for the first time
But it might be okay in your specific use case, if you have a lot of small files, and no way to figure out what needs to be preloaded ¯_(ツ)_/¯
@long escarp initialize is call by all other function in the background, so you don't usually need it. You usually just do DownloadDependency
thanks for your time to answer first.
but the thing is, I do not want to use "labels" for retrieving data. I only want to use "address" instead.
Because what I have done is:
I have 10 objects in a remote catalog being hold in the server. I only have the addresses of those objects. (I created them in bundle making process.)
So I want to retrieve that asset by using address.
Is there any way to do that?
@ionic shadow @kind relic
1- I want to download all the asset by "addressess"
2- I want to get them by using these "addresses" (not labels or Adress references)
- I don't know, I don't bother to download bit by bit, since it could give a bad experience if the bundle are not locally cached yet.
2- Those are prefabs? or which kind of object they are.
For me, since my scene include most of the object so they are all needed when I load the scene. Can you elaborate what you are trying to achieve in #2?
I have 10 3D beverage objects with material on it and some textures.
What I have done;
- I put all the objects into "Addressable groups" and gave them an address. I do not know maybe I should have given a "label" what do you think?
- I made a asset bundle files for Android.
- Uploaded these files on AWS server.
- I changed "remote load path" in profile to point my server.
What I want is
When the app is started I want to download them all without consent of the user. So whenever user do something, I will call one of the assets.
thanks for patience!
@kind relic
Ok how do you add those object to the game? are they prefab? Are they already in a scene?
- During the "start" of your game call DownloadDependenciesAsync to download everything.
- If they are already in a scene, you have nothing else to do
If they are not, then it depend how you plan to "add" them to the scene
- this is my group. I want to call one of them as calling like that : 500/100.
I need to instantiate them in a common scene. I mean my scene will never be changed. These are mesh prefabs
You can think of this as a "character selection scene"
so when the user clicks the "next" button, the previous one will be disappear and the next one will show up.
but all the buttons will be used by the user are going to have an address. these addresses are coming from the Database (dynamoDB)
@kind relic
I think I should use this method to call a prefab after I download them.
AsyncOperationHandle<GameObject> goHandle = Addressables.LoadAssetAsync<GameObject>("100/500");
yes... it should work
should i bother using addressables for open world or just uninstall the package, anyone know genshin impacts strategy
Well.. you probably will split up the world into separate scenes/prefabs/whatever to load it in chunks, instead of having the entire world loaded at all times, so why not?
I don't know how genshin impact works, I didn't play it, but if it's an open world game - I'd assume the world is split into some sort of chunks.
Addressables are not a must here, but could be useful, if you'd want to iterate some parts of the world, without having to make a new build of the game every time to test it.
Does anyone know how to identify the missing script when loading adressable and you receive that?
Addressables in and of itself won't be a solution to creating an open-world game (at least, that's my impression of it as seems to heavily look over to Zelda BotW). Addressables might be part of a solution regarding to content managing, but the tech for creating such a game will probably be highly custom. There are some world-streaming assets to be found on the asset store.
A possible implementation for this would be like this:
- Have a very low-detail model of your environment/terrain that is always loaded in and can be used for rendering stuff off into the distance
- Have medium detail chunks of the world (prefabs, or scenes) represent environments or regions of the surrounding areas you can go to with your characters. Load/unload them as you move closer to/away from them.
- Have a high detail version of each chunk of the world loaded in which your character currently standing in and the ones very near to you.
Something Addressables could help with in this case is that you can easily load in chunks of the world and detail based on labels or an address, instead of you yourself looking through Resources etc., or get it downloaded from the server when needed to keep the initial install of the game small, but have it grow over time as the player progresses through the game.
hmm i am going to have to stream in scenes custom like
will adressable help with this
or should i just use resource load
:/
what do you think genshin impact does
Addressables can do that for you, yeah.
I don't know how Genshin Impact does it, but it seems to be built on the Unity Engine. So they will either use something like streaming in scenes (using either Asset Bundles, Addressables, Resources), or something custom is possible as well. It's a pretty high budget production it seems, so I wouldn't be surprised if they developed some custom tools for this.
Anyone have this weird issue where after opening the project for the first time, you need to go into addressables->groups and open a group for it to be loaded properly? Very strange
Otherwise it will throw a bunch of errors for me
InvalidOperationException: Collection was modified; enumeration operation may not execute. System.Collections.Generic.Dictionary`2+ValueCollection+Enumerator[TKey,TValue].MoveNext () (at <695d1cc93cca45069c528c15c9fdd749>:0) UnityEditor.AddressableAssets.Settings.AddressableAssetGroup.GatherAllAssets (System.Collections.Generic.List`1[T] results, System.Boolean includeSelf, System.Boolean recurseAll, System.Boolean includeSubObjects, System.Func`2[T,TResult] entryFilter) (at Library/PackageCache/com.unity.addressables@1.17.17/Editor/Settings/AddressableAssetGroup.cs:468)
If I opened the group once it will work fine...
when should one use a group vs a label?
I'm not sure I understand this question... They're not really related.
A group defines how you process assets together in terms of building and location. Assets put in a group can be configured to be downloaded from the internet, can be configured to be have a different naming scheme than other assets in other groups, etc. E.g. if you're developing an RPG with different kinds of weapons and armor, you can create a group per item and group the prefab + textures + material, or you can group based on asset type like making a group of all textures, all materials, all prefabs, etc. Whatever works best for the type of game you're building and how you plan to distribute it.
A label is used to find or load assets in the game. E.g. the 'music' label on assets can be used to load in all 'music' assets across all groups.
that's very helpful, ty! Is the only way to use labels in my code to add some string references into the codebase? that makes me somewhat nervous but it seems like a better organization tool than remembering to drag and drop a reference to the addressable in a serialized List
btw, in your example with grouping RPG items — if my prefab referenced textures and materials, and I only explicitly added the prefab to the group, those referenced textures/materials/other stuff would automatically be included in the group, right?
Yeah, they would automatically be included in the group.
do you guys put animation controllers in addressables too
Yes you need them
Is there any way I can use addressables within Google Drive?
Yes... never tried, and it can be complicated if you need to write your own module to generate URL
You’d need to write a custom url resolver and probably paste every url generated by google drive in to that script by hand.
It would also be very slow.
Get the free tier of unity’s CDN instead, if I remember correctly the first 50 GB of bandwidth is free
Or any cdn, i use bunny and it cost me nothing. Or close to if you use basic service...
I keep getting this error when trying to build my adressables
Does anyone know what it means? I had taken it as perhaps i deleted a file that used to be an adressable. & I just needed to remove it fromt he adressables group...but I don't see anything with an empty path
i think iv tracked it down to when it tries to build the materials. I see nothing unique about this particular build group.
iv compared the build group settings to another one that worked, and they are identical.
it bombs out when it trys to build the very first item in the build list. Specifically it bombs out when calling the method "MoveFileToDestinationWithTimestampIfDifferent"
this particular addressable group has not changed in a long time, and has worked the last few builds.
the only difference I can think of between this build & last time that might affect it is me shfiting from the standard rendering pipeline to the universal pipeline. I'm not sure if because it's a material, is there possibly an extra step I have to do to get it working with the adressable system?
i have also tried to remove all of them & re-add them incase there was a funny reference problem, but still no go
if i remove the group entirely. I still get this error
implying to me that there might be more than 1 problem, or the problem might have nothing to do with what i thought it did.
also tried updating the addressable system in case it was a known bug that was already fixed.
ok...so i removed all the addressables in that group. rebuilt and cut it from the 4 errors to the 1 i posted. I then Added a singular material to the list & rebuilt. And then it went back to the 4. proving it definitely doesn't like the material for some reason & that i probably have 2 problems, though where to begin on the second problem, idk yet.
this particular problem, when i cut it down to 1 material. it still reproduced the problem. Then i 'simplified' the name, on the theory that it was due to just being too long of a path. & that actually seemed to work. I'm going to re-add all the other ones, and confirm the names are all simplified & try again
and that seemed to do the trick...now i just have the last funny error to track down
ok. i have no idea about the second error. fixing the first one fixed the second one after a reboot.
so root of the problem if anyone runs into it again, i believe is the fact that the group\adressable name was too long because i had it defaulted to use the full path.
solution: right click the adressable to 'simplify name' and that worked. Another option probably would have been to flatten the folder structure in which it resided.
Reason it took forever to solve: nothing about the error message told me what group had the problem, nor what the problem actually was.
Perhaps you can also set the naming scheme of the group (or all groups) to use the hash of the asset name rather than something else. This usually also really shortens the paths being generated. They’ll be less readable, but on Windowss less of a chance to run into path length issues.
with addressables, if I want to have images user can download individually I need separate group for every image?
No, make a group with bundle mode "pack separately" and every image in that group will have its own bundle
Hi everyone, I'm experiencing some weird bugs in my build. Is there any reason in particular why an addressables key lookup won't work in the build?
It works in the editor though
I'm using Localization
Got it solved, apparently there's an issue with preloading 🤨
Sooo I got an architectural problem I can't wrap my head around.
[Test]
public void ShouldInstantiate()
{
var builder = new Builder();
var gameObject = builder.Build();
...
}
public class Builder()
{
GameObject gameObject;
public Builder()
{
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("...");
gameObject = Instantiate(prefab);
}
public GameObject Build()
{
return gameObject;
}
}
I have this builder class that I am using for my unit tests
But I want to use the builder also in play mode for actually building things
So I need to change the AssetDatabase.LoadAssetAtPath call to use Addressables.LoadAssetAsync
The problem is, I can't really use it since I can't make the unit test async
public class Builder()
{
...
public async Task<GameObject> Build()
{
var prefab = await Addressables.LoadAssetAsync<GameObject>("...").Task;
var gameObject = Object.Instantiate(prefab);
return gameobject
}
}
This would theoretically possible, but since unit tests can't be made async to my knowledge it's not an option
[UnityTest]
public IEnumerator ShouldInstantiate()
{
var builder = new Builder();
yield return builder.Build();
}
I could change the unit test to an IEnumerator so I can yield return the Build() operation, but I don't really know how the signature of the Build method would need to look like for this to be possible
public class Builder()
{
...
public IEnumerator Build()
{
var loadOp = Addressables.LoadAssetAsync<GameObject>("...");
yield return loadOp;
var prefab = loadOp.Result;
var gameObject = Object.Instantiate(prefab);
}
}
I of course could make the Build method a coroutine itself, but I then wouldn't be able to return the instantiated GameObject
I had to add a CustomYieldInstruction to my Coroutine wrapper class and had to write a custom attribute, but now I can do this:
public class CityBuilder : Builder
{
[LoadAsset("prefab")]
GameObject CityPrefab { get; set; }
public GameObject CityObject { get; private set; }
public override IEnumerator Build()
{
yield return base.Build();
CityObject = Object.Instantiate(CityPrefab);
}
}
public class Tests
{
[UnityTest]
public IEnumerator ShouldLoadAndInstantiate()
{
var builder = new CityBuilder();
yield return builder.Build();
var cityObject = builder.CityObject;
Assert.NotNull(cityObject);
}
}
ughh.... it's been a month unity never responded
Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
this seems to be caused by asyncoperations that i'm trying to store? or it could be something else? Also something is causing my build to stop in a loading process and i've already tried to change addressables play mode script to existing build and it works in editor
hi friends, is anyone using addressables with user-generated content?
like, imagine if users could create their own cosmetics, and those cosmetics would be automatically packaged (by the server, say) as an addressable
is that at all possible? or would i be better off just storing the data myself in the cloud and creating objects to represent those cosmetics at runtime?
@edgy adder I don't think that's possible, since asset bundles can't be created in runtime and addressables are just an asset bundle management system, but I might not know about something.
yeah, that makes sense. i was actually very surprised (and disappointed) to see that updating addressable content remotely requires the build to specifically reference the previous build artifact, that seems quite an annoying limitation
i'm not even sure why it's necessary
even just trying to get that to work with UGC would be a challenge in itself
I have 20 stores. and 20 stores have 100 products.
all products consist of a 3d object and its dependencies (texture, sound, material)
how should I put them into server?
- should I split them into "catalog groups"? (All the stores have their own catalogs. I call this catalog in runtime according to the store has been selected by user.)
- or should I change the "profile remote build path" in runtime?
all the content differs from each other. So they have no in common at all between stores. What should I do.
really thanks in advance.
for the life of me i can't get remote content updates to work
i can make a build that happily pulls remote content from my server (Unity CCD)
but when I run Update a Previous Build and upload the new files and create a new release in CCD, the player never seems to notice the new bundle
i even call CheckForCatalogUpdates() manually and it returns an empty List
a new catalog is clearly being generated, and it definitely has my changes in it (i inspected the catalog.json)
but every time the player starts -- even if i delete its cache -- it fetches the old .bundle, completely ignoring the new one
its like it's just not even looking at the remote catalog and instead is just asking for the old bundle specifically by name
oh you know what, that's EXACTLY what's happening
i just deleted the remote catalog entirely from the server
and the app has no issue loading the assets
so clearly it's just bypassing the catalog entirely and requesting the bundle directly. wtf!
but how did you deal with, for example, a store?
did you put all the assets that belongs to a "store" and label them to retrieve?
@edgy adder
I mean I have a coffee shop. the shop has 10 3d objects. how should I approach this?
should I pack them all in a asset bundle and retrieve by using label?
i'm clearly not an expert on addressables but yeah i think you could use a label for that
you could also use AssetReferences directly if the content isn't going to change after you build the player
^ check this message
@long escarp
all my content will be at the server
I wont have anything even a primitive box in the build app.
really got crazy. If I find someone Ill pay to learn 🙂
could not find in fiverr.com as well
no body know this system.
documentations are not enough and there is almost nothing on youtube. everybody copied the others videos.
is it possible to have "fail-safe" path of the primary one fails?
like for example, two load paths - game first tries to download from the first one, and if the first one fails it downloads from second path
anything's possible you just have to write the code
yeah, I was more interested in how it can be done with addressables 😄
as documentation on this topic is very scarce to non-existent
- Try to load the first thing
- If it succeeds you're done.
- If it fails, try to load the second thing
The documentation is fine
Hi, for those that are using GitHub Actions as a CI/CD pipeline and want to be able to upload their Addressables content to the Unity Cloud Content Delivery service, this article might help: https://medium.com/@bencekovacs/creating-addressable-content-builds-cloud-content-delivery-releases-in-github-actions-ef6bd5b972b2
why not just use Unity Cloud Build, since you're already using Cloud Content Delivery...?
it solves 90% of that for you with just a few checkboxes
does anyone know if it's possible to get an AssetReference from a Scene that's marked as Addressable? for example, if it's possible what would ?? need to be in this code block?
Scene activeScene = SceneManager.GetActiveScene();
// What can I call here to get the AssetReference?
AssetReference activeSceneReference = ??;
I wrote a long reply and it didn't go through for some reason, so here's the abridged version:
- mark all scenes with a label
- Use Addressables.LoadResourceLocationsAsync to load the locations by a label
- Go through them, use IResourceLocation.internalId to get the scene name
- put them in a dictionary <string: sceneName, AssetReference>, you can create an assetreference by using IResourceLoaction.PrimaryKey as guid.
- look up the active scene name in the dictionary to get the asset reference
I didn't find any other way to do that, and that's what I'm using for myself
How can I check if an AssetReference is "none" at runtime? We just had a build crash because an asset was deleted but the runtime error is "invalid key".
Did you try assetReference.RuntimeKeyIsValid() ?
I know that I asked several times but really do not understand and started to feel awakward.
for answers, thanks in advance.
I must change my end point in runtime.
I have more than one content. and my "CORE" application will retrieve data accordingly. For instance if you are in Istanbul, you will retrieve data for Istanbul, if you are in London, then your end point will be London folder. I will catch the location information and according to that, I will download catalogs!
Is addressable system the one that I need? Or should I write my own bundle system?
I did not, that sounds like it could be good.
Addressables would work for this in theory, you'd need to have the same ID available in each bundle. However I can't advise whether it would be the best solution or not.
Is there are reason for that? Will the content differ in any way?
-if you just want to speed up the download speed by choosing a server closer to the user - use a CDN for that
-if the entire content will be different because of <reasons> - you could try doing this: https://docs.unity3d.com/Packages/com.unity.addressables@1.19/manual/AddressableAssetsDevelopmentCycle.html#customizing-url-evaluation and change the URL based on the user location.
thanks!
So i'm trying to load a compute shader at runtime with Addressables.LoadAssetAsync<ComputeShader>() but I have to run the new build script in the addressable window every time I make a change to the shader, and if i havent made a build at all it fails to load. I thought it was just meant to load it from the asset database if i have playmode set to fastest? Am i doing something wrong?
AFAIK you should only need to build groups for your actual build/release.
If I do:
await _scene.LoadSceneAsync(activateOnLoad: false).Task;
Will Awake etc. be called before I activate the scene?
(I think the answer is obviously no, because the objects don't exist yet)
from AssetReference, which value is the key I can use in Addressables class methods?
to be more specific, I have AssetReference to an asset and need to call Addressables.ClearDependencyCacheAsync for that asset
would it be RuntimePath or AssetGUID?
Hey guys, i'm building a mobile app for ios and aving issues if the users put the app in background mode while is downloading assets through addressable. The download process freeze and blocks everything, searched on the web and documentation but nothing.... do you have any hint ?
is there a way to access the addressable group and then the asset list via code?
any way to check if an asset exists?
Going crazy over here
having an invalidkey problem but I havent been able to catch or ignore the error
and it crashes on console so I cannot just ignore it even when it works fine on editor
most probably because you didn't build the addressables before making a build.
Addressable has a system because of which when you load anything in editor, it uses the traditional non asset bundle method. But you can change that behaviour by changing to "simulate builds" or something like that
@untold warren I did build it , it works, it's just if for whatever reason I try to load an asset that doesnt exist
I have no way to catch the exception
I cant actually check if the asset exists based on it's ID
can you paste the stack trace of the error?
InvalidKeyException
not the error type but the stack trace
if it's a Debug.LogException you can't catch it because it's caught internally
let me check the trace but it wont add that much to anything, it just fails to find an asset (because there is no asset with said ID)
and yeah, it's internal
the root of the stack trace of error should show you exactly where the exception is printed from
crash probably shouldn't happen normally because of addressable. are you by any chance loading level?
nope, using the asset name as an id
I had a custom audio system that loaded audioclips from an ScriptableObject dictionary based on ids, but that made it load the entire game's music at once, so I refactored it to load a path/id to an adressable, which works perfectly
it just crashes on build whenever it references an invalid asset
specifically XOne and Switch, works on PC
if that works on pc but not consoles that definitely sounds like a bug. Best thing you can do is by submitting a bug report
play a bit with the addressable sources. in my case it never crashed with invalid key exception but I only make builds for windows
also make sure you upgrade your package once
yeah, i tested them on windows and they work perfectly, issues began when working on consoles
Can anyone tell me how to use split application binary? I want to be able to use the obb file without publishing in app store but manually copying to android folder.
I did that, copied the obb file to Android/Obb through my computer but on launching the apk, the scripts didn't run.
Could someone please helpe with this?
@untold warren building addressables in necessary before normal build, so another question comes to mind - is it also necessary to commit updated addressables_content_state.bin files, or is just having automated build job commiting it (and uploading any changes to addressables to CDN) once in a while enough?
basically, ignore resulting addressables for normal builds and only upload and use results of builds dedicated for this task
it's pretty normal to create the bundles along with build if it's deployed along with the executable. But for remote deployment it's really upto you man and how you want to deal with it.
If you want the automate the build process, say release some Christmas stuff on 25th dec, then some new year stuff for your game automatically on 1st jan (just few examples) you can go with the automated process.
but if you want to add some bundles which rely on a script which is newly added to the player then you'd want to deploy bundles right after you deploy your build.
So it's just a design choice really
Why do the assets downloaded via addressable have messed up shadows? I am using real time shadows and SSAO in my game.
Also, how can I check if all the assets have been downloaded and is stored as cache without internet connection?
I am aiming to build an offline game and want the users to download the assets just once and so that later they could use the application offline.
Thank in advance
https://docs.unity3d.com/Packages/com.unity.addressables@1.19/manual/DownloadDependenciesAsync.html
tldr: use GetDownloadSizeAsync. Cached AssetBundles return a size of 0.
not sure what's going to happen when you call it offline, though
What should I make of this?
I think this asset shouldn't actually be included at all so should look into that. Although I'd like to understand what this is about.
fwiw, i've seen that error about fonts before -- for ages in my project -- prior to using addressables. afaik, it's harmless. also no idea why it happens or how to fix it.
Cool, thanks
question -- is there an API to allow me to programmatically make a given asset (e.g. ScriptableObject) addressable, from an editor script? and also to add labels/change its group? basically automating some stuff that I do by hand in the "Addressables Groups" window
I have a set of scriptable objects that I'd like to hold persistent references(meaning if I save the game with a certain SO in use, I can load the game and reference that used scriptable object just by hitting load) to, would addressables be used here?
Addressables is not used for game saving. You need to take those values from the SO and write them to disk. You can ask more about it in #archived-code-general.
Does anyone have tutorials on how to use addressables with google's Play Asset Delivery?
Do addressable keys include the group name? I.e. group1/assets/test/test.prefab, or would it just be assets/test/test.prefab when calling LoadAsync
cause the second one worked fine in editor but throws InvalidKeyException on Android...
probably you want to be using an AssetReference, not actually typing the asset's name by hand..
it's actually a scene I'm loading via loadsceneasync
Error Unity Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Assets/Scenes/MapTiles/5_2.unity, Type=UnityEngine.ResourceManagement.ResourceProviders.SceneInstance
not sure why it loaded it fine in the editor but not android, I built & packed them
what does the key show as in the Groups window?
it says exactly what the key is in the exception message (I used a different x/y coord for the screenshot but it does exist)
It also works fine in a Windows build, it only fails on Android
Splitting a bunch of terrains into individual scenes inside addressables so they can be additively loaded also made the APK size grow from 400MB to 2GB...and I already fixed any duplicated assets in the bundles (they were all moved to a separate shared group). That's insane.
400mb when in one scene to 2gb when in separate bundles. Something has to be wrong here
the overhead on addressables/bundles can't be that absurd
yeah just had to do a clean and rebuild, I thought building alone would handle it after fixing the duplicates but guess not.
Loading a scene on WebGL that is 190MB works fine directly from its own project, but when packaging it as an addressable it fails to load after the download completes. It's finished downloading the file since the Network tab in DevTools shows it's done but then it crashes Chrome with the Aw Snap page and doesn't even log any errors or warnings either in the console. How would I even go about debugging it because making a sample and testing the bundle load from another project just shows pink shaders in the Editor since its webgl but I can see in the hierarchy panel, it has loaded all the gameobjects from that large scene and even the editor console window has no errors/warnings. But it fails in the browser for some reason. Any ideas why?
Does Unity intend for you to replace all Instantiate() with InstantiateAsync()? For example, let’s say I am making a 2D top down shooter. Am I supposed to call InstantiateAsync() for every bullet that your gun fires (assuming there is no pooling system)? Or am I supposed to cache the result somehow and only load the asset once, sort of like how you use GetComponent()?
since addressables abstract the resource/asset location, the -async methods allow you to deal with expected and unexpected delays in the aquisition of the asset.... in any case, you should have loaded the asset quite some time before you intend to instantiate it. No point in having a bullet fire "some time in the future".
So the intended way to use addressables in this situation would be to load the bullet prefab (at the start of the game maybe, since it will be required through most of play), cache the result, and then later Instantiate() that cached result when the player fires the gun?
yes
Thank you very much
I need help with addressables.
The apk in my aab file is greater than the 150MB limit on google play, and the total aab size is at 270MB. So I found a plugin that integrates google's play asset delivery with unity's addressables. So after packing all my scenes into different groups and forming addressable assets, each one of the addressable assets was at least 130MB file size, and after building an aab with the plugin, the apk size reduced to 140MB, but the aab went up to 860MB and after I used LZMA compression, it went down to 768MB. What made the file size so large?
Duplicated assets result from assets in different groups sharing dependencies, for example two Prefabs that share a material existing in different Addressable groups. That material (and any of its dependencies) would be pulled into both groups containing the Prefabs.
Thanks for the docs. One more question: My addressable scenes has characters as one of its dependencies, and these characters are prefabs, now will the dependencies of these characters(ie meshes, materials, textures, etc) be marked as addressables too?
I guess my general question is: Almost every assets I have in my Assets folder are dependencies to all my game scenes(i.e they are used in my game scenes), do I have to mark every one of them as an addressable too?
I believe everything referenced by an addressable asset is pulled into the group unless it's already in another group.
I don't do enough with addressables or asset bundles tbh to really know what's the correct setup for you, but I had a setup where we had our scenes in one group, and then assets were grouped into bundles as we saw appropriate, with any asset shared between different groups being added/moved to a group specifically. It's really quite project-specific what your dependencies look like, I've only experienced ones where all that seemed mostly straight forward.
Alright, I'll have to take the trial and error approach. Thanks for responding.
You do not have to mark them as addressable. I have a setup like this, where I am using prefabs inside of those. I am loading the assetreference async and thats the only thing thats in my addressable groups. The rest is standard prefabs that get loaded with the asset anyway. Same as if you reference prefabs directly in a script, they get loaded into memory nevertheless you use them or not.
Hello all!
Lets say that I have a game with levels made of prefabs (like a trackmania level's track parts), would using addressable be the way to go to load the level efficiently or is it overkill?
Depends on the size, but if you are loading a new scene with that level anyway, it would not make much sense to load the scene and then load the addressable level, but if you are swapping in one scene, you might want to use addressables as it is not in memory until you finally load it. Prefabs that are referenced in the inspector will get loaded in memory, nevertheless if you use it or not
I understand! Thank you for your help!
I forgot to give an update, the solution was from this link, just fix the issues in the Fixable Rules and manually mark the assets listed on the issues in theUnfixable Rules as Addressable, and build.
I ended up reducing the aab size to 217MB.
Yes but we still couldn't auto deploy to the appstores from the cloud build. That was the main reason for setting this pipeline up. Sorry for being a slowpoke 😁
Hi, is there a way to get an asset in a Packed Asset Group with an index number instead of a Path?
How would you manage addressables without knowing the path? (too many different path without proper naming convention)
Can anybody recommend a bundle analyzer so we can see the total size of assets included in each bundle? I'm trying to reduce build size and addressables content is not covered by the build log (as far as I can see).
Ah, I found out how to do it. You can enable a build report in addressables preferences. The content is a bit harder to make sense of but I managed to find some egregious assets by search for patterns including MB.
Is there a way to set a default value for an AssetReference. Preferably by asset key?
If anyone was having performance issues with the addressables inspector that seriously interrupted development, the fix was just released
I'm trying to load sprite assets using addressables but I think I'm misunderstanding what a key is. Can I use the shortened paths for keys?
I'm getting an invalid key exception error from the console but I think my keys match the shortened adresses, so i'm not sure what I did wrong.
I'm using Addressables for accessing sprite files at runtime in order to create tiles, these tiles have different themes, but each theme has 12 tiles. With the name and a corrosponding number for a specific tile I am itterating through each possible combination and instantiating tiles.
//here I wait for the sprite to be retrieved
for (int i = 0; i < roomTileCount; i++) {
s = skinName+"_"+i;
AsyncOperationHandle<Sprite> spriteHandle = Addressables.LoadAssetAsync<Sprite>(s);
spriteHandle.Completed += delegate { Sprite_Completed(spriteHandle, ref flag, tileList[i]); };
}
//heres the function, it sets the sprite for the tile once its ready
public void Sprite_Completed(AsyncOperationHandle<Sprite> handle, ref int flag, CostomTile tile)
{
if (handle.Status == AsyncOperationStatus.Succeeded)
{
// Sprite ready for use
tile.sprite = handle.Result;
flag += 1;
Debug.Log("Resource has loaded, flag: "+flag);
}
else
{
Debug.Log("Tile Resource failed to be loaded, flag: "+flag);
}
}
I'm very confused about how to build my addressables. When I do it via API it takes a very long time, but when I do it via the groups window it's almost immediate...
As though it's doing nothing.
I haven't used this method in a long time... Is there something I'm missing?
Oh wait, yes:
Addressable content build failure (duration : 0:00:16.003)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
hm...
I thought that you build the addressables if you are making a build outside the editor
My understanding is that it builds into the Library and then gets copied out when you build your game.
I don't know if it is possible to make a build outside of the editor.
Ah, it was changing platform + preprocessor symbols and hitting a compile error I hadn't noticed.
So I did a little experiment regarding my issue, I hardcoded the path to a single image, the tileset for one of the themes and that worked. I'm not sure why I cant get the tiles to load
I figured this out a while ago, but, I had turned tiles into adressables and tried to use them directly as sprites. I changed the variables to take tiles and grabbed the sprite from there so it works now
Anyone knows why this is happening in my build ? A simple terrain shader is now taking 700mb. And some shaders I have not yet loaded are taking a lot of places. This is in my android build using Addressables
Hello, do someone know if it possible to use addressable at runtime to let a user create a "custom Addressable Assets".
For example: I give the user a "creation mode" who is gonna use assets build in the game, but also assets imported by himself, and I want to let him import and export what he created as a "package".
Is this possible ? Or I should look for another tech ?
Not without Unity editor being involved
So I just found this bit of code, and I guess I'm wondering if my comment is right?
public async Task<EpisodeConfig> LazyLoadEpisodeConfig() {
// Load episode config if it hasn't already been loaded (there must be a
// better way to do this!)
return EpisodeConfigReference.IsValid()
? (EpisodeConfig) EpisodeConfigReference.OperationHandle.Result
: await EpisodeConfigReference.LoadAssetAsync<EpisodeConfig>().Task;
}
EpisodeConfig is an AssetReference
Ok, thank you, I will find something else
What are the extra fields for in the asset reference object?
"_episodeConfigReference": {
"m_AssetGUID": "d32025fdb3e0242278f41d7d075bb062",
"m_SubObjectName": "",
"m_SubObjectType": "",
"m_EditorAssetChanged": false
},
Should I just be serializing the ID?
(This is for a save file)
Hello everyone, I understand that this question could already be asked, but I cannot find the answer to it anywhere.
I want to use remote Addressables that are stored somewhere (on google cloud for example) and at the same time I do not want these addressables to be included in the application build so that they do not take up space.
If I go to the advanced settings of the Addressables group then there is a field "Include In Build". If I make this field false, then when I try to download Addressables, the error "UnityEngine.AddressableAssets.InvalidKeyException" appears, but the file itself was successfully downloaded and cached.
What is the problem?
Reading about Addressables, it sounds like people have had to maintain their own version of TextMesh Pro in order to get it to work properly, due to it using Resources by default. Is this still the case?
I want to start our projects with Addressables, but I would rather not have to fix Unity’s packages just to make it work.
I have an odd situation where sometimes after successfully calling insantiateasync for a prefab from an addressable, I grab the skinnedmeshrenderer component on it inside the Completed callback but the bones array on the SMR is all nulls instead of the actual transforms. and sometimes it isn't nulls. seems like a timing thing but I'd assume the Completed callback wouldn't be called until everything was actually ready to go
You can still include Resources in your build if you're willing to.
What determines the GUID that's given to assets inside a folder that's included in a group? Am I safe to rename them if I'm serializing their asset refs?
This is bothering me a lot
I've changed the path to these assets (and renamed them from {episodeName} to {episodeName}_00 yet the old path is still showing
Okay, awesome. It's using the internal asset IDs. Safe!
Hey
I am facing it difficult to update previous builds. Each time, I update my previous build it goes on to update each and every asset. Not sure why is that the case, as a result a new bundle file is created. Shouldn't it only update the files having changes?
I am currently having big issues with Addressables regarding to shaders memory footprint. The addressables build is building way too many shader variants and can take up to 2gb RAM of shader files only on my android build. Been looking at shader variants stripping and OnPreprocess shader but honestly I am a bit lost. Anyone stumbled upon such issues ?
The bigger my addressables build is, the bigger the same shaders gets. A simple shader can take up to 200mb on some builds. Only happens when I use addressables.
Thank you
Hmmm, my concern is that there are threads on the forums where people have had issues with using Resources and Addressables at the same time, in particular with TextMesh Pro.
Is the only realistic problem with mixing these two systems that you get font related asset duplication, which only increases memory load? Or are there other problems that will require rewriting parts of TMP to fix?
The former I am fine with; font related assets for our projects are not huge, so the extra size isn’t an issue. And as far as I am aware, we will not need to modify the assets at runtime, so the fact they are duplicated shouldn’t cause any issues on its own. But the latter would be a problem.
All I can say is that it's building and running without error. They might be duplicated at runtime, I don't know how to check. I do get some warnings while building related to tmp. One annoying thing I've noticed is that the font asset hold a reference to the ttf, so that ends up being included in your build needlessly.
Alright, thanks, that helps. It’s good to know you haven’t ran into any major issues yet
One problem I have in general with addressables is that we can no longer do CLI builds, but I'm not sure if it's related.
Wait, really? What happens when you try?
I was able to get the Addressables sample projects to build through our automated build scripts, which run Unity from the command line… It seemed to work, but I didn’t stress test it. Although now that I’m thinking of it, I had to remove the nographics option to make it work… Is that related?
The game builds without assets
Or something
Just immediately get errors when it tries to grab assets from the bundle.
Ah, interesting. Could be nographics. We don't have CD set up so I'm doing local builds anyway, I just do them from a menu in Unity now.
What happened before you removed nographics?
Tbh I regret implementing addressables, it's been nothing but pain.
There are so many problems with it. I think next time I'm going to look into writing my own asset bundles builder... Still have no idea how to tell what's bloating our build. The only thing you get is this nasty unparseable log file that I was literally searching for [0-0]{2,}MB to find files that might be unusually large lol.
Also... can't load addressables in edit mode, so any config you have in a bundle becomes untestable...
I'm just venting now, but while I'm at it... why are AssetReferences a class instead of a struct, and they don't implement equality!!! So you compare two references to the object and they return false.
The assets wouldn’t get included properly. I discovered it was caused by the nographics optional by trial and error; I don’t think there were any error messages in the build log or the player log
Nice, that could be it then!
Might be able to go back to my more automated pipeline
Very glad I mentioned something
Also, I just found a solution for loading in editor :-)
public static T LoadInEditor<T>(
this AssetReference assetReference
) where T : UnityEngine.Object {
// https://forum.unity.com/threads/how-to-use-addressable-system-in-editor-script.715163/#post-5678014
var path = AssetDatabase.GUIDToAssetPath(assetReference.RuntimeKey.ToString());
return AssetDatabase.LoadAssetAtPath<T>(path);
}
Nice! Hopefully it fixes the problem
Thanks buddy. :-)
(literally days from release though)
haha
Probably the best time to find out actually...
I’ve been converting our projects to Addressables, and it has definitely been a rough process so far. Getting our scene management system to work again in particular has been difficult. Watching Unity’s Creator Spotlight series has been helping to keep me going, haha… “Those devs managed to get it to work, so it must be possible!”
What made my life a lot easier was using async/await everywhere.
I use this lib https://github.com/Cysharp/UniTask
It's a godsend.
async UniTask<(SceneInstance, Location)> LoadLocationAsync(string locationName) {
DebugUtility.Assert(
_assetManager.HasLocation(locationName),
$"Location '{locationName}' not found"
);
// Load next scene.
var sceneInstance = await _assetManager.LoadLocationAsync(locationName);
// Set loaded scene.
var scene = sceneInstance.Scene;
DebugUtility.AssertEqual(
scene.rootCount, 1,
$"Scene '{locationName}' should have exactly one root"
);
// Get location component.
var location = scene
.GetRootGameObjects()[0]
.GetComponent<Location>();
DebugUtility.AssertNotNull(
location,
$"Scene '{locationName}' root object does not have a {nameof(Location)} component"
);
return (sceneInstance, location);
}
async UniTask UnloadCurrentLocationAsync() {
DebugUtility.AssertNotNull(_currentLocation.location, nameof(_currentLocation));
await _assetManager.UnloadLocationAsync(_currentLocation.sceneInstance);
_currentLocation = default;
}
From AssetManager: it fills the _locations using a label which is set on the scene group.
public async UniTask<SceneInstance> LoadLocationAsync(string locationName) {
var resourceLocation = _locations[locationName];
var sceneInstance = await Addressables.LoadSceneAsync(resourceLocation, LoadSceneMode.Additive).Task;
DebugUtility.Assert(sceneInstance.Scene.IsValid(), $"Invalid scene '{locationName}'");
return sceneInstance;
}
This is good if you want string-based loading, which we do for our use case.
Oh neat, I’ll have to look at that tool. Thanks!
“MonoScript Bundle Name” is Disabled by default, but the tooltip says that the recommended setting is “Project Name”. Is this a mistake?
A value of Disabled was causing missing script warnings. It seems like the default should actually be the recommended value, as that solved the warnings.
How can I get all the sprites from an addressable texture with Sprite mode- multiple enabled?
I tried LoadResourceLocationsAsync but it only returns the texture Asset and the first sprite...
I worked around this by saving a list of addresses for all of the sprites in the texture, but I don't understand why Loading Resource Locations doesn't work...
Getting this helpful message when I try to build addressables:
UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent ()
XXX.BuildScript:RebuildAddressables () (at Assets/XXX/Scripts/Editor/BuildScript.cs:15)
All I can say is "it worked last week"
If I try to rebuild the addressables via the Addressables UI rather than my build script, I get this helpful error instead:
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
I was getting this error with Unity’s Open Project #1. In that case, the load and build paths were not set on one of the Addressable groups. Setting them properly fixed the error
Unity has an example of loading sprites from a texture in multiple mode in the Addressable samples: “Basic/Sprite Land”. It looks like you can call LoadAssetAsync on the texture, with type IList<Sprite> and the completed callback returns a list of all the sprites in the texture.
One thing I noticed while experimenting with the sample though; it does not look like the order of the sprites in that returned list matches the order as displayed in the editor.
😮 it does! Thanks!
is there any good guidance on what not to make addressable?
Grimly, I ended up just deleting my addressables data and reassigning everything. Then it worked. Something probably got corrupted in version control, maybe someone on the team merged something that couldn't be merged.
Think I'll just have to introduce some new Addressables-specific version control hygiene measures
That said, I'll make a note of your solution and try that before I got through the whole reassignment song and dance if this ever happens again, so thanks!
Can someone help?
And on launching the application it goes on to download everything again.
Reading through the Addressables manual, it looks like this is the intended behavior, and Unity is expecting you to break your assets up into smaller bundles based on how they are expected to be updated.
I have no personal experience with this though. So I recommend reading through the manual, in particular the section on ”Distributing Remote Content”
You legend. I can do CLI builds again!
Congrats! 😄 Glad it worked out
when there are duplicate bundle dependencies, what's the best way to figure out what is causing the duplicate dependency?
Hello everyone, I am using Unity Addressables in one of my projects. There are two packed groups that I have created in my project at my end which looks like the image I have shared below.
When I have built the player & uploaded the assets to the amazon s3 service server & used the given url "https://sloticonsasssets.s3.ap-south-1.amazonaws.com/Android", I am am getting a few errors which can be seen in the screenshot attached below. This error occurs only when run on the android platform but runs fine on editor.