ResKit 模块简介:

加载 Resources 目录下的资源

  1. // allocate a loader when initialize a panel or a monobehavour
  2. var loader = ResLoader.Allocate();
  3. // load someth in a panel or a monobehaviour
  4. var smobjPrefab = loader.LoadSync<GameObject>("Resources/smobj");
  5. var bgTexture = loader.LoadSync<Texture2D>("Resources/Bg");
  6. var gameObjPrefab = loader.LoadSync("Resources/gameObj") as GameObject;
  7. // resycle this panel/monobehaivour loaded res when destroyed
  8. loader.Recycle2Cache();
  9. loader = null;

加载网络资源

加载 AssetBundle 资源

准备

  • 鼠标右键某个资源 Assets/ResKit/Mark AssetBundle
  • Command/Ctrl + Shift + R 弹出资源面板,点击 build

加载代码

  1. // init res mgr before load asset bundle
  2. ResMgr.Init();
  3. // allocate a loader when initialize a panel or a monobehavour
  4. var loader = ResLoader.Allocate<ResLoader>();
  5. // load someth in a panel or a monobehaviour
  6. var smObjPrefab = loader.LoadSync<GameObject>("smObj");
  7. var bgTexture = loader.LoadSync<Texture2D>("Bg");
  8. var logoTexture = loader.LoadSync<Texture2D>("hometextures","logo");
  9. // resycle this panel/monobehaivour loaded res when destroyed
  10. loader.Recycle2Cache();
  11. loader = null;