Skip to content

Instantly share code, notes, and snippets.

@kou-yeung
Last active April 17, 2020 04:14
Show Gist options
  • Save kou-yeung/2a16190e8da66105a5bddcffa7cf4b10 to your computer and use it in GitHub Desktop.
Save kou-yeung/2a16190e8da66105a5bddcffa7cf4b10 to your computer and use it in GitHub Desktop.
Change Location in Runtime
public static class AddressableAssets
{
/// <summary>
/// replace "BASE_URL"
/// </summary>
static string BaseUrl = "";
public static void Init(string baseUrl)
{
BaseUrl = baseUrl;
}
static string CustomTransform(IResourceLocation location)
{
return location.InternalId.Replace("BASE_URL", BaseUrl);
}
[RuntimeInitializeOnLoadMethod]
static void SetInternalIdTransform()
{
Addressables.InternalIdTransformFunc = CustomTransform;
}
}
public class Sample : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
AddressableAssets.Init("http://localhost:8000");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment