public static byte[] LoadDll(string assetPath) { //Debug.Log("加载dll: " + assetPath); var asset = Assets.LoadAsset(assetPath, typeof(UnityEngine.Object)); var ta = (TextAsset)asset.asset; return(ta.bytes); }
public AssetRequest LoadAsset <T>(string assetPath) where T : UnityEngine.Object { AssetRequest request; if (assets.TryGetValue(assetPath, out request)) { request = Assets.LoadAsset(assetPath, typeof(T)); assets.Add(assetPath, request); } return(request); }
public static AssetRequest LoadSprite(string assetPath) { var asset = Assets.LoadAsset(assetPath, typeof(Sprite)); return(asset); }
private void OnGUI() { if (state == State.Completed) { using (var v = new GUILayout.VerticalScope("AssetsUpdate Demo", "window")) { GUILayout.Label(string.Format("{0}:{1}", state, message)); if (GUILayout.Button("Clear")) { Clear(); } GUILayout.Label("AllBundleAssets:"); var assets = Assets.GetAllBundleAssetPaths(); foreach (var item in assets) { if (GUILayout.Button(item)) { assetPath = item; } } using (var h = new GUILayout.HorizontalScope()) { assetPath = GUILayout.TextField(assetPath, GUILayout.Width(256)); if (GUILayout.Button("Load")) { var asset = Assets.LoadAsset(assetPath, typeof(UnityEngine.Object)); asset.completed += OnAssetLoaded; } if (GUILayout.Button("LoadAsync")) { var asset = Assets.LoadAssetAsync(assetPath, typeof(UnityEngine.Object)); asset.completed += OnAssetLoaded; } if (GUILayout.Button("LoadScene")) { var asset = Assets.LoadSceneAsync(assetPath, true); asset.completed += OnAssetLoaded; } } if (loadedAssets.Count > 0) { if (GUILayout.Button("UnloadAll")) { for (int i = 0; i < loadedAssets.Count; i++) { var item = loadedAssets[i]; item.Release(); } loadedAssets.Clear(); } for (int i = 0; i < loadedAssets.Count; i++) { var item = loadedAssets[i]; using (var h = new GUILayout.HorizontalScope()) { GUILayout.Label(item.url); if (GUILayout.Button("Unload")) { item.Release(); loadedAssets.RemoveAt(i); i--; } } } } } } }