Liu Hao
Liu Hao

Reputation: 512

Do I need to include .meta file when build unity assetbundle?

In editor, the meta file records reference with other asset, so I think when build assetbundle, I need to include the .meta file also, so at runtime the asset will find the reference with each other.

But according to this link https://answers.unity.com/questions/910422/assetbundleloadmainassetatpath-not-loading-meta-fi.html , the answer said there is no need for it, I'm confused about that

Upvotes: 0

Views: 1769

Answers (2)

FastFwd
FastFwd

Reputation: 1

Unity's .meta files contain two important pieces of information:

  • The GUID that Unity uses to track any references to the Asset.
  • The settings for the Asset that you see in the Inspector window.

Hence, if you don't include them you risk breaking references and losing Asset settings.

This article on my blog explains meta files and GUIDs in more detail.

Upvotes: 0

CausticLasagne
CausticLasagne

Reputation: 219

From what I know, Unity uses these .meta files in the editor only. I'm pretty sure that the asset bundle contains data that tells it what files do what. The guy at the link you've posted seems to be pulling .meta files from the asset bundle and I don't think this is the correct way to do this, since you are basically doing it in the reverse of what unity was designed for. Try finding only the assets you are looking for, not the meta files. Also you should not have to manually include .meta files in your asset bundle, unity should do this automatically. And one last thing, Use unity's built in functions for accessing asset bundles rather than System.IO, since the system does not know what an asset bundle is, only unity does. Once the files are extracted onto your drive, then use System.IO on them.

Good luck.

Upvotes: 2

Related Questions