예제 #1
0
        void Awake()
        {
            m_DialogWindow = GetComponent <DialogWindow>();

            m_ActiveDialogSelector = UISelectorFactory.createSelector <OpenDialogAction.DialogType>(UIStateContext.current, nameof(IDialogDataProvider.activeDialog),
                                                                                                    type =>
            {
                m_DialogButton.selected = type == OpenDialogAction.DialogType.SunStudy;
            });

            TimeOfDaySelector  = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.timeOfDay), OnTimeOfDayChanged);
            TimeOfYearSelector = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.timeOfYear), OnTimeOfYearChanged);
            UtcOffsetSelector  = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.utcOffset), OnUtcChanged);
            LatitudeSelector   = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.latitude), OnLatitudeChanged);
            LongitudeSelector  = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.longitude), OnLongitudeChanged);
            NorthAngleSelector = UISelectorFactory.createSelector <int>(SunStudyContext.current, nameof(ISunstudyDataProvider.northAngle), OnNorthAngleChanged);

            // Initialize controls with current values
            OnTimeOfDayChanged(TimeOfDaySelector.GetValue());
            OnTimeOfYearChanged(TimeOfYearSelector.GetValue());
            OnUtcChanged(UtcOffsetSelector.GetValue());
            OnLatitudeChanged(LatitudeSelector.GetValue());
            OnLongitudeChanged(LongitudeSelector.GetValue());
            OnNorthAngleChanged(NorthAngleSelector.GetValue());

            QueryArgHandler.Register(this, k_NorthAngleQueryKey, OnNorthAngleControlChanged, NorthAngleQueryValue);
            QueryArgHandler.Register(this, k_TimeOfDayQueryKey, OnTimeOfDayControlChanged, TimeOfDayQueryValue);
            QueryArgHandler.Register(this, k_TimeOfYearQueryKey, OnTimeOfYearControlChanged, TimeOfYearQueryValue);
            QueryArgHandler.Register(this, k_UtcOffsetQueryKey, OnUtcOffsetControlChanged, UtcOffsetQueryValue);
            QueryArgHandler.Register(this, k_LatitudeQueryKey, OnLatitudeControlChanged, LatitudeQueryValue);
            QueryArgHandler.Register(this, k_LongitudeQueryKey, OnLongitudeControlChanged, LongitudeQueryValue);
        }
        protected virtual void Awake()
        {
            m_SelectedDatas = new List <SelectionData>();

            m_DisposeOnDestroy.Add(m_MeasureToolStateSelector = UISelectorFactory.createSelector <bool>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.toolState), OnMeasureToolStateDataChanged));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <List <NetworkUserData> >(RoomConnectionContext.current, nameof(IRoomConnectionDataProvider <NetworkUserData> .users), OnUsersChanged));
            m_DisposeOnDestroy.Add(m_LocalUserSelector = UISelectorFactory.createSelector <NetworkUserData>(RoomConnectionContext.current, nameof(IRoomConnectionDataProvider <NetworkUserData> .localUser), OnLocalUserChanged));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <bool>(VRContext.current, nameof(IVREnableDataProvider.VREnable), OnVREnable));
            m_DisposeOnDestroy.Add(m_ObjectPickerSelector        = UISelectorFactory.createSelector <IPicker>(ProjectContext.current, nameof(IObjectSelectorDataProvider.objectPicker)));
            m_DisposeOnDestroy.Add(m_ObjectSelectionInfoSelector = UISelectorFactory.createSelector <SelectObjectAction.IObjectSelectionInfo>(ProjectContext.current, nameof(IObjectSelectorDataProvider.objectSelectionInfo), OnObjectSelectionInfoChanged));
            m_DisposeOnDestroy.Add(m_HOLDFilterSelector          = UISelectorFactory.createSelector <bool>(SceneOptionContext.current, nameof(ISceneOptionData <SkyboxData> .filterHlods)));
            m_DisposeOnDestroy.Add(m_UnityUserSelector           = UISelectorFactory.createSelector <UnityUser>(SessionStateContext <UnityUser, LinkPermission> .current, nameof(ISessionStateDataProvider <UnityUser, LinkPermission> .user)));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <LoginState>(SessionStateContext <UnityUser, LinkPermission> .current, nameof(ISessionStateDataProvider <UnityUser, LinkPermission> .loggedState), OnLoggedStateChanged));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <HighlightFilterInfo>(ProjectContext.current, nameof(IProjectSortDataProvider.highlightFilter), info =>
            {
                StartCoroutine(WaitBeforeUpdateHighlight());
            }));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <Project>(ProjectManagementContext <Project> .current, nameof(IProjectDataProvider <Project> .activeProject), project =>
            {
                m_SelectedDatas.Clear();
                UpdateMultiSelection();
            }));
            m_DisposeOnDestroy.Add(m_ActiveToolSelector = UISelectorFactory.createSelector <SetActiveToolAction.ToolType>(ToolStateContext.current, nameof(IToolStateDataProvider.activeTool),
                                                                                                                          type =>
            {
                if (type != SetActiveToolAction.ToolType.SelectTool)
                {
                    StartCoroutine(UnselectObject());
                }

                m_SelectMode = type == SetActiveToolAction.ToolType.SelectTool && m_MeasureToolStateSelector.GetValue() == false;
                UpdateMultiSelection();
            }));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <OpenDialogAction.DialogType>(UIStateContext.current, nameof(IDialogDataProvider.activeSubDialog),
                                                                                                  type =>
            {
                UpdateMultiSelection();
            }));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <Color[]>(UIStateContext.current, nameof(IUIStateDataProvider.colorPalette),
                                                                              palette =>
            {
                SetColorPalette(palette);
            }));

            OrphanUIController.onPointerClick += OnPointerClick;

            m_Reflect.StreamingStarting += bridge =>
            {
                m_Reflect.ViewerBridge.GameObjectCreating   += OnGameObjectCreating;
                m_Reflect.ViewerBridge.GameObjectDestroying += OnGameObjectDestroying;
                m_Reflect.ViewerBridge.GameObjectEnabling   += OnGameObjectEnabling;
            };

            QueryArgHandler.Register(this, k_SelectionQueryKey, SelectionFromQueryValue, SelectionToQueryValue);
        }