Unity客户端架构-Resource
来源:互联网 发布:c语言多个随机数 编辑:程序博客网 时间:2024/06/05 08:29
using UnityEngine;using System.Collections;using System.IO;using System;public class Resource { private static Hashtable texts = new Hashtable(); private static Hashtable images = new Hashtable(); private static Hashtable prefabs = new Hashtable(); public static GameObject LoadPrefab(string path) { object obj = Resource.prefabs[path]; if (obj == null) { Resource.prefabs.Remove(path); GameObject gameObject = (GameObject)Resources.LoadAssetAtPath(path, typeof(GameObject)); Resource.prefabs.Add(path, gameObject); return gameObject; } return obj as GameObject; } public static string LoadTextFile(string path, string ext) { object obj = Resource.texts[path]; if (obj == null) { Resource.texts.Remove(path); string text = string.Empty;#if UINTY_EDITOR string pathstr = Util.GetDataDir() + "/StreamingAssets/" + path + ext;#else string pathstr = Util.AppContentDataUri + path + ext;#endif text = File.ReadAllText(pathstr); Resource.texts.Add(pathstr, ext); return text; } return obj as string; } public static Texture2D LoadTexture(string path) { object obj = Resource.images[path]; if(obj == null) { Resource.images.Remove(path); Texture2D texture2D = (Texture2D)Resources.Load(path, typeof(Texture2D)); Resource.images.Add(path,texture2D); return texture2D; } return obj as Texture2D; }}
0 0
- Unity客户端架构-Resource
- Unity客户端架构-Util
- Unity客户端架构-UIContainer
- Unity客户端架构-io
- Unity客户端架构-PanelManager
- Unity客户端架构-DialogManager
- Unity客户端架构-BaseDialog
- Unity客户端架构-DialogInfo
- Unity客户端架构-DialogType
- Unity客户端架构-GlobalGenerator
- Unity客户端架构设计视频教程
- Unity游戏开发Photon Server之客户端架构
- Unity Resource Manager
- unity客户端
- Unity架构??
- Unity Resource文件夹的使用
- 客户端架构
- 客户端架构
- Yii2.0 一个表单
- javascript函数报Uncaught ReferenceError: XXX is not defined
- Ubuntu16.04交叉编译OpenCV并移植
- Android之自定义属性文件
- 第三周项目2-建立“顺序表”算法库
- Unity客户端架构-Resource
- 后台获取多个前台相同的参数值
- Hello, World
- ubuntu 查找软件并且删除
- 第三周项目3-求集合并集
- js学习笔记:基本包装类型——Boolean
- Unity+Vuforia SDKAR开发系列教程--2.1.1 vuforia 4.0 sdk
- 曲率的基本概念 (式子记住!)
- base64编码