Addressables-Sample icon indicating copy to clipboard operation
Addressables-Sample copied to clipboard

In IDE, I can use editorAsset through AssetReference, and there are no errors when loading scripts in IDE or Unity. However, during build, Unity prompts me that AssetReference does not include the definition of editorAsset

Open Mayfly777w opened this issue 2 years ago • 1 comments

In IDE, I can use editorAsset through AssetReference, and there are no errors when loading scripts in IDE or Unity. However, during build, Unity prompts me that AssetReference does not include the definition of editorAsset

error CS1061: 'AssetReference' does not contain a definition for 'editorAsset' and no accessible extension method 'editorAsset' accepting a first argument of type 'AssetReference' could be found (are you missing a using directive or an assembly reference?)

(These words are translated through a translator) W0Q YF1M6 JPV}{$GH@KV_J

Mayfly777w avatar Nov 29 '23 18:11 Mayfly777w

Hi! I know it's been quite a while, but in case you're still looking for the answer, it's pretty simple: the editorAsset property is defined inside the #if UNITY_EDITOR section, so you get this error in runtime on your device, and also in the code copying process when the target is selected by yours. Make sure you are using the API available on your device. In particular, outside of the editor (and in general in any other situation), the preferred way to get an asset would be to call LoadAssetAsync<TObject>().

deniskutovskiy avatar Oct 31 '24 13:10 deniskutovskiy