How to create a lightweight Item/Mineral/etc System

Hi people

I want to create a space game. There are asteroids and they contain minerals which I want to mine and sell… For now each asteroid is ‘pure’ meaning that it only contains one mineral type. I created several classes:

public class Mineral {

	public string name;
	public int value;

	public Mineral() {
		name = "New Mineral";
		value = 0;

	public override string ToString() {
		return "v:" + value;

	public void OnGUI() {
		GUILayout.Label(name, EditorStyles.boldLabel);
		value = EditorGUILayout.IntField ("Value", value);

public class Asteroid : MonoBehaviour {

	public Mineral mineral = null;


public class Pool {
	public static Dictionary<string, Mineral> minerals = new Dictionary<string, Mineral> ();

	public static void AddMineral(Mineral m) {
		minerals.Add (, m);


Because I have no custom property drawers or something in the inspector for the asteroid there are fields for the name and value fields. But I don’t want to create new mineral objects for each asteroid, I want to be able to select mineral objects from the Pool class. How do I do that? I assume I have to go with serialization and creating custom editors, because the mineral objects and the references to them in the asteroid objects have to exist in edit mode AND play mode. Any idea?

This is a more abstract and general questions, I don’t need concrete code, except it helps you explaining :slight_smile:

To make a list of options appear in the editor, I use an ENUM.
Once you have your list of enumerated values, create a public member of that type, and you will be presented with a drop down list in the editor.
Each item on an Enumeration list is really just a “named number”, and should be used like an integer in your code (which makes them great for working with arrays).

public enum MineralType {NONE=0,GOLD=1,IRON=2,COPPER=3,KRYPTON=4};

public Asteroid:MonoBehaviour
    public MineralType composition;  // this looks like a drop down list in the editor,
                                     // showing all the values in the enum MineralType