Some facts about Resource folder in Unity3d,
The Resources folder is a special folder which allows you to access assets by file path and name in your scripts, rather than by referencing them in Unity Inspector.
- All the assets of Resources will be included in build generated(even if it is not used in anyway).
- Resources folder would not exist when build is generated, It exists in editor only.
- Multiple resources folder can be used, Unity will examine assets from all the Resource folders. So it is not recommended to use same named asset in two different Resources folder.
- All the assets found in Resources folder will be stored in resources.assets file, when build is generated.
- It can be used to load Textures, Materials, AudioClips etc.
- Prefab can also be instantiated directly form Resource folder as shown below,
GameObject gameObj = Instantiate(Resouces.Load("ObjectName", GameObject));
OR
GameObject gameObj = Instantiate(Resouces.Load<GameObject>("ObjectName"));
OR
GameObject gameObj = Instantiate(Resouces.Load("ObjectName", typeof(GameObject)));
No comments:
Post a Comment