Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #90

Open
Mayfly777w opened this issue Nov 29, 2023 · 1 comment

Comments

@Mayfly777w
Copy link

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

@deniskutovskiy
Copy link

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>().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants