kiyah
kiyah

Reputation: 1528

Unity custom editor error "type is not a supported int value"

I was making my own custom script editor with SerializedProperty variables, but I got the following error:

type is not a supported int value
UnityEditor.SerializedProperty:get_boolValue()

The reason why I was using SerializedProperty variable types is that I use the script on a prefab, which would cause some trouble with overriding parameters.

Here is my editor script:

using UnityEditor;
using UnityEngine;
using sp = UnityEditor.SerializedProperty;

[CustomEditor (typeof (ScriptName))]
public class SwitchableObjectEditor : Editor {

    SerializedProperty usePanel, morningHint;

    protected virtual void OnEnable () {
        usePanel = serializedObject.FindProperty ("morningHint");
        morningHint = serializedObject.FindProperty ("morningHint");
    }

    public override void OnInspectorGUI () {
        if (UnityEditor.EditorApplication.isPlaying)
            return;
        ScriptName s = (ScriptName) target;

        usePanel.boolValue = EditorGUILayout.Toggle (usePanel.boolValue);
        morningHint.stringValue = EditorGUILayout.TextArea (morningHint.stringValue);
        this.serializedObject.ApplyModifiedProperties ();
    }
}

I was frustrated, because the morningHint variable worked nicely.

Upvotes: 0

Views: 6131

Answers (1)

kiyah
kiyah

Reputation: 1528

It turns out I forgot to change the serializedObject.FindProperty() value for usePanel, changing it fixed everything.

Just putting this here in case anyone produced the same mistake.

Upvotes: 1

Related Questions