Unity API HOOK 之AssetBundle

Unity API HOOK 之Resources http://www.jianshu.com/p/c7d0330683e5

#if ASSETBUNDLEHOOK

using UnityEngine;
using System;
using Object = UnityEngine.Object;

public class AssetBundle
{
    private UnityEngine.AssetBundle assetBundle;

    public AssetBundle()
    {
        assetBundle = new UnityEngine.AssetBundle();
    }

    public AssetBundle(UnityEngine.AssetBundle assetBundle)
    {
        this.assetBundle = assetBundle;
    }

    public static implicit operator AssetBundle(UnityEngine.AssetBundle assetBundle)
    {
        return new AssetBundle(assetBundle);
    }

    public static implicit operator bool (AssetBundle exists)
    {
        return exists != null;
    }

    public bool isStreamedSceneAssetBundle
    {
        get
        {
            return assetBundle.isStreamedSceneAssetBundle;
        }
    }

    public Object mainAsset
    {
        get
        {
            return assetBundle.mainAsset;
        }
    }

    public static UnityEngine.AssetBundle LoadFromFile(string path)
    {
        return UnityEngine.AssetBundle.LoadFromFile(path);
    }

    public static UnityEngine.AssetBundle LoadFromFile(string path, uint crc)
    {
        return UnityEngine.AssetBundle.LoadFromFile(path, crc);
    }

    public static UnityEngine.AssetBundle LoadFromFile(string path, uint crc, ulong offset)
    {
        return UnityEngine.AssetBundle.LoadFromFile(path, crc, offset);
    }

    public static AssetBundleCreateRequest LoadFromFileAsync(string path)
    {
        return UnityEngine.AssetBundle.LoadFromFileAsync(path);
    }

    public static AssetBundleCreateRequest LoadFromFileAsync(string path, uint crc)
    {
        return UnityEngine.AssetBundle.LoadFromFileAsync(path, crc);
    }

    public static AssetBundleCreateRequest LoadFromFileAsync(string path, uint crc, ulong offset)
    {
        return UnityEngine.AssetBundle.LoadFromFileAsync(path, crc, offset);
    }

    public static UnityEngine.AssetBundle LoadFromMemory(byte[] binary)
    {
        return UnityEngine.AssetBundle.LoadFromMemory(binary);
    }

    public static UnityEngine.AssetBundle LoadFromMemory(byte[] binary, uint crc)
    {
        return UnityEngine.AssetBundle.LoadFromMemory(binary, crc);
    }

    public static AssetBundleCreateRequest LoadFromMemoryAsync(byte[] binary)
    {
        return UnityEngine.AssetBundle.LoadFromMemoryAsync(binary);
    }

    public static AssetBundleCreateRequest LoadFromMemoryAsync(byte[] binary, uint crc)
    {
        return UnityEngine.AssetBundle.LoadFromMemoryAsync(binary, crc);
    }

    public string[] AllAssetNames()
    {
        return assetBundle.AllAssetNames();
    }

    public bool Contains(string name)
    {
        return assetBundle.Contains(name);
    }

    public string[] GetAllAssetNames()
    {
        return assetBundle.GetAllAssetNames();
    }

    public string[] GetAllScenePaths()
    {
        return assetBundle.GetAllScenePaths();
    }

    public Object[] LoadAllAssets()
    {
        return assetBundle.LoadAllAssets();
    }

    public Object[] LoadAllAssets(Type type)
    {
        return assetBundle.LoadAllAssets(type);
    }

    public T[] LoadAllAssets() where T : Object
    {
        return assetBundle.LoadAllAssets();
    }

    public AssetBundleRequest LoadAllAssetsAsync()
    {
        return assetBundle.LoadAllAssetsAsync();
    }

    public AssetBundleRequest LoadAllAssetsAsync(Type type)
    {
        return assetBundle.LoadAllAssetsAsync(type);
    }

    public AssetBundleRequest LoadAllAssetsAsync()
    {
        return assetBundle.LoadAllAssetsAsync();
    }

    public Object LoadAsset(string name)
    {
        return assetBundle.LoadAsset(name);
    }

    public Object LoadAsset(string name, Type type)
    {
        if (type == typeof(AudioClip))
        {
            var id = AudioMapping.GetId(name);
            if (id != "")
            {
                name = "Audios/en/" + id;

                return UnityEngine.Resources.Load(name, type);
            }
        }

        return assetBundle.LoadAsset(name, type);
    }

    public T LoadAsset(string name) where T : Object
    {
        return LoadAsset(name, typeof(T)) as T;
    }

    public AssetBundleRequest LoadAssetAsync(string name)
    {
        return assetBundle.LoadAssetAsync(name);
    }

    public AssetBundleRequest LoadAssetAsync(string name, Type type)
    {
        return assetBundle.LoadAssetAsync(name, type);
    }

    public AssetBundleRequest LoadAssetAsync(string name)
    {
        return assetBundle.LoadAssetAsync(name);
    }

    public Object[] LoadAssetWithSubAssets(string name)
    {
        return assetBundle.LoadAssetWithSubAssets(name);
    }

    public Object[] LoadAssetWithSubAssets(string name, Type type)
    {
        return assetBundle.LoadAssetWithSubAssets(name, type);
    }

    public T[] LoadAssetWithSubAssets(string name) where T : Object
    {
        return assetBundle.LoadAssetWithSubAssets(name);
    }

    public AssetBundleRequest LoadAssetWithSubAssetsAsync(string name)
    {
        return assetBundle.LoadAssetWithSubAssetsAsync(name);
    }

    public AssetBundleRequest LoadAssetWithSubAssetsAsync(string name, Type type)
    {
        return assetBundle.LoadAssetWithSubAssetsAsync(name, type);
    }

    public AssetBundleRequest LoadAssetWithSubAssetsAsync(string name)
    {
        return assetBundle.LoadAssetWithSubAssetsAsync(name);
    }

    public void Unload(bool unloadAllLoadedObjects)
    {
        assetBundle.Unload(unloadAllLoadedObjects);
    }
}

#endif

你可能感兴趣的:(Unity API HOOK 之AssetBundle)