void OnProjectStateDataChanged(UIProjectStateData data) { if (data.objectSelectionInfo != m_CurrentObjectSelectionInfo && (data.objectSelectionInfo.userId == m_CurrentUserId || data.objectSelectionInfo.userId == UIStateManager.current.roomConnectionStateData.localUser.matchmakerId)) { var oldSelectedObject = m_CurrentObjectSelectionInfo.CurrentSelectedObject(); var currentSelectedObject = data.objectSelectionInfo.CurrentSelectedObject(); m_CurrentObjectSelectionInfo = data.objectSelectionInfo; if (currentSelectedObject != oldSelectedObject) { ClearBimList(); m_BimGroupDropdown.options.Clear(); m_BimGroupDropdown.options.Add(k_AllInfoOption); } var isSelected = currentSelectedObject != null; m_NoSelectionText.gameObject.SetActive(!isSelected); if (isSelected) { var metadata = currentSelectedObject.GetComponentInParent <Metadata>(); foreach (var group in metadata.SortedByGroup()) { m_BimGroupDropdown.options.Add(new OptionData(group.Key)); foreach (var parameter in group.Value) { if (parameter.Value.visible) { CreateBimListItem(group.Key, parameter.Key, parameter.Value.value); } } } int targetIndex = 0; m_BimGroupDropdown.SetValueWithoutNotify(targetIndex); // Cant notify or this will trigger the valueChanged and do a dispatch inside a dispatch m_CurrentBimGroup = m_BimGroupDropdown.options[targetIndex].text; m_BimGroupDropdown.RefreshShownValue(); RefreshShownBimItems(); } } if (data.bimSearchString != m_CachedSearchString) { SearchBimItem(data.bimSearchString); m_CachedSearchString = data.bimSearchString; } }
void OnObjectSelectionChanged(ObjectSelectionInfo newData) { var currentSelectedObject = newData.CurrentSelectedObject(); if (currentSelectedObject != m_OldSelectedObject || m_OldSelectedObject == null) { ClearBimList(); m_BimGroupDropdown.options.Clear(); m_BimGroupDropdown.options.Add(k_AllInfoOption); m_OldSelectedObject = currentSelectedObject; } var isSelected = currentSelectedObject != null; m_NoSelectionText.gameObject.SetActive(!isSelected); if (isSelected) { var metadata = currentSelectedObject.GetComponentInParent <Metadata>(); foreach (var group in metadata.SortedByGroup()) { m_BimGroupDropdown.options.Add(new OptionData(group.Key)); foreach (var parameter in group.Value) { if (parameter.Value.visible) { CreateBimListItem(group.Key, parameter.Key, parameter.Value.value); } } } int targetIndex = 0; m_BimGroupDropdown .SetValueWithoutNotify( targetIndex); // Cant notify or this will trigger the valueChanged and do a dispatch inside a dispatch m_CurrentBimGroup = m_BimGroupDropdown.options[targetIndex].text; m_BimGroupDropdown.RefreshShownValue(); RefreshShownBimItems(); } }
void OnProjectStateDataChanged(UIProjectStateData data) { if (data.objectSelectionInfo != m_CurrentObjectSelectionInfo) { var oldSelectedObject = m_CurrentObjectSelectionInfo.CurrentSelectedObject(); var currentSelectedObject = data.objectSelectionInfo.CurrentSelectedObject(); m_CurrentObjectSelectionInfo = data.objectSelectionInfo; if (currentSelectedObject != oldSelectedObject) { ClearBimList(); m_BimGroupDropdown.options.Clear(); m_BimGroupDropdown.options.Add(k_AllInfoOption); } if (currentSelectedObject != null) { var metadata = currentSelectedObject.GetComponentInParent <Metadata>(); foreach (var group in metadata.SortedByGroup()) { m_BimGroupDropdown.options.Add(new OptionData(group.Key)); foreach (var parameter in group.Value) { if (parameter.Value.visible) { CreateBimListItem(group.Key, parameter.Key, parameter.Value.value); } } } int targetIndex = 0; m_BimGroupDropdown.SetValueWithoutNotify(targetIndex); // Cant notify or this will trigger the valueChanged and do a dispatch inside a dispatch m_CurrentBimGroup = m_BimGroupDropdown.options[targetIndex].text; m_BimGroupDropdown.RefreshShownValue(); RefreshShownBimItems(); } } }