Day 2

Custom Editor Woes & Tabbed Menu Progress

A bit of a shorter day, today, in which I spent an hour trying to get a custom editor displaying, only to find out that… The editor was targeting something from Unity’s Visual Scripting, rather than my own class 🫠 I’m extending Unity’s Button class, which has a bunch of useful c

25 May 2023 Polyfury development log

A bit of a shorter day, today, in which I spent an hour trying to get a custom editor displaying, only to find out that… The editor was targeting something from Unity’s Visual Scripting, rather than my own class 🫠

I’m extending Unity’s Button class, which has a bunch of useful custom editor code that controls how the navigation system chooses which item to select next, plus some transitions which I usually ignore and implement myself. However, because those buttons already have a custom editor, it doesn’t show any new properties I add! Which means I have to go in and add them myself, like so:

[CustomEditor(typeof(UI.TabButton))]
public class TabButtonEditor : ButtonEditor
{
  private SerializedProperty _text;
  private SerializedProperty _display;
  private SerializedProperty _selectedFontSize;
  private SerializedProperty _selectedCharacterSpacing;
  private SerializedProperty _duration;
  private SerializedProperty _ease;
  private SerializedProperty _onSelected;
  private SerializedProperty _onGroupChange;

  protected override void OnEnable()
  {
    base.OnEnable();
    _text = serializedObject.FindProperty("text");
    _display = serializedObject.FindProperty("display");
    _selectedFontSize = serializedObject.FindProperty("selectedFontSize");
    _selectedCharacterSpacing = serializedObject.FindProperty("selectedCharacterSpacing");
    _duration = serializedObject.FindProperty("duration");
    _ease = serializedObject.FindProperty("ease");
    _onSelected = serializedObject.FindProperty("onSelected");
    _onGroupChange = serializedObject.FindProperty("onGroupChange");
  }

  public override void OnInspectorGUI()
  {
    base.OnInspectorGUI();
    serializedObject.Update();
    EditorGUILayout.PropertyField(_text);
    EditorGUILayout.PropertyField(_display);
    EditorGUILayout.PropertyField(_selectedFontSize);
    EditorGUILayout.PropertyField(_selectedCharacterSpacing);
    EditorGUILayout.PropertyField(_duration);
    EditorGUILayout.PropertyField(_ease);
    EditorGUILayout.PropertyField(_onSelected);
    EditorGUILayout.PropertyField(_onGroupChange);
    serializedObject.ApplyModifiedProperties();
  }
}

Now that’s working, the new tabbed navigation for the options menu is completely up and running, and… My 1 year old son gave me the gift of an awful cold - so I’m going to go have a nap!

What’s next?

Sleep for the next three days? I wish… Next I’ll be sorting more accessibility options - namely fixing the game speed slider, adding sliders for changing the intensity of individual game elements, adding remappable controls, and adding a way to change the background colour. That won’t all happen tomorrow, but it’s my aim to have it sorted by the weekend!


Making your own games? Check out Artificer Pro - released this month!