예제 #1
0
        internal override void OnCreateDestroyClicked()
        {
            if (SubIValue == null)
            {
                var value = UnderlyingValue ?? Activator.CreateInstance(ElementType);

                SubIValue       = Create(value, ElementType);
                SubIValue.Owner = this.Owner;
                SubIValue.m_mainContentParent = this.m_mainContentParent;
                SubIValue.m_subContentParent  = this.m_subContentParent;

                SubIValue.ConstructUI(m_valueContent, m_uiSubGroupParent);
                m_createDestroyBtn.transform.SetAsLastSibling();
            }
            else
            {
                SubIValue.OnDestroy();
                SubIValue = null;
                if (m_subContentParent.gameObject.activeSelf)
                {
                    m_subContentParent.gameObject.SetActive(false);
                }
            }

            this.Owner.SetValue();
            this.OnValueUpdated();
            RefreshElementsAfterUpdate();
            UpdateCreateDestroyBtnState();
        }
        public virtual void UpdateValue()
        {
            var value = IValue.Value;

            // if the type has changed fundamentally, make a new interactivevalue for it
            var type = value == null
                ? FallbackType
                : value.GetType();

            var ivalueType = InteractiveValue.GetIValueForType(type);

            if (ivalueType != IValue?.GetType())
            {
                IValue.OnDestroy();
                CreateIValue(value, FallbackType);
                m_subContent?.SetActive(false);
            }

            IValue.OnValueUpdated();
        }