Setting a [SerializeField] GameObject in code

Hey there,

I am trying to set the following member

	[SerializeField] [HideInInspector]
	private GameObject structure;

with the following code:

structure = (GameObject) Instantiate(Resources.Load("Map/Base Prefab"));

The code is not meant to be executed in game, but is triggered by a custom Editor-class:

I am building a kind of map editor for a hexgrid-based strategy game. When klicking on a hex-tile, the inspector shows several dropdowns to define properties or to add buildings. So I want to instantiate a prefab for a base/HQ-structure and keep it referenced with the structure member.

When deleting the [SerializeField] - flag, structure is set when changing the dropdown in Editor-Mode, but the reference is lost when I finally start the game (which was the reason to use [SerializeField] in the first place).

Any ideas on how to set this up properly?

Beste,
der_smon

See the comment above for the solution.