@unity_bill There’s an error on the Asset property of the script that makes it throw an error when you try to access the property to check if something is loaded.
Using the following simple code to illustrate the problem:
[SerializeField]
AssetReferenceGameObject reference;
public void LoadAsset()
{
if (reference.Asset == null)
{
reference.LoadAsset();
}
}
As you can see nothing special is happening here, it just checks if an asset has been loaded before trying to load it. This will throw the following error:
Exception: Attempting to use an invalid operation handle
AsyncOperationHandle.get_InternalOp () (at Library/PackageCache/com.unity.addressables@0.7.4-preview/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:208)
AsyncOperationHandle.get_Result () (at Library/PackageCache/com.unity.addressables@0.7.4-preview/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:273)
UnityEngine.AddressableAssets.AssetReference.get_Asset () (at Library/PackageCache/com.unity.addressables@0.7.4-preview/Runtime/AssetReference.cs:157)
...
Which makes perfect sense since the m_operation field on the script is only valid when it loads something. So if the property in the AssetReference.cs is changed to:
public Object Asset
{
get
{
if (!m_operation.IsValid())
return null;
return m_operation.Result as Object;
}
}
It works without any problems since it will be returning a null value. I’m not sure if I should report this with the bug report tool since it’s not an engine error.