Esempio n. 1
0
 void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Esempio n. 2
0
 void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Esempio n. 3
0
 public void SetTarget(object target)
 {
     Clear();
     _target = target;
     if (target != null)
     {
         ScrollRect         scroll = GetComponent <ScrollRect>();
         BrowsableAttribute browse;
         foreach (PropertyInfo prop in _target.GetType().GetProperties())
         {
             browse = PropertyEditors.FindAttribute <BrowsableAttribute>(prop);
             if (browse != null && browse.Browsable)
             {
                 ValueEditor editor = PropertyEditors.Instance.CreateEditor(target, prop);
                 if (editor != null)
                 {
                     editor.transform.SetParent(scroll.content.transform, false);
                 }
                 else
                 {
                     Debug.LogError(string.Format("Failed to create editor for property: {0} ({1})",
                                                  prop.Name, target.GetType().Name));
                 }
             }
         }
         // Ensure the spacer appears at the end.
         Spacer.transform.SetParent(null, false);
         Spacer.transform.SetParent(scroll.content.transform, false);
     }
 }
Esempio n. 4
0
 protected override void OnSetTarget()
 {
     if (Property != null)
     {
         // Check for range property.
         _range = PropertyEditors.FindAttribute <SetRangeAttribute>(Property);
     }
     SetupRange();
     UpdateDisplay();
 }
Esempio n. 5
0
        /// <summary>
        /// Initialise the property target.
        /// </summary>
        /// <param name="target">The target object.</param>
        /// <param name="property">The property reflection object.</param>
        public void SetTarget(object target, PropertyInfo property)
        {
            INotifyPropertyChanged notify;

            if (_target != null)
            {
                notify = target as INotifyPropertyChanged;
                if (notify != null)
                {
                    notify.PropertyChanged -= OnPropertyChanged;
                }
                OnReleaseTarget();
            }

            _target   = target;
            _property = property;

            notify = target as INotifyPropertyChanged;
            if (notify != null)
            {
                notify.PropertyChanged += OnPropertyChanged;
            }

            if (_property != null)
            {
                if (NameField != null)
                {
                    NameField.text = _property.Name;
                }
                if (ToolTipDisplay != null)
                {
                    TooltipAttribute tta = PropertyEditors.FindAttribute <TooltipAttribute>(_property);
                    if (tta != null)
                    {
                        ToolTipDisplay.ToolTip = tta.Tooltip;
                    }
                }
            }

            OnSetTarget();
        }