Exemple #1
0
        protected void BindSelectors(bool overwriteLabels = false)
        {
            var children = transform.GetComponentsInChildren <UISelectorComponent>();

            foreach (var childSelector in children)
            {
                if (overwriteLabels)
                {
                    var iLabel = childSelector.transform.GetComponentInChildren <IPropertyLabel>(true);
                    if (iLabel != null)
                    {
                        iLabel.label = ObjectNames.NicifyVariableName(childSelector.propertyName);
                    }
                }
                var iValue = childSelector.transform.GetComponentInChildren <IPropertyValue>(true);
                m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <object>(childSelector.context, childSelector.propertyName, (property) =>
                {
                    iValue.objectValue = property;
                }));
                Action handler = () =>
                {
                    Dispatcher.Dispatch(ModifyContextPropertyAction.From(
                                            new ModifyContextPropertyActionData
                    {
                        context       = childSelector.context,
                        propertyName  = childSelector.propertyName,
                        propertyValue = iValue.objectValue
                    }));
                };
                iValue.AddListener(handler);
                m_HandlerList.Add(new HandlerData {
                    handler = handler, iPropertyValue = iValue
                });
            }
        }
Exemple #2
0
        void Awake()
        {
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <string>(ApplicationContext.current, nameof(IQualitySettingsDataProvider.qualityLevel), (qualityLevel) =>
            {
                m_QualitySettingValue.text = qualityLevel;
            }));

            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <bool>(DebugOptionContext.current, nameof(IDebugOptionDataProvider.gesturesTrackingEnabled), (gesturesTrackingEnabled) =>
            {
                m_GesturesTrackingToggle.on = gesturesTrackingEnabled;
            }));

            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <bool>(DebugOptionContext.current, nameof(IDebugOptionDataProvider.ARAxisTrackingEnabled), (ARAxisTrackingEnabled) =>
            {
                m_ARAxisTrackingToggle.on = ARAxisTrackingEnabled;
            }));


            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <bool>(DebugOptionContext.current, "ARAxisTrackingEnabled", (ARAxisTrackingEnabled) =>
            {
                m_ARAxisTrackingToggle.on = ARAxisTrackingEnabled;
            }));
        }