Example #1
0
 /// <summary>
 ///   Deinitializes the data binding, e.g. unregistering from events.
 /// </summary>
 public void Deinit()
 {
     if (this.Provider != null)
     {
         this.Provider.ValueChanged -= this.OnTargetValueChanged;
     }
     if (this.contextNode != null)
     {
         this.contextNode.SetValueListener(null);
         this.contextNode = null;
     }
 }
Example #2
0
        /// <summary>
        ///   Initializes the data binding, depending on the type of data binding.
        /// </summary>
        /// <param name="gameObject">Game object this data binding belongs to.</param>
        public void Init(GameObject gameObject)
        {
            switch (this.Type)
            {
            case DataBindingType.Context:
            {
                this.contextNode = new ContextNode(gameObject, this.Path);
                var initialValue = this.contextNode.SetValueListener(this.OnTargetValueChanged);
                this.OnTargetValueChanged(initialValue);
            }
            break;

            case DataBindingType.Provider:
            {
                if (this.Provider != null)
                {
                    this.Provider.ValueChanged += this.OnTargetValueChanged;
                    if (this.Provider.IsInitialized)
                    {
                        this.OnTargetValueChanged(this.Provider.Value);
                    }
                }
                else
                {
                    this.OnTargetValueChanged(null);
                }
            }
            break;

            case DataBindingType.Constant:
            {
                this.OnTargetValueChanged(this.Constant);
            }
            break;

            case DataBindingType.Reference:
            {
                this.OnTargetValueChanged(this.Reference == null ? null : this.Reference);
            }
            break;
            }
        }
Example #3
0
 protected virtual void Awake()
 {
     this.node = new ContextNode(this.gameObject, this.Path);
 }