Implementing resources outside the resource directory dynamically loaded in Unity3d

Source: Internet
Author: User

You may all know how to implement dynamic loading of resources in Unity3d, that is, to put resources in the resource directory, using the Resources.load method can dynamically load resources. But there is a problem with resources in the resource directory, and that is, when the package is packaged, all the files in the directory will be encrypted and compressed into the package, so that if we want to use the Assetbundle way to play the packet. I've been thinking about this a lot lately, while looking at the API documentation recently, I found a method called Resources.loadassetatpath, which allows you to load resources from any location in the assets directory, but only in editor mode. With this approach, we can load resources using two different policies when testing and publishing: Dynamically loading resources using the Resources.loadassetatpath method in the editor test environment, and loading dynamic resources in a publishing environment using the assetbundle approach.

unity3d--defines the projection matrix of the camera http://www.linuxidc.com/Linux/2013-04/82566.htm

Unity3d the distinction of several default functions http://www.linuxidc.com/Linux/2012-07/66012.htm

Unity3d a script that sets the arrow keys to move and space to jump http://www.linuxidc.com/Linux/2012-07/66011.htm

Unity3d add scripting code to Objects (Gameobject) http://www.linuxidc.com/Linux/2012-07/66010.htm

The following code fragment is posted:

Dynamically loading prefab by Resources.loadatpath method
private void Loadprefabbyresources ()
{
Object prefab = Resources.loadassetatpath ("Assets/prefabs/cube.prefab", typeof (Gameobject));
Gameobject cube = (gameobject) instantiate (prefab);
Cube.transform.parent = transform;
}

At the same time I made a simple example, download the address:

free download address in http://linux.linuxidc.com/

both the username and password are www.linuxidc.com

download Directory in /2014/June/17th/unity3d in the dynamic loading resources outside the resource directory

Download method See http://www.linuxidc.com/Linux/2013-07/87684.htm

PS: The Tools folder in the project directory contains a HFS.exe that is a small tool for simulating HTTP file services locally. With it you can map local files to files that HTTP can access.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.