示例#1
0
        void OnProjectStateDataChanged(UIProjectStateData data)
        {
            m_ObjectPicker = data.objectPicker;
            if (data.objectSelectionInfo != m_CurrentObjectSelectionInfo)
            {
                m_CurrentObjectSelectionInfo = data.objectSelectionInfo;

                if (m_SelectedDatas.Any(s => s.userId == data.objectSelectionInfo.userId))
                {
                    var selectedData = m_SelectedDatas.First(s => s.userId == data.objectSelectionInfo.userId);
                    m_SelectedDatas.Remove(selectedData);
                }

                var selectedObject = data.objectSelectionInfo.CurrentSelectedObject();
                if (selectedObject != null)
                {
                    var metadata = selectedObject.GetComponentInParent <Metadata>();
                    if (metadata != null)
                    {
                        selectedObject = metadata.gameObject;
                    }
                    else
                    {
                        selectedObject = null;
                    }
                }

                if (data.objectSelectionInfo.userId == m_CurrentUserId)
                {
                    m_CurrentSelectedGameObject = selectedObject;
                }

                if (data.objectSelectionInfo.CurrentSelectedObject() != null)
                {
                    m_SelectedDatas.Add(new SelectionData {
                        userId         = data.objectSelectionInfo.userId,
                        selectedObject = selectedObject,
                        colorId        = data.objectSelectionInfo.colorId
                    });
                }

                UpdateMultiSelection();
            }

            if (data.highlightFilter != m_CurrentHighlightFilter)
            {
                m_CurrentHighlightFilter = data.highlightFilter;

                StartCoroutine(WaitBeforeUpdateHighlight());
            }

            if (data.activeProject != m_CachedActiveProject)
            {
                m_CachedActiveProject = data.activeProject;
                m_SelectedDatas.Clear();
                UpdateMultiSelection();
            }
        }
示例#2
0
        void OnPointerClick(BaseEventData data)
        {
            if (!m_SelectMode)
            {
                return;
            }

            var screenPoint = data.currentInputModule.input.mousePosition;

            var info = new ObjectSelectionInfo();

            info.userId = m_CurrentUserId;
            if (m_PreviousScreenPoint.HasValue && (screenPoint - m_PreviousScreenPoint.Value).magnitude <= m_Tolerance)
            {
                info.selectedObjects = m_CurrentObjectSelectionInfo.selectedObjects;
                info.currentIndex    = m_CurrentObjectSelectionInfo.selectedObjects.Count == 0
                    ? 0
                    : (m_CurrentObjectSelectionInfo.currentIndex + 1) %
                                       m_CurrentObjectSelectionInfo.selectedObjects.Count;
            }
            else
            {
                if (m_Camera == null || !m_Camera.gameObject.activeInHierarchy)
                {
                    m_Camera = Camera.main;
                    if (m_Camera == null)
                    {
                        Debug.LogError($"[{nameof(UISelectionController)}] active main camera not found!");
                        return;
                    }
                }

                m_ObjectPicker.Pick(m_Camera.ScreenPointToRay(screenPoint), m_Results);
                // send a copy of the list to preserve previous selection info
                info.selectedObjects = m_Results.Select(x => x.Item1).Where(x => x.layer != MetadataFilter.k_OtherLayer).ToList();
                info.currentIndex    = 0;
                info.colorId         = 0;
            }

            m_PreviousScreenPoint = screenPoint;
            Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.SelectObjects, info));
        }
示例#3
0
 public void SendSelection(ObjectSelectionInfo info)
 {
     Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.SelectObjects, info));
 }