Hi,
I’m trying to create a very simple database one to many like list, in which I have:
- A list of objects (cooker, toaster, box…)
- A list of tools (bread, knife, cup…)
- A list of the above objects, that can have many of the above tools, with other variables (this will be on how they interact, how long etc)
So I have something like the below as an example of what I’d like to achieve.
My main goal is to be able to populate these from the editor, so they can be changed at will, and saved against whatever object I put it on.
I can’t figure our how to populate the UseableTool.obj or UseableTool.tool, with the other lists, doing it as shown below just creates further list objects.
Any thoughts/ideas?
Thanks,
Geordie
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Data : MonoBehaviour {
[SerializeField] List<Object> objects = new List<Object>();
[SerializeField] List<Tool> tools = new List<Tool>();
[SerializeField] List<UseableTool> useableTools = new List<UseableTool>();
[System.Serializable]
public class Object {
public string name;
}
[System.Serializable]
public class Tool{
public string name;
public float cost;
}
[System.Serializable]
public class UseableTool{
public Object obj;
public Tool tool;
public float time;
public float effort;
}
}