So I’m following along with a tutorial (Hex Map 1) and am currently on part 4.1 where we make a custom property drawer and for some reason mine just isn’t displaying the label no matter what I do. It’s half working because the positioning is correct for the information afterwards, but instead of displaying the name of the property, it’s just blank.
Here’s the code for the property drawer, it’s exactly the same as in the tutorial and it worked just fine for him.
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(HexCoordinates))]
public class HexCoordinatesDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
HexCoordinates coordinates = new HexCoordinates(property.FindPropertyRelative("x").intValue,
property.FindPropertyRelative("z").intValue);
position = EditorGUI.PrefixLabel(position, label);
GUI.Label(position, coordinates.ToString());
}
}
The tutorial is a few years old at this point, so I wouldn’t be surprised if this is a new bug or it’s been deprecated, but even according to the current documentation what I’m doing should work. I tried playing around with some things and confirmed that label.text is “Coordinates” which is what I expect to see instead of nothing. Any ideas? I’m using Unity 2021.1.19f1
