Hello i'm trying to set a custom option in the menu so the player can choose if he uses basic unitorm hours or real time hour but each time i click or press the accept button on the boolean it works and then the value goes automatically to false and when i load the game the variable isn't saved, here is my script :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ORKFramework;

public class ORKEnableRealTime : MonoBehaviour {

public UniStormSystem uS;
// Use this for initialization
void Start () {
//DontDestroyOnLoad (this.gameObject);
uS = GameObject.Find ("UniStorm System").GetComponent<UniStormSystem> ();
}

// Update is called once per frame
public void Update () {
//ORK.Game.Variables.GetBool("useRealTime");
if (ORK.Game.Variables.Check ("useRealTime", true)) {
uS.RealWorldTime = UniStormSystem.EnableFeature.Enabled;
//ORK.Game.Variables.Set ("useRealTime", true);
}


if (ORK.Game.Variables.Check ("useRealTime", false)) {
uS.RealWorldTime = UniStormSystem.EnableFeature.Disabled;

}
}

}

  • When is the variable set?
    Starting a new game will reset variables and loading a game will reset it to the saved variables.

    E.g. having that setting in the main menu would result in the setting being reset when starting a new game or loading a game.

    You could use PlayerPrefs as an alternative - ORK 2.17.0 introduced an option to use them in option menus instead of game variables.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.