Raistlin Thoreson
Raistlin Thoreson

Reputation: 31

Custom Editor - Multi-object editing not supported

I have had no previous issues creating custom editors, however with this one it seems to be informing me "Multi-object editing not supported" the code for my script is below as well as the script for my custom editor. Is there something that I'm missing?

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

[AddComponentMenu("Biophase Games/UI/Togglr")]
[System.Serializable]
public class Togglr : MonoBehaviour {

    public List<Toggler> toggles;

    public ColorBlock onColors;
    public ColorBlock offColors;

    public string value;

    void Update() {

        foreach(Toggler t in toggles) {

            if (t.toggle.isOn == true) {

                value = t.text;

                t.toggle.colors = onColors;

            } else {

                t.toggle.colors = offColors;

            }

        }

    }

}

[System.Serializable]
public class Toggler {

    public Toggle toggle;
    public string text;

}

and the CustomEditor script

using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

[CustomEditor(typeof(Togglr))]
[CanEditMultipleObjects]
public class TogglrEditor : Editor {

    SerializedProperty onColors;
    SerializedProperty offColors;
    SerializedProperty toggles;

    void OnEnable() {

        onColors = serializedObject.FindProperty ("onColors");
        offColors = serializedObject.FindProperty ("offColors");
        toggles = serializedObject.FindProperty ("toggles");

    }

    public override void OnInspectorGUI() {

        serializedObject.Update ();

        EditorGUILayout.PropertyField (toggles, true);
        EditorGUILayout.PropertyField (onColors);
        EditorGUILayout.PropertyField (offColors);

        serializedObject.ApplyModifiedProperties ();

    }

}

Upvotes: 0

Views: 4394

Answers (1)

Raistlin Thoreson
Raistlin Thoreson

Reputation: 31

On an attempt to solve my issue, I moved the class Toggler into it's own file which subsequently solved the issue I was having.

Upvotes: 2

Related Questions