So I wanted a more interesting item system than this common list with variables thing.
I've a basic item class with this:
public class Item : ScriptableObject {
public string name;
public string description;
public Texture2D icon;
public int weight;
public bool stackable;
}
And then I've another class that inherits the item class:
public class WeaponMod : Item
{
public float damage;
public Texture2D projectile;
public enum WeaponControl { DirectedFront, Mouse };
public WeaponControl weaponControl;
}
Then I've a simple mono behavior script with the list containing the items:
public class ItemManager : MonoBehaviour
{
public List- itemList;
}
Also I created a custom editor script where you are able to ex. create a weapon. To add it to the item list I use this function:
WeaponMod Weapon = (WeaponMod)ScriptableObject.CreateInstance
();
itemManager.itemList.Add(Weapon);
In the editor I can see & edit the item variables and the weapon variables, but when I try to access the weapon variables in the script I only see the item variables.
![alt text][1]
![alt text][2]
[1]: http://imageshack.com/a/img843/5840/t2kt.png
[2]: http://imageshack.com/a/img840/2981/byt.png
Am I totally wrong with this method or am I just missing a piece?
Trending Articles
More Pages to Explore .....