I’m trying to create simple custom editor to transform pairs CardSuit&Sprites to Dictionary>
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(CardsView))]
public class CardsViewEditor : Editor {
public override void OnInspectorGUI() {
var script = target as CardsView;
Array suitValues = Enum.GetValues (typeof(CardSuit));
foreach (CardSuit suit in suitValues) {
PairSuitSprites pair = ScriptableObject.CreateInstance<PairSuitSprites>();
pair.suit = suit;
EditorGUILayout.LabelField (pair.suit.ToString ());
SerializedObject serializedObject = new UnityEditor.SerializedObject(pair);
SerializedProperty serializedPropertySprites = serializedObject.FindProperty("sprites");
EditorGUILayout.PropertyField (serializedPropertySprites, true);
serializedObject.ApplyModifiedProperties ();
EditorGUILayout.Space ();
}
}
}
public class PairSuitSprites : ScriptableObject {
public CardSuit suit = 0;
public List<Sprite> sprites;
}
And get smth like this
Looks good. But when I try to drag sprites into field or change Size - nothing happens
Perhaps it’s because of “public class PairSuitSprites : ScriptableObject” ?
How can I describe auxiliary data class to use it only in Editor to store temp data (like “PairSuitSprites”) ?