ModuleSettings

class ModuleSettings : ScriptableObject

Base class for project-wide settings objects. Create a subclass to add a single instance to the Project Settings window. Get that instance during runtime by using ModuleSettings.Get<MySettingsType>().

  public class ServerSettings : ModuleSettings
{
  [SerializeField]
  private string _serverUrl;
  public string serverUrl => _serverUrl;

  [SerializeField]
  private GameEvent _onConnectToServer;
  public GameEvent onConnectToServer => _onConnectToServer;
}

Static Methods

T Get<T>()

Returns the ModuleSettings object of the given type T.

  var settings = ModuleSettings.Get<ServerSettings>();

    // and then, for example...
    onConnectToServer.onRaise.AddResponse(SomeResponse);
    ConnectToServer(settings.serverUrl);