Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Unity remote not updating new values through script

Discussion in 'Unity Remote Config' started by Coloradete, Nov 19, 2020.

  1. Coloradete

    Coloradete

    Joined:
    Sep 23, 2019
    Posts:
    4
    Hello there! I had Unity Remote working but then when I installed Firebase Analytics and Admob it messed up my whole project and had to go back.
    Now the Unity Remote is not correctly fetching the new values I change either from the remote config window or from the dashboard.
    The values inside the scriptable objects (in the script) are always set to some old values, but in the remote config window I see the new ones as soon as I change them from the dashboard if I make a Pull, any thoughts? Thanks!
    Here is my script

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.RemoteConfig;
    5.  
    6. public class RemoteConfigManager : MonoBehaviour
    7. {
    8.     [SerializeField] private SproutParameters sproutParameters;
    9.     [SerializeField] private SuperSproutParameters superSproutParameters;
    10.     [SerializeField] private TankParameters tankParameters;
    11.     [SerializeField] private WaterCharParameters waterCharParameters;
    12.     [SerializeField] private FireCharParameters fireCharParameters;
    13.     [SerializeField] private ShovelCharParameters shovelCharParameters;
    14.     [SerializeField] private GasCharParameters gasCharParameters;
    15.  
    16.     public struct userAttributes { }
    17.     public struct appAttributes { }
    18.  
    19.     public static RemoteConfigManager Instance;
    20.  
    21.     private bool isDeveloping;
    22.     void Awake()
    23.     {
    24.         if (Instance == null)
    25.             Instance = this;
    26.         else
    27.         {
    28.             Destroy(gameObject);
    29.             return;
    30.         }
    31.         DontDestroyOnLoad(gameObject);
    32.         ConfigManager.FetchCompleted += SetRemoteVariables;
    33.         ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    34.     }
    35.  
    36.     public void FetchNewValues(bool developer = false)
    37.     {
    38.         ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    39.         isDeveloping = developer;
    40.     }
    41.  
    42.     private void SetRemoteVariables(ConfigResponse response)
    43.     {
    44.         SetSproutParameters();
    45.         SetSuperSproutParameters();
    46.         SetTankParameters();
    47.         SetWaterCharParameters();
    48.         SetFireCharParameters();
    49.         SetShovelCharParameters();
    50.         SetGasCharParameters();
    51.     }
    52.  
    53.     private void SetSproutParameters()
    54.     {
    55.         sproutParameters.maxHealth = ConfigManager.appConfig.GetFloat("sproutMaxHealth");
    56.         sproutParameters.thrownDistance = ConfigManager.appConfig.GetFloat("sproutThrownDistance");
    57.         sproutParameters.superSproutTimer = ConfigManager.appConfig.GetFloat("superSproutTimer");
    58.         sproutParameters.speed = ConfigManager.appConfig.GetFloat("sproutSpeed");
    59.         sproutParameters.burningSpeed = ConfigManager.appConfig.GetFloat("sproutBurningSpeed");
    60.         sproutParameters.randomMovementTimer = ConfigManager.appConfig.GetFloat("sproutRandomMovementTimer");
    61.         if (isDeveloping)
    62.         {
    63.             foreach (SproutMovement sproutMovement in FindObjectsOfType<SproutMovement>())
    64.             {
    65.                 sproutMovement.LoadNewParameters();
    66.                 sproutMovement.gameObject.GetComponent<SproutStatus>().LoadNewParameters();
    67.             }
    68.         }
    69.     }
    70.  
    71.     private void SetSuperSproutParameters()
    72.     {
    73.         superSproutParameters.walkingSpeed = ConfigManager.appConfig.GetFloat("superSproutWalkingSpeed");
    74.         superSproutParameters.tankHitCooldown = ConfigManager.appConfig.GetFloat("superSproutTankHitCooldown");
    75.         superSproutParameters.maxHealth = ConfigManager.appConfig.GetFloat("superSproutMaxHealth");
    76.         superSproutParameters.gotHitCooldown = ConfigManager.appConfig.GetFloat("superSproutGotHitCooldown");
    77.         superSproutParameters.hitsToPutOffFire = ConfigManager.appConfig.GetInt("superSproutHitsToPutOffFire");
    78.         superSproutParameters.hitsToSetOnFire = ConfigManager.appConfig.GetInt("superSproutHitsToSetOnFire");
    79.         if (isDeveloping && GameManager.superSprout != null)
    80.             FindObjectOfType<SuperSprout>().LoadNewParameters();
    81.     }
    82.  
    83.     private void SetTankParameters()
    84.     {
    85.         tankParameters.maxHealth = ConfigManager.appConfig.GetInt("tankMaxHealth");
    86.         tankParameters.ammoRespawnTime = ConfigManager.appConfig.GetFloat("tankAmmoRespawnTime");
    87.         tankParameters.ammoTravelSpeed = ConfigManager.appConfig.GetFloat("tankAmmoTravelSpeed");
    88.         if (isDeveloping)
    89.             FindObjectOfType<Tank>().LoadNewParameters();
    90.     }
    91.  
    92.     private void SetWaterCharParameters()
    93.     {
    94.         waterCharParameters.shootSproutSpeed = ConfigManager.appConfig.GetFloat("waterCharShootSproutSpeed");
    95.         waterCharParameters.shootWaterSpeed = ConfigManager.appConfig.GetFloat("waterCharShootWaterSpeed");
    96.         waterCharParameters.maxTimeHoldingSprout = ConfigManager.appConfig.GetFloat("waterCharMaxTimeHoldingSprout");
    97.         waterCharParameters.speed = ConfigManager.appConfig.GetFloat("waterCharSpeed");
    98.         waterCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("waterCharSlowDownFactor");
    99.         if (isDeveloping)
    100.             FindObjectOfType<WaterAbility>().LoadNewParameters();
    101.     }
    102.  
    103.     private void SetFireCharParameters()
    104.     {
    105.         fireCharParameters.maxLoads = ConfigManager.appConfig.GetInt("fireCharMaxLoads");
    106.         fireCharParameters.flamesDuration = ConfigManager.appConfig.GetFloat("fireCharFlamesDuration");
    107.         fireCharParameters.speed = ConfigManager.appConfig.GetFloat("fireCharSpeed");
    108.         fireCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("fireCharSlowDownFactor");
    109.         if (isDeveloping)
    110.             FindObjectOfType<FireAbility>().LoadNewParameters();
    111.     }
    112.  
    113.     private void SetShovelCharParameters()
    114.     {
    115.         shovelCharParameters.buryCooldown = ConfigManager.appConfig.GetFloat("shovelCharBuryCooldown");
    116.         shovelCharParameters.throwSproutSpeed = ConfigManager.appConfig.GetFloat("shovelCharThrowSproutSpeed");
    117.         shovelCharParameters.speed = ConfigManager.appConfig.GetFloat("shovelCharSpeed");
    118.         shovelCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("shovelCharSlowDownFactor");
    119.         if (isDeveloping && PlayerManager.isTwoVsTwo)
    120.             FindObjectOfType<ShovelAbility>().LoadNewParameters();
    121.     }
    122.  
    123.     private void SetGasCharParameters()
    124.     {
    125.         gasCharParameters.maxLoads = ConfigManager.appConfig.GetInt("gasCharMaxLoads");
    126.         gasCharParameters.maxNumberOfDrops = ConfigManager.appConfig.GetInt("gasCharMaxNumberOfDrops");
    127.         gasCharParameters.layGasolineCooldown = ConfigManager.appConfig.GetFloat("gasCharLayGasolineCooldown");
    128.         gasCharParameters.betweenDropsCooldown = ConfigManager.appConfig.GetFloat("gasCharBetweenDropsCooldown");
    129.         gasCharParameters.speed = ConfigManager.appConfig.GetFloat("gasCharSpeed");
    130.         gasCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("gasCharSlowDownFactor");
    131.         if (isDeveloping && PlayerManager.isTwoVsTwo)
    132.             FindObjectOfType<GasAbility>().LoadNewParameters();
    133.     }
    134.     private void OnDestroy()
    135.     {
    136.         ConfigManager.FetchCompleted -= SetRemoteVariables;
    137.     }
    138. }
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Same is happening to me right now, and I didn't install any of those.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We identified the issue and rolling out an update.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The issue has been resolved, please try again? We've updated an internal process to avoid another occurrence, sorry for the inconvenience.
     
  6. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Working now:)