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);
            }
        }
Пример #2
0
        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);
        }