Example #1
0
    public void SetAddressableRemoteResCdnUrl(string cdnUrl)
    {
        Debug.Log("SetAddressableRemoteResCdnUrl cdnUrl = " + cdnUrl);
        if (string.IsNullOrEmpty(cdnUrl))
        {
            return;
        }

        this.remote_res_cdn_url = cdnUrl;

        //设置catalog的请求路径
        string newLocation = cdnUrl + "/" + "catalog_1.hash";

        Addressables.SetRemoteCatalogLocation(newLocation);

        //设置location的transfrom func
        Addressables.InternalIdTransformFunc = (IResourceLocation location) =>
        {
            string internalId = location.InternalId;
            if (internalId != null && internalId.StartsWith("http"))
            {
                var    fileName      = Path.GetFileName(internalId);
                string newInternalId = cdnUrl + "/" + fileName;
                // Debug.Log("InternalIdTransformFunc  " + newInternalId);
                return(newInternalId);
            }
            else
            {
                return(location.InternalId);
            }
        };
    }