I have a few classes that have the Serializable attribute and I’m able to edit them just fine. When I hit play, though, it uses the default values. Once I stop the game, the values change back to the ones I set them to. I’ve read in some places that people have been extending the Editor class, but it doesn’t look like the Unity guys are doing that in this video: TANKS! Unity Tutorial - Phase 7 of 8 - Game Managers - YouTube
I’ve spent a few hours looking for a solution (e.g. EditorUtility.SetDirty), but that seems much more complicated than what how the Unity guys made TANKS!.
Below is the code I have. To keep it relevant, I just removed the functions that I have. If you think the functions I have are relevant, let me know and I’ll update the question ![]()
GameManager.cs:
public class GameManager : MonoBehaviour
{
public static GameManager Instance;
public GameObject Camera;
public GameObject MessageCanvas;
public PlayerManager Player1;
void Start () {
if (Instance == null)
{
Instance = this;
}
else if (Instance != this)
{
Destroy(gameObject);
}
Player1 = new PlayerManager();
Player1.Setup();
}
}
PlayerManager.CS:
[Serializable]
public class PlayerManager
{
public GameBoard PlayerBoard;
public void Setup()
{
PlayerBoard = new GameBoard();
PlayerBoard.Initialize();
}
}
GameBoard.CS
[Serializable]
public class GameBoard
{
private Transform boardTransform;
public Grid Player;
public Grid Opponent;
public GameBoard()
{
Player = new Grid();
Opponent = new Grid();
}
public void Initialize()
{
Player.Initialize("Player Grid", boardTransform);
Player.Initialize("Opponent Grid", boardTransform);
}
}
Grid.CS
[Serializable]
public class Grid
{
public int Width = 10;
public int Height = 10;
public float TileSize = 1;
public Material TileMaterial;
public Color TileColor = Color.yellow;
[HideInInspector] public GameObject[][] Tiles;
[HideInInspector] public GameObject instance;
public Grid()
{
// Instansiate Tiles
}
public void Initialize(string name, Transform boardLocation)
{
// Initialize board here.
}
}
Before/After I hit play:
While the game is running:

