Remote Settings

Remote settings looks very interesting. How does Remote Settings Component with scriptable objects? That’s what I use to store enemy stats and other game settings.

Using ScriptableObjects directly with the component isn’t currently supported. You could create a MonoBehaviour with properties that set your ScriptableObject fields (as described here: https://docs.unity3d.com/Manual/UnityAnalyticsRemoteSettingsComponent.html).

Or, it might be easier to add a function to handle the RemoteSettings. Updated event to your scriptable objects:

    using UnityEngine;

    public class ScriptableThing : ScriptableObject {

        public float DefaultSpawnRateFactor = 1.0f;
        public float DefaultEnemySpeedFactor = 1.0f;
        public float DefaultEnemyStrengthFactor = 1.0f;

        public static float SpawnRateFactor{ get; private set; }
        public static float EnemySpeedFactor{ get; private set; }
        public static float EnemyStrengthFactor{ get; private set; }

        void Awake () {
            SpawnRateFactor = DefaultSpawnRateFactor;
            EnemySpeedFactor = DefaultEnemySpeedFactor;
            EnemyStrengthFactor = DefaultEnemyStrengthFactor;

            RemoteSettings.Updated +=
                new RemoteSettings.UpdatedEventHandler(HandleRemoteUpdate);
        }

        private void HandleRemoteUpdate(){
            SpawnRateFactor
            = RemoteSettings.GetFloat ("SpawnRateFactor", DefaultSpawnRateFactor);
            EnemySpeedFactor
            = RemoteSettings.GetFloat ("EnemySpeedFactor", DefaultEnemySpeedFactor);
            EnemyStrengthFactor
            = RemoteSettings.GetFloat ("EnemyStrengthFactor", DefaultEnemyStrengthFactor);

            Debug.Log("Update settings");
        }
    }

This is essentially the same technique described here, but for ScriptableObjects: https://docs.unity3d.com/Manual/UnityAnalyticsRemoteSettingsScripting.html

2 Likes