void UpdateMarkerLibraryData(MarsMarkerLibrary markerLibrary, string markerGuidValue) { const string markersProp = "m_Markers"; if (m_CurrentMarkerIndex != ImageMarkerEditorUtils.UnselectedMarkerIndex && m_CurrentMarkerIndex < markerLibrary.Count && markerLibrary[m_CurrentMarkerIndex].MarkerId.ToString() == markerGuidValue && m_MarkerLibrary == markerLibrary) { return; } m_CurrentMarkerIndex = ImageMarkerEditorUtils.CurrentSelectedImageMarkerIndex(markerLibrary, markerGuidValue); if (m_MarkerLibrary != markerLibrary) { m_MarkerLibrarySerializedObject = new SerializedObject(markerLibrary); m_MarkerProperty = m_MarkerLibrarySerializedObject.FindProperty(markersProp); m_MarkerLibrary = markerLibrary; } if (m_CurrentMarkerIndex != ImageMarkerEditorUtils.UnselectedMarkerIndex) { m_SizeOptionIndex = MarkerConstants.GetSelectedMarsMarkerSizeOption(markerLibrary[m_CurrentMarkerIndex].Size); m_MarkerDefinitionProperty = m_MarkerProperty.GetArrayElementAtIndex(m_CurrentMarkerIndex); } }
/// <summary> /// Draw the Marker Definition Selector GUI /// </summary> /// <param name="markerLibrary"></param> /// <param name="markerGuidValue">The guid string value of the marker id</param> /// <returns>Guid of the selected marker</returns> public string DrawSelectorGUI(MarsMarkerLibrary markerLibrary, string markerGuidValue) { UpdateMarkerLibraryData(markerLibrary, markerGuidValue); using (var check = new EditorGUI.ChangeCheckScope()) { var selectionIndex = ImageMarkerEditorUtils.DrawImageMarkerLibraryInspector(ref m_ImageBrowserScrollPos, markerLibrary, m_CurrentMarkerIndex); if (m_CurrentMarkerIndex == ImageMarkerEditorUtils.UnselectedMarkerIndex) { EditorGUILayout.HelpBox(k_CurrentMarkerGuidDoesntMatchCurrentLibrary, MessageType.Info); } else { m_SizeOptionIndex = ImageMarkerEditorUtils.DrawImageMarkerInfoContentsAtIndex(m_MarkerDefinitionProperty, m_SizeOptionIndex); } DrawGuid(markerGuidValue); if (check.changed) { m_MarkerLibrarySerializedObject.ApplyModifiedProperties(); UpdateMarkerLibrarySerializedObject(); } return(selectionIndex != ImageMarkerEditorUtils.UnselectedMarkerIndex ? markerLibrary[selectionIndex].MarkerId.ToString() : markerGuidValue); } }
public override void OnInspectorGUI() { serializedObject.Update(); var markerLibrary = ImageMarkerEditorUtils.GetSessionMarkerLibrary(); if (markerLibrary == null) { return; } var markerIndex = ImageMarkerEditorUtils.UnselectedMarkerIndex; using (var check = new EditorGUI.ChangeCheckScope()) { var currentMarkerID = m_SynthMarkerGuidProperty.stringValue; var newMarkerID = m_MarkerDefinitionSelectorDrawer.DrawSelectorGUI(markerLibrary, currentMarkerID); markerIndex = ImageMarkerEditorUtils.CurrentSelectedImageMarkerIndex(markerLibrary, newMarkerID); if (markerIndex != ImageMarkerEditorUtils.UnselectedMarkerIndex) { var markerDefinition = markerLibrary[markerIndex]; if (newMarkerID != currentMarkerID) { m_SynthMarkerGuidProperty.stringValue = newMarkerID; m_SynthMarkerTextureProperty.objectReferenceValue = markerDefinition.Texture; serializedObject.ApplyModifiedProperties(); m_MarkerDefinitionSelectorDrawer.UpdateMarkerLibraryData(m_SynthMarkerGuidProperty.stringValue); } if (check.changed) { m_SynthesizedMarkerId.UpdateMarkerSize(markerDefinition.Size); } } if (check.changed) { serializedObject.ApplyModifiedProperties(); MARSSession.Instance.CheckCapabilities(); EditorUtility.SetDirty(this); } } SetMarkerSizeToTransformScale(markerLibrary, markerIndex); }
public override void OnInspectorGUI() { serializedObject.Update(); var markerLibrary = ImageMarkerEditorUtils.GetSessionMarkerLibrary(); if (markerLibrary == null) { return; } using (var check = new EditorGUI.ChangeCheckScope()) { var currentMarkerID = m_MarkerGuidProperty.stringValue; var newMarkerID = m_MarkerDefinitionSelectorDrawer.DrawSelectorGUI(markerLibrary, currentMarkerID); if (newMarkerID != currentMarkerID) { m_MarkerGuidProperty.stringValue = newMarkerID; serializedObject.ApplyModifiedProperties(); m_MarkerDefinitionSelectorDrawer.UpdateMarkerLibraryData(m_MarkerGuidProperty.stringValue); } if (check.changed) { serializedObject.ApplyModifiedProperties(); isDirty = true; var marsSession = MARSSession.Instance; if (marsSession == null) { return; } marsSession.CheckCapabilities(); } } }