コード例 #1
0
        public void Load()
        {
            Debug.Log("Loading game settings...");

            // if we're loading over an existing settings object we want to deregister the old one
            if (Settings != null)
            {
                SettingsBindBroker.DeregisterData(Settings);
            }

            // check to see if the settings file exists
            if (File.Exists(SettingsPath))
            {
                Settings = _serializer.Deserialize <GameSettings>(SettingsPath);
            }
            else
            {
                // create the default settings
                Debug.Log("Settings.json not found, creating default settings");
                Settings = new GameSettings();
                Save();
            }

            // register the new settings object
            SettingsBindBroker.RegisterData(Settings);
        }
コード例 #2
0
        // Use this for initialization
        void Start()
        {
            // create and register the BindBroker
            _broker = new BindBroker();
            _broker.RegisterData(GameSettings.CurrentSettings);
            GUID = Guid.NewGuid();

            // set the FOV to the current value from game settings
            FOV = GameSettings.CurrentSettings.FOV;

            // bind the settings FOV value to the Camera FOV, so we get updates
            _broker.Bind(() => GameSettings.CurrentSettings.FOV, () => FOV, BindingType.OneWay);
        }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        GUID = Guid.NewGuid();

        Slider1.onValueChanged.AddListener((f) => { NotifyPropertyChange(nameof(Slider1Value)); });
        Slider2.onValueChanged.AddListener((f) => { NotifyPropertyChange(nameof(Slider2Value)); });

        bindBroker = new BindBroker();
        bindBroker.RegisterData(this);

        bindBroker.Bind(() => PlayerHealth, () => HealthBarFillAmount, BindingType.OneWay);
        bindBroker.Bind(() => PlayerHealth, () => HealthBarTextText, BindingType.OneWay);

        bindBroker.Bind(() => Slider1Value, () => Slider2Value, BindingType.TwoWay);
        bindBroker.Bind(() => Slider2Value, () => Slider2TextText, BindingType.OneWay);
    }