Most of it is in the title. I have prefabs with a specific script on them, and every time I restart Unity (doesn’t happen when playing the scene) this one variable will reset to its default of 1
.
Line for editing the variable in my custom editor:
t.tilePriority = (short) EditorGUILayout.IntField (new GUIContent ("Tile priority: ", "Used to determine how this tile connects to others. Negatives not recommended."), t.tilePriority);
Line defining the variable itself:
public short tilePriority = 1;
EDIT: I’ve since added another GameObject variable and it won’t save either. Both variables are defined in the main class, not the custom editor. More details:
GameObject variable defined:
public GameObject backgroundTile;
Entire custom editor script:
public class TileTexEditor : Editor {
public override void OnInspectorGUI ()
{
TileTextureManager t = (TileTextureManager) target;
t.tileType = EditorGUILayout.IntField (new GUIContent ("Tile type: ", "Tile type. used to identify this unique tile.."), t.tileType);
t.tilePriority = EditorGUILayout.IntField (new GUIContent ("Tile priority: ", "Used to determine how this tile connects to others. Negatives not recommended."), t.tilePriority);
t.backgroundTile = EditorGUILayout.ObjectField ("Background Tile: ", t.backgroundTile, typeof (GameObject), false) as GameObject;
serializedObject.Update ();
SerializedProperty spr = serializedObject.FindProperty ("sprites");
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField (spr, true);
if (EditorGUI.EndChangeCheck ())
serializedObject.ApplyModifiedProperties ();
}
}
}