Hey there! Had a custom editor for arrays based on applying a PropertyAttribute to the array.
Under 4.2 we had a nice custom interface which allowed for drag and drop re-ordering and the creation of new elements with a button click. In 4.3, the editor no longer works.
If I put debug output into the PropertyAttribute constructor (not shown in sample), I do not see the debug output when it is applied to an array field. The output does appear when applying the property to a non-array or when manually inspecting attributes on the System.Reflection.FieldInfo.
As field attributes are only constructed when a lookup is done, it seems like Unity, under the hood, is no longer checking for attributes on arrays before selecting a property drawer.
I’ve attached a testbed project that demonstrates the problem. But I’m including my code inline here for quicker skim reading:
This is the Monobehaviour that owns the fields that are not rendered properly.
using UnityEngine;
using System.Collections;
public class HasSomeAttributeProperties : MonoBehaviour {
public int Integer;
public string String;
public MyClazz Clazz;
[MyAttribute("Totally Custom", "#")]
public string AttributeString;
[MyAttribute("Also Custom", "->")]
public string[] AttributeStringArray;
[MyAttribute("Does this work?", "*")]
public MyClazz AttributeClazz;
[MyAttribute("This will also not work.", ">")]
public MyClazz[] AttributeClazzArray;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
This is the attribute, very simple.
using UnityEngine;
using System.Collections;
public class MyAttribute : PropertyAttribute {
public string Label;
public string BulletChar;
public MyAttribute(string label, string bulletChar)
{
Label = label;
BulletChar = bulletChar;
}
}
And here is the drawer:
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomPropertyDrawer(typeof(MyAttribute))]
public class MyAttributeDrawer : PropertyDrawer {
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
{
var mine = attribute as MyAttribute;
GUI.Label(position, mine.BulletChar);
position = new Rect (position.x + 25, position.y, position.width, position.height);
GUI.Label(position, mine.Label);
}
}
As you can see below. The non-array fields are drawn with the property drawer, but the array fields are not: