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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Remote Config Fetch returning zero values.

Discussion in 'Unity Remote Config' started by npcmaniac, Jun 15, 2020.

Thread Status:
Not open for further replies.
  1. npcmaniac

    npcmaniac

    Joined:
    Dec 6, 2015
    Posts:
    2
    I'm using Unity 2019.4.0f1 with remote config 1.0.9
    Environment: development
    I'm setting the values from remote config to a scriptable object.
    When my game starts and remote config data fetch is completed all the values are set to zero.
    It worked yesterday with the same code. but now not working (both editor and android build

    Code:
    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.RemoteConfig;
    3.  
    4. public class RemoteConfigController : MonoBehaviour
    5. {
    6.     public static RemoteConfigController currentRemoteConfigController;
    7.  
    8.     public struct userAttributes
    9.     {
    10.         // Optionally declare variables for any custom user attributes; if none keep an empty struct:
    11.     }
    12.  
    13.     public struct appAttributes
    14.     {
    15.         // Optionally declare variables for any custom app attributes; if none keep an empty struct:
    16.     }
    17.  
    18.     // Optionally declare a unique assignmentId if you need it for tracking:
    19.     [SerializeField] private GameConfigurationData gameConfigSettingsRemote;
    20.  
    21.     void Awake()
    22.     {
    23.         if (currentRemoteConfigController != null && currentRemoteConfigController != this)
    24.         {
    25.             Destroy(currentRemoteConfigController.gameObject);
    26.         }
    27.         currentRemoteConfigController = this;
    28.         DontDestroyOnLoad(currentRemoteConfigController.gameObject);
    29.  
    30.         ConfigManager.FetchCompleted += ApplyRemoteSettings;
    31.         //FetchGameConfigData();
    32.     }
    33.  
    34.     public void FetchGameConfigData()
    35.     {
    36.         ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    37.     }
    38.  
    39.     void ApplyRemoteSettings(ConfigResponse configResponse)
    40.     {
    41.         // Conditionally update settings, depending on the response's origin:
    42.         switch (configResponse.requestOrigin)
    43.         {
    44.             case ConfigOrigin.Default:
    45.                 Debug.Log("No settings loaded this session; using default values.");
    46.                 break;
    47.             case ConfigOrigin.Cached:
    48.                 Debug.Log("No settings loaded this session; using cached values from a previous session.");
    49.                 LoadConfigData();
    50.                 break;
    51.             case ConfigOrigin.Remote:
    52.                 Debug.Log("New settings loaded this session; update values accordingly.");
    53.                 LoadConfigData();
    54.                 break;
    55.         }
    56.     }
    57.  
    58.     void LoadConfigData()
    59.     {
    60.         gameConfigSettingsRemote.enemySpawnDelayMin = ConfigManager.appConfig.GetFloat("enemySpawnDelayMin");
    61.         gameConfigSettingsRemote.enemySpawnDelayMax = ConfigManager.appConfig.GetFloat("enemySpawnDelayMax");
    62.         gameConfigSettingsRemote.enemySpawnDistanceMin = ConfigManager.appConfig.GetFloat("enemySpawnDistanceMin");
    63.         gameConfigSettingsRemote.enemySpawnDistanceMax = ConfigManager.appConfig.GetFloat("enemySpawnDistanceMax");
    64.  
    65.         gameConfigSettingsRemote.enemyCountLevelStart = ConfigManager.appConfig.GetInt("enemyCountLevelStart");
    66.         gameConfigSettingsRemote.enemyCountLevelMax = ConfigManager.appConfig.GetInt("enemyCountLevelMax");
    67.         gameConfigSettingsRemote.enemyCountLevelIncrease = ConfigManager.appConfig.GetInt("enemyCountLevelIncrease");
    68.  
    69.         gameConfigSettingsRemote.enemyLifeLevelStart = ConfigManager.appConfig.GetInt("enemyLifeLevelStart");
    70.         gameConfigSettingsRemote.enemyLifeLevelMax = ConfigManager.appConfig.GetInt("enemyLifeLevelMax");
    71.         gameConfigSettingsRemote.enemyLifeLevelIncrease = ConfigManager.appConfig.GetInt("enemyLifeLevelIncrease");
    72.  
    73.         gameConfigSettingsRemote.enemyLifetimeLevelStart = ConfigManager.appConfig.GetFloat("enemyLifetimeLevelStart");
    74.         gameConfigSettingsRemote.enemyLifetimeLevelMax = ConfigManager.appConfig.GetFloat("enemyLifetimeLevelMax");
    75.         gameConfigSettingsRemote.enemyLifetimeLevelIncrease = ConfigManager.appConfig.GetFloat("enemyLifetimeLevelIncrease");
    76.  
    77.         gameConfigSettingsRemote.enemySpeedLevelStart = ConfigManager.appConfig.GetFloat("enemySpeedLevelStart");
    78.         gameConfigSettingsRemote.enemySpeedLevelMax = ConfigManager.appConfig.GetFloat("enemySpeedLevelMax");
    79.         gameConfigSettingsRemote.enemySpeedLevelIncrease = ConfigManager.appConfig.GetFloat("enemySpeedLevelIncrease");
    80.  
    81.         gameConfigSettingsRemote.enemyTurnSpeedLevelStart = ConfigManager.appConfig.GetFloat("enemyTurnSpeedLevelStart");
    82.         gameConfigSettingsRemote.enemyTurnSpeedLevelMax = ConfigManager.appConfig.GetFloat("enemyTurnSpeedLevelMax");
    83.         gameConfigSettingsRemote.enemyTurnSpeedLevelIncrease = ConfigManager.appConfig.GetFloat("enemyTurnSpeedLevelIncrease");
    84.  
    85.         gameConfigSettingsRemote.enemyDeathVolume = ConfigManager.appConfig.GetFloat("enemyDeathVolume");
    86.  
    87.         gameConfigSettingsRemote.playerSpeed = ConfigManager.appConfig.GetFloat("playerSpeed");
    88.  
    89.         gameConfigSettingsRemote.playerGunLifetime0 = ConfigManager.appConfig.GetFloat("playerGunLifetime0");
    90.         gameConfigSettingsRemote.playerGunLifetime1 = ConfigManager.appConfig.GetFloat("playerGunLifetime1");
    91.         gameConfigSettingsRemote.playerGunLifetime2 = ConfigManager.appConfig.GetFloat("playerGunLifetime2");
    92.  
    93.         gameConfigSettingsRemote.playerGunDamage0 = ConfigManager.appConfig.GetInt("playerGunDamage0");
    94.         gameConfigSettingsRemote.playerGunDamage1 = ConfigManager.appConfig.GetInt("playerGunDamage1");
    95.         gameConfigSettingsRemote.playerGunDamage2 = ConfigManager.appConfig.GetInt("playerGunDamage2");
    96.  
    97.         gameConfigSettingsRemote.playerGunReloadtime0 = ConfigManager.appConfig.GetFloat("playerGunReloadtime0");
    98.         gameConfigSettingsRemote.playerGunReloadtime1 = ConfigManager.appConfig.GetFloat("playerGunReloadtime1");
    99.         gameConfigSettingsRemote.playerGunReloadtime2 = ConfigManager.appConfig.GetFloat("playerGunReloadtime2");
    100.  
    101.         gameConfigSettingsRemote.playerGunRange0 = ConfigManager.appConfig.GetFloat("playerGunRange0");
    102.         gameConfigSettingsRemote.playerGunRange1 = ConfigManager.appConfig.GetFloat("playerGunRange1");
    103.         gameConfigSettingsRemote.playerGunRange2 = ConfigManager.appConfig.GetFloat("playerGunRange2");
    104.  
    105.         gameConfigSettingsRemote.playerShieldVolume = ConfigManager.appConfig.GetFloat("playerShieldVolume");
    106.         gameConfigSettingsRemote.playerAmmoShootVolume = ConfigManager.appConfig.GetFloat("playerAmmoShootVolume");
    107.         gameConfigSettingsRemote.playerAmmoHitVolume = ConfigManager.appConfig.GetFloat("playerAmmoHitVolume");
    108.         gameConfigSettingsRemote.playerFootstepVolume = ConfigManager.appConfig.GetFloat("playerFootstepVolume");
    109.         gameConfigSettingsRemote.playerDeathVolume = ConfigManager.appConfig.GetFloat("playerDeathVolume");
    110.  
    111.         gameConfigSettingsRemote.pickupCountMax = ConfigManager.appConfig.GetInt("pickupCountMax");
    112.  
    113.         gameConfigSettingsRemote.pickupSpawnDelay = ConfigManager.appConfig.GetFloat("pickupSpawnDelay");
    114.         gameConfigSettingsRemote.pickupVolume = ConfigManager.appConfig.GetFloat("pickupVolume");
    115.  
    116.         gameConfigSettingsRemote.gameMusicVolume = ConfigManager.appConfig.GetFloat("gameMusicVolume");
    117.  
    118.         gameConfigSettingsRemote.gameSittingPosePercentage = ConfigManager.appConfig.GetInt("gameSittingPosePercentage");
    119.         gameConfigSettingsRemote.gameLayingPosePercentage = ConfigManager.appConfig.GetInt("gameLayingPosePercentage");
    120.         gameConfigSettingsRemote.gameGroundPosePercentage = ConfigManager.appConfig.GetInt("gameGroundPosePercentage");
    121.  
    122.         gameConfigSettingsRemote.gameLevelChangeDelay = ConfigManager.appConfig.GetFloat("gameLevelChangeDelay");
    123.  
    124.         gameConfigSettingsRemote.gameRewardLevelCount = ConfigManager.appConfig.GetInt("gameRewardLevelCount");
    125.  
    126.         gameConfigSettingsRemote.playerStartingGemsCount = ConfigManager.appConfig.GetInt("playerStartingGemsCount");
    127.         gameConfigSettingsRemote.playerGemsLevelStart = ConfigManager.appConfig.GetInt("playerGemsLevelStart");
    128.         gameConfigSettingsRemote.playerGemsLevelMax = ConfigManager.appConfig.GetInt("playerGemsLevelMax");
    129.         gameConfigSettingsRemote.playerGemsLevelIncrease = ConfigManager.appConfig.GetInt("playerGemsLevelIncrease");
    130.  
    131.         gameConfigSettingsRemote.playerGemPickupLifetime = ConfigManager.appConfig.GetFloat("playerGemPickupLifetime");
    132.  
    133.         gameConfigSettingsRemote.costUpgradeLevel1 = ConfigManager.appConfig.GetInt("costUpgradeLevel1");
    134.         gameConfigSettingsRemote.costUpgradeLevel2 = ConfigManager.appConfig.GetInt("costUpgradeLevel2");
    135.  
    136.         gameConfigSettingsRemote.ammoLifetime = ConfigManager.appConfig.GetFloat("ammoLifetime");
    137.         gameConfigSettingsRemote.ammoVelocity = ConfigManager.appConfig.GetFloat("ammoVelocity");
    138.  
    139.         gameConfigSettingsRemote.assignmentId = ConfigManager.appConfig.assignmentID;
    140.     }
    141.  
    142.     void OnDestroy()
    143.     {
    144.         ConfigManager.FetchCompleted -= ApplyRemoteSettings;
    145.     }
    146. }
    147.  
    build settings.PNG editor.PNG web dashboard.PNG
     
  2. npcmaniac

    npcmaniac

    Joined:
    Dec 6, 2015
    Posts:
    2
    It only happens at the starting of the RemoteConfig Controller. After initialization, when I manually call the fetch function, it works!
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you try with the most recent version? We have addressed similar issues, 1.3.2 looks to be the most recent. Also please provide the output of your Debug.Log statements when you run the game on the Android device, they will show in the logcat logs https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ Perhaps add additional statements to confirm the code flow. Also, I believe I remember reading another forum post elsewhere last week where the user mentioned that the first time they ran a scriptable object in the editor, it didn't initialize correctly on only the first run, but subsequently worked. Please debug to confirm if that applies here, but I suspect not. The device logs would confirm if it's working as expected.
     
  4. tataygames

    tataygames

    Joined:
    Aug 4, 2016
    Posts:
    53

    Hi is there a way to put MyGame(default) values I have created. and put in to release and debug.
    why do I need to create same variables and values to release and debug? I might get wrong spelled and cause error.
    How can I put the values I create on default and put it on debug and release.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please elaborate on your issue, and show a screenshot of your issue. What do you mean "create on default", please show your code and your values as defined in your Remote Config dashboard. Perhaps Copy Config would help you https://forum.unity.com/threads/new-feature-announcement-copy-config-settings.843406/ . I would encourage you to review the posts on this forum in the future
     
  6. tataygames

    tataygames

    Joined:
    Aug 4, 2016
    Posts:
    53
    Its okay now, I just need to figure it out
    This is what I meant
    There is a copy config in the dashboard website but not on the editor.
    What I mean is my variables I created in myGame(default) I can copy and put it on release or debug
     

    Attached Files:

  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I don't quite follow. You can Push/Pull values from the Editor, is this what you mean? Is the Dashboard copy working for you? You stated "What I mean is my variables I created in myGame(default) I can copy and put it on release or debug" , does that it mean it's working for you? There wasn't a question.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    This thread is digressing from the original topic "Returning zero values", so please follow up in a new thread, thanks for understanding
     
Thread Status:
Not open for further replies.