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