![]() GetEnumValueIndex and GetEnumValueFromIndex are helpers for handling enum values with Unity’s serialized properties.ShowTypeField helper shows the toggle buttons for selecting the special ability type.In OnGUI in the if (property.isExpanded) block, instead of showing all the 3 cooldown, power and duration fields, we show only the controls that apply to the current special ability type.In GetPropertyHeight we simply add the number of fields we want to show depending on the current selected type of the special ability.Invisibility: Become invisible for duration seconds.Bounce: Reverse the direction of movement as if hitting an invisible wall.Dash: Sudden move in the direction of controller.None: The player cannot use the special ability. ![]() Special ability can have 4 different types: For the purpose of this guide, let’s go ahead and write a property drawer that looks different. By default Unity draws each field of a class or struct with its default property drawer. Let’s start by writing a Property Drawer for the SpecialAbility type. The attributes that Unity uses like Range, Header, etc. I will explain what they are and will create one later in this post.
0 Comments
Leave a Reply. |