コード例 #1
0
        static AssetBundle MM_Detour(byte[] binary, uint crc)
        {
            AssetBundle result;

            var parameters = new AssetBundleLoadingParameters(binary, null, crc, 0, AssetBundleLoadType.LoadFromMemory);
            var context    = ResourceRedirection.Hook_AssetBundleLoading_Prefix(parameters, out result);

            var p = context.Parameters;

            if (!context.SkipOriginalCall)
            {
                result = _original(p.Binary, p.Crc);
            }

            if (!context.SkipAllPostfixes)
            {
                ResourceRedirection.Hook_AssetBundleLoaded_Postfix(parameters, ref result);
            }

            if (result != null && p.Path != null) // should only be null if loaded through non-hooked methods
            {
                var ext = result.GetOrCreateExtensionData <AssetBundleExtensionData>();
                ext.Path = p.Path;
            }

            return(result);
        }
コード例 #2
0
        static AssetBundle MM_Detour(AssetBundleCreateRequest self)
        {
            if (ResourceRedirection.TryGetAssetBundle(self, out var info))
            {
                AssetBundle bundle;

                if (info.ResolveType == AsyncAssetBundleLoadingResolve.ThroughBundle)
                {
                    bundle = info.Bundle;
                }
                else
                {
                    bundle = _original(self);
                }

                if (!info.SkipAllPostfixes)
                {
                    ResourceRedirection.Hook_AssetBundleLoaded_Postfix(info.Parameters, ref bundle);
                }

                if (bundle != null && info != null) // should only be null if loaded through non-hooked methods
                {
                    var path = info.Parameters.Path;
                    if (path != null)
                    {
                        var ext = bundle.GetOrCreateExtensionData <AssetBundleExtensionData>();
                        ext.Path = path;
                    }
                }

                return(bundle);
            }
            else
            {
                return(_original(self));
            }
        }