public static void DrawPropertyDrawer(System.Type type, SerializedProperty property, GUIContent errorLabel)
 {
     if (SOArchitecture_EditorUtility.HasPropertyDrawer(type) || typeof(Object).IsAssignableFrom(type) || type.IsEnum)
     {
         //Unity doesn't like it when you have scene objects on assets,
         //so we do some magic to display it anyway
         if (typeof(Object).IsAssignableFrom(type) &&
             !EditorUtility.IsPersistent(property.objectReferenceValue) &&
             property.objectReferenceValue != null)
         {
             using (new EditorGUI.DisabledGroupScope(true))
             {
                 EditorGUILayout.ObjectField(new GUIContent("Value"), property.objectReferenceValue, type, false);
             }
         }
         else
         {
             EditorGUILayout.PropertyField(property);
         }
     }
     else
     {
         EditorGUILayout.LabelField(errorLabel);
     }
 }
Ejemplo n.º 2
0
    protected void DrawValue()
    {
        if (SOArchitecture_EditorUtility.HasPropertyDrawer(Target.Type))
        {
            //Unity doesn't like it when you have scene objects on assets,
            //so we do some magic to display it anyway
            if (typeof(Object).IsAssignableFrom(Target.Type) &&
                !EditorUtility.IsPersistent(_valueProperty.objectReferenceValue) &&
                _valueProperty.objectReferenceValue != null)
            {
                using (new EditorGUI.DisabledGroupScope(true))
                {
                    EditorGUILayout.ObjectField(new GUIContent("Value"), _valueProperty.objectReferenceValue, Target.Type, false);
                }
            }
            else
            {
                EditorGUILayout.PropertyField(_valueProperty);
            }
        }
        else
        {
            string labelContent = "Cannot display value. No PropertyDrawer for (" + Target.Type + ") [" + Target.BaseValue.ToString() + "]";

            EditorGUILayout.LabelField(new GUIContent(labelContent, labelContent));
        }
    }
Ejemplo n.º 3
0
    private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        rect.height = EditorGUIUtility.singleLineHeight;
        rect.y++;

        SerializedProperty property = _reorderableList.serializedProperty.GetArrayElementAtIndex(index);

        EditorGUI.BeginDisabledGroup(DISABLE_ELEMENTS);

        EditorGUI.LabelField(rect, "Element " + index);

        rect.width /= 2;
        rect.x     += rect.width;

        if (SOArchitecture_EditorUtility.HasPropertyDrawer(Target.Type))
        {
            //Unity doesn't like it when you have scene objects on assets,
            //so we do some magic to display it anyway
            if (typeof(Object).IsAssignableFrom(Target.Type) && !EditorUtility.IsPersistent(property.objectReferenceValue) && property.objectReferenceValue != null)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUI.ObjectField(rect, new GUIContent(""), property.objectReferenceValue, Target.Type, false);
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                EditorGUI.PropertyField(rect, property, new GUIContent(""));
            }
        }
        else
        {
            string content = "No PropertyDrawer for " + Target.Type;

            EditorGUI.LabelField(rect, new GUIContent(content, content));
        }

        //EditorGUI.ObjectField(rect, "Element " + index, property.objectReferenceValue, Target.Type, false);
        EditorGUI.EndDisabledGroup();
    }