コード例 #1
0
        protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label)
        {
            label    = EditorGUI.BeginProperty(position, label, property);
            label    = property.name != "data" ? label : GUIContent.none;
            position = EditorGUI.PrefixLabel(position, label);

            var validAttribute = GetVerifiedAttribute(attribute);
            var addSearchField = validAttribute.AddTextSearchField;

            UpdateConstraint(validAttribute);
            UpdateAppearance(validAttribute);

            var referenceProperty = property.FindPropertyRelative("typeReference");
            var activeType        = SerializedType.GetReferenceType(referenceProperty.stringValue);

            typeField.OnGui(position, addSearchField, (type) =>
            {
                try
                {
                    referenceProperty.serializedObject.Update();
                    referenceProperty.stringValue = SerializedType.GetReferenceValue(type);
                    referenceProperty.serializedObject.ApplyModifiedProperties();
                }
                catch (Exception e) when(e is ArgumentNullException || e is NullReferenceException)
                {
                    ToolboxEditorLog.LogWarning("Invalid attempt to update disposed property.");
                }
            }, activeType);

            EditorGUI.EndProperty();
        }
コード例 #2
0
        private void CreateTypeProperty(SerializedProperty property)
        {
            property.GetFieldInfo(out Type propertyType);
            TypeUtilities.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
            var position = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);

            position = EditorGUI.IndentedRect(position);
            typeField.OnGui(position, true, (type) =>
            {
                try
                {
                    if (!property.serializedObject.isEditingMultipleObjects)
                    {
                        UpdateTypeProperty(property, type);
                    }
                    else
                    {
                        var targets = property.serializedObject.targetObjects;
                        foreach (var target in targets)
                        {
                            using (var so = new SerializedObject(target))
                            {
                                SerializedProperty sp = so.FindProperty(property.propertyPath);
                                UpdateTypeProperty(sp, type);
                            }
                        }
                    }
                }
                catch (Exception e) when(e is ArgumentNullException || e is NullReferenceException)
                {
                    ToolboxEditorLog.LogWarning("Invalid attempt to update disposed property.");
                }
            }, currentType, propertyType);
        }
コード例 #3
0
 private static void LogMethodNotSupported(ComparisionTestMethod testMethod, object valueToMatch)
 {
     ToolboxEditorLog.LogWarning(string.Format("{0} comparision method is not supported for type: {1}.", testMethod, valueToMatch.GetType()));
 }