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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.RemoteConfig;
public class RemoteConfigManager : MonoBehaviour
{
[SerializeField] private SproutParameters sproutParameters;
[SerializeField] private SuperSproutParameters superSproutParameters;
[SerializeField] private TankParameters tankParameters;
[SerializeField] private WaterCharParameters waterCharParameters;
[SerializeField] private FireCharParameters fireCharParameters;
[SerializeField] private ShovelCharParameters shovelCharParameters;
[SerializeField] private GasCharParameters gasCharParameters;
public struct userAttributes { }
public struct appAttributes { }
public static RemoteConfigManager Instance;
private bool isDeveloping;
void Awake()
{
if (Instance == null)
Instance = this;
else
{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
ConfigManager.FetchCompleted += SetRemoteVariables;
ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
}
public void FetchNewValues(bool developer = false)
{
ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
isDeveloping = developer;
}
private void SetRemoteVariables(ConfigResponse response)
{
SetSproutParameters();
SetSuperSproutParameters();
SetTankParameters();
SetWaterCharParameters();
SetFireCharParameters();
SetShovelCharParameters();
SetGasCharParameters();
}
private void SetSproutParameters()
{
sproutParameters.maxHealth = ConfigManager.appConfig.GetFloat("sproutMaxHealth");
sproutParameters.thrownDistance = ConfigManager.appConfig.GetFloat("sproutThrownDistance");
sproutParameters.superSproutTimer = ConfigManager.appConfig.GetFloat("superSproutTimer");
sproutParameters.speed = ConfigManager.appConfig.GetFloat("sproutSpeed");
sproutParameters.burningSpeed = ConfigManager.appConfig.GetFloat("sproutBurningSpeed");
sproutParameters.randomMovementTimer = ConfigManager.appConfig.GetFloat("sproutRandomMovementTimer");
if (isDeveloping)
{
foreach (SproutMovement sproutMovement in FindObjectsOfType<SproutMovement>())
{
sproutMovement.LoadNewParameters();
sproutMovement.gameObject.GetComponent<SproutStatus>().LoadNewParameters();
}
}
}
private void SetSuperSproutParameters()
{
superSproutParameters.walkingSpeed = ConfigManager.appConfig.GetFloat("superSproutWalkingSpeed");
superSproutParameters.tankHitCooldown = ConfigManager.appConfig.GetFloat("superSproutTankHitCooldown");
superSproutParameters.maxHealth = ConfigManager.appConfig.GetFloat("superSproutMaxHealth");
superSproutParameters.gotHitCooldown = ConfigManager.appConfig.GetFloat("superSproutGotHitCooldown");
superSproutParameters.hitsToPutOffFire = ConfigManager.appConfig.GetInt("superSproutHitsToPutOffFire");
superSproutParameters.hitsToSetOnFire = ConfigManager.appConfig.GetInt("superSproutHitsToSetOnFire");
if (isDeveloping && GameManager.superSprout != null)
FindObjectOfType<SuperSprout>().LoadNewParameters();
}
private void SetTankParameters()
{
tankParameters.maxHealth = ConfigManager.appConfig.GetInt("tankMaxHealth");
tankParameters.ammoRespawnTime = ConfigManager.appConfig.GetFloat("tankAmmoRespawnTime");
tankParameters.ammoTravelSpeed = ConfigManager.appConfig.GetFloat("tankAmmoTravelSpeed");
if (isDeveloping)
FindObjectOfType<Tank>().LoadNewParameters();
}
private void SetWaterCharParameters()
{
waterCharParameters.shootSproutSpeed = ConfigManager.appConfig.GetFloat("waterCharShootSproutSpeed");
waterCharParameters.shootWaterSpeed = ConfigManager.appConfig.GetFloat("waterCharShootWaterSpeed");
waterCharParameters.maxTimeHoldingSprout = ConfigManager.appConfig.GetFloat("waterCharMaxTimeHoldingSprout");
waterCharParameters.speed = ConfigManager.appConfig.GetFloat("waterCharSpeed");
waterCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("waterCharSlowDownFactor");
if (isDeveloping)
FindObjectOfType<WaterAbility>().LoadNewParameters();
}
private void SetFireCharParameters()
{
fireCharParameters.maxLoads = ConfigManager.appConfig.GetInt("fireCharMaxLoads");
fireCharParameters.flamesDuration = ConfigManager.appConfig.GetFloat("fireCharFlamesDuration");
fireCharParameters.speed = ConfigManager.appConfig.GetFloat("fireCharSpeed");
fireCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("fireCharSlowDownFactor");
if (isDeveloping)
FindObjectOfType<FireAbility>().LoadNewParameters();
}
private void SetShovelCharParameters()
{
shovelCharParameters.buryCooldown = ConfigManager.appConfig.GetFloat("shovelCharBuryCooldown");
shovelCharParameters.throwSproutSpeed = ConfigManager.appConfig.GetFloat("shovelCharThrowSproutSpeed");
shovelCharParameters.speed = ConfigManager.appConfig.GetFloat("shovelCharSpeed");
shovelCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("shovelCharSlowDownFactor");
if (isDeveloping && PlayerManager.isTwoVsTwo)
FindObjectOfType<ShovelAbility>().LoadNewParameters();
}
private void SetGasCharParameters()
{
gasCharParameters.maxLoads = ConfigManager.appConfig.GetInt("gasCharMaxLoads");
gasCharParameters.maxNumberOfDrops = ConfigManager.appConfig.GetInt("gasCharMaxNumberOfDrops");
gasCharParameters.layGasolineCooldown = ConfigManager.appConfig.GetFloat("gasCharLayGasolineCooldown");
gasCharParameters.betweenDropsCooldown = ConfigManager.appConfig.GetFloat("gasCharBetweenDropsCooldown");
gasCharParameters.speed = ConfigManager.appConfig.GetFloat("gasCharSpeed");
gasCharParameters.slowDownFactor = ConfigManager.appConfig.GetFloat("gasCharSlowDownFactor");
if (isDeveloping && PlayerManager.isTwoVsTwo)
FindObjectOfType<GasAbility>().LoadNewParameters();
}
private void OnDestroy()
{
ConfigManager.FetchCompleted -= SetRemoteVariables;
}
}