- Home /
Variables depending on enum selection
Hello,
I need help with my item database.
Here is just an example code (in javascript):
public var Items : ItemData[];
public class ItemData
{
public var itemType : ItemType;
public enum ItemType {
Weapon,
Armor,
Consumable
}
//for weapon
public var damage : int;
//for armor
public var armor : int;
//for consumable
public var health_restored : int;
}
So i would like to show only variables of the selected item type. For example if i have Weapon enum selected, it only shows damage in inspector.
i have found one solution http://answers.unity3d.com/questions/417837/change-inspector-variables-depending-on-enum.html
But how does it work with class (multiple items) and in javascript?
thanks!
Perhaps a better way to structure this would be to have the different item types as there own classes, inheriting from the item data class?
That could work, i can't believe i did not think of that. Thanks for the suggestion, i will try it out!
Your answer

Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
How to store a javascript in a variable in the editor then call a function from it? 2 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Using functions of Inherited classes 3 Answers
Changing material depending on variable 2 Answers