Beispiel #1
0
    private void setButtonOff()
    {
        backboard.GetComponent <Renderer>().material = offMaterial;

        SettingsVariables.toggleFeature(feature, false);
        buttonOn = false;
    }
Beispiel #2
0
    private void setButtonOn()
    {
        backboard.GetComponent <Renderer>().material = onMaterial;

        SettingsVariables.toggleFeature(feature, true);
        buttonOn = true;
    }
Beispiel #3
0
        /// <summary>
        /// Set instance for settings object and initialize callbacks of UI
        /// </summary>
        private void Awake()
        {
            // Check singleton, each time the menu scene is loaded, the instance is replaced with the newest script
            if (instance == null)
            {
                instance = this;
            }
            else
            {
                // Update Settings Manager when loading a new scene
                Destroy(instance.gameObject);
                instance = this;
            }

            // New Settings object
            settingsPath = Application.streamingAssetsPath + "/" + filename;
            settings     = new SettingsVariables();

            // Create directory
            if (!Directory.Exists(Application.streamingAssetsPath))
            {
                Debug.LogError("StreamingAssets folder did not exist, it was created in the first run. Please stop and play your game again");
                Directory.CreateDirectory(Application.streamingAssetsPath);
            }
        }
Beispiel #4
0
    protected override void Start()
    {
        base.Start();

        backboard = transform;
        slider    = transform.parent.Find("Slider");
        ColorUtility.TryParseHtmlString("#343836FF", out onColor);
        onColor.a = 1;
        ColorUtility.TryParseHtmlString("#343836FF", out offColor);
        offColor.a = 0;

        onPos  = new Vector3(0.21f, slider.localPosition.y, slider.localPosition.z);
        offPos = new Vector3(-0.21f, slider.localPosition.y, slider.localPosition.z);

        if (SettingsVariables.getState(feature))
        {
            setButtonOn();
            slider.localPosition = onPos;
        }
        else
        {
            setButtonOff();
            slider.localPosition = offPos;
        }
    }
Beispiel #5
0
        /// <summary>
        /// Load settings from the hard-drive
        /// </summary>
        public void LoadSettings()
        {
            if (File.Exists(settingsPath))
            {
                settings = JsonUtility.FromJson <SettingsVariables>(File.ReadAllText(settingsPath));

                if (!useSettingsWithoutUI)
                {
                    UpdateUI();
                }
            }
            else
            {
                // If the settings file does not exist, create one with default values and read from it.
                SaveSettings(true);
                LoadSettings();
            }
        }