Because material reference doesn’t show when getting class defaults. I guess the reason for that is because it’s a direct reference to an object that doesn’t really exist, hence why it’s not exposed as class default.
I did find a way to make it work. I wasn’t loading the assets, I was just reading the assetID and resolving them into a reference. But as the resolver states, when the asset isn’t loaded this resolve returns null. Which also explains why it worked around 70% of the time. Sometimes the assets would be loaded somewhow, sometimes (after editor restart) they wouldn’t. So I used a load asset node in the origin object and now it works. However, I’m still wondering if there is a method that doesn’t involve assetID’s?
Hmm, Ok basically the problem I have with the load asset thing is that I’m loading the asset in the source object. Which is an inventory item. When the actual item is spawned in the world the material instance asset is loaded into memory. Which all works fine. But there is a problem. Imagine a rare inventory item, an item that spawn only once per week for example on a server. A lucky player found this item and equiped it. Server goes down for maintenance, server comes back up. Item is no longer part of the world, hasn’t respawned yet. Lucky player re-connects. Oops, his item isn’t loaded. Why because the item is loaded in the source object, which isn’t part of the world anymore / yet.
Possible solution could be, loading the asset inside of the player when he equips it. But that would mean every item the player equips gets loaded, does this mean that when the player equips similar items who share the same asset get re-loaded into memory everythime he equips it? Or does asset loading work in a way that a particular asset can’t be loaded twice, once it’s loaded, it’s loaded? Or does it actually load it again? These are questions I need answers to, because this is a big deal when it comes to optimization. Loading assets isn’t exactly something I want to have happen every second.