Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Remote Config returns Key from wrong Environment.

Discussion in 'Unity Remote Config' started by lemonLimeBitta, Jun 3, 2023.

  1. lemonLimeBitta

    lemonLimeBitta

    Joined:
    Aug 28, 2014
    Posts:
    4
    Hi all!

    I had a search but couldn't see if anyone had encountered this before, sorry if I didn't search hard enough.

    My problem is I have two environments for Remote Config on UGS, 'test' and 'production'. I am setting the environment id in my project based off if you're in the editor or on a build like this.
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.             string environmentId = "test";
    3. #else
    4.             string environmentId = "production";
    5. #endif
    I then go onto set the environment ID in my initialisation, as shown here:
    Code (CSharp):
    1.             RemoteConfigService.Instance.FetchCompleted += ApplyRemoteSettings;
    2.             RemoteConfigService.Instance.SetEnvironmentID(environmentId);
    3.             Debug.Log("Env ID: " + environmentId);
    (notice that I'm logging the environment id, this prints as 'test' in the console).

    I later fetch one of my keys and log it to the console.
    Code (CSharp):
    1.         string fetchedContext = RemoteConfigService.Instance.appConfig.GetString("AIContext");
    2.         Debug.Log("Env ID: " + environmentId);
    Here are my two environments
    Prod
    upload_2023-6-3_13-13-18.png
    Test
    upload_2023-6-3_13-14-17.png

    and here is the console, showing that it's fetching the string from the prod env...
    upload_2023-6-3_13-15-33.png

    Any help would be appreciated. I have tried reloading the unity editor as I thought maybe it was cached, but as it's printing the correct environmentID I don't think it's that.

    Cheers,

    Damo
     
  2. lemonLimeBitta

    lemonLimeBitta

    Joined:
    Aug 28, 2014
    Posts:
    4
    I worked it out while waiting for moderation :D

    Turns out you can't use an Environments 'name' you have to use it's ID! silly me.

    Here's a photo of what I mean for anyone that finds this thread in the future.

    upload_2023-6-5_11-4-10.png
    and find these IDs on the dashboard
    upload_2023-6-5_11-4-48.png

    Mods you can mark this as answered now if you like!
     
    SebT_Unity likes this.