Skip to content

Resource Management

高凯 edited this page Nov 21, 2017 · 7 revisions

Resource Management

Framework unified resource management to the Explorer Explorer open: Window -> Package Settings Manager    Click ** "自动添加 Resources 目录下的资源并保存" ** Resources will automatically generate Resources Resources directory under a ResourcesManifest

At the same time will generate a Version file stored in the Resources directory, this file is used to determine the version of the heat update.

** Tip **: Whenever a new file is added to Resources, remember to click the button again

Load resources

All resources are loaded from the ResourceManager class Load resources ** only need name, do not need to pass the path ** So this requires the name of all the files in the project ** Do not repeat **    static string ReadTextFile (string textName) reads a text file and returns its contents

static object Load (string name) Load a resource

static T Load (T) (string name) where T: UnityEngine.Object Load a resource of type T

static void LoadAsync (string name, LoadCallBack callBack) Asynchronously load a resource

static void UnLoad (string name) Uninstalling a resource (only works in Bundle mode)

Example

`` `Csharp void Update () { If (Input.GetKey (KeyCode.A))     {         GameObject cube = (GameObject) ResourceManager.Load ("Cube");

        Instantiate (cube); } } `` `

Bundle loaded

The document is perfect

Hot update

The document is perfect

Clone this wiki locally