Example #1
0
        private void OnGUI()
        {
            if (_sObject == null || _property == null)
            {
                FieldUtility.CreateSerializedObjectAndProperty(_serializedTargetObject, _propertyPath, out _sObject, out _property);
                if (_sObject == null || _property == null)
                {
                    return;
                }

                _disposed = false;
                ArraySize = _property.arraySize;
            }

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
            EditorGUI.BeginChangeCheck();
            _property.isExpanded = true;
            EditorGUILayout.PropertyField(_property);
            EditorGUILayout.EndScrollView();

            if (EditorGUI.EndChangeCheck())
            {
                ArraySize = _property.arraySize;
                _property.serializedObject.ApplyModifiedProperties();
                _property.Dispose();
                _sObject.Dispose();
                _property = null;
                _sObject  = null;
                _disposed = true;
                OnChanged?.Invoke();
            }
        }
        private void CreateSimpleView(SerializedProperty property)
        {
            var simpleField = FieldUtility.GetFieldByType(property, GetTargetObjectValue(), SimpleValueChanged);

            simpleField.AddToClassList("simple-prop-value");
            var simpleContainer = new VisualElement();

            simpleContainer.AddToClassList("simple-prop-container");
            if (!Unwrap)
            {
                simpleContainer.Add(Label);
            }
            simpleContainer.Add(simpleField);
            FieldsContainer.Add(simpleContainer);
        }