public override void OnInspectorGUI()
        {
            if (dontDrawAttribute != null && !shouldBeDrawed)
            {
                if (dontDrawAttribute.IsMissingFunction)
                {
                    EditorGUILayout.HelpBox($"{nameof(DontDrawInspectorIfAttribute)} attribute required a function", MessageType.Error);
                }
                else
                {
                    EditorGUILayout.HelpBox(dontDrawAttribute.Message, MessageType.Error);
                }
                return;
            }

            if (!shouldOverrideInspector)
            {
                base.OnInspectorGUI();
                return;
            }

            serializedObject?.Update();
            inspectorDrawer?.OnInspectorGUI();

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Пример #2
0
        internal override void DrawMember()
        {
            if (m_fieldType.IsDefined(CustomDrawerType, true))
            {
                if (m_classDrawer == null)
                {
                    m_classDrawer          = InspectorDrawer.Create(m_fieldInfo.GetValue(DeclaringObject), SerializedProperty.Copy(), false);
                    m_classDrawerAccordion = new SimpleAccordion(DisplayName, () =>
                    {
                        m_classDrawer.OnEnable();
                        m_classDrawer.OnInspectorGUI();
                    });
                    m_classDrawerAccordion.IsExpanded = SerializedProperty.isExpanded;
                    m_classDrawerAccordion.expandStateChangeCallback = acc => SerializedProperty.isExpanded = acc.IsExpanded;

                    m_classDrawerAccordion.drawHeaderCallback = () => SimpleAccordion.DrawDefaultAccordionHeader(m_classDrawerAccordion, FA.code, 14, 8);
                }

                DrawMember(m_classDrawerAccordion.OnGUI);
                return;
            }

            if (IsListOrArray(m_fieldType))
            {
                if (m_reordableAttribute != null)
                {
                    if (m_reorderableList == null)
                    {
                        m_reorderableList = CreateReordableList(SerializedProperty.serializedObject, SerializedProperty);
                    }
                    DrawMember(m_reorderableList.DoLayoutList);
                }
                else
                {
                    DrawMember(DrawCollection);
                }
            }
            else
            {
                DrawMember(DrawPropertyField);
            }
        }