Custom Action Type

Szymon Z.

Member
Hello.

How we can create another Item Action Type and make it available trought Item Manager ?

For example i want to add new Action Type: CharacterTool as an Action and make it available from this dropdown

1626343979190.png
 
That dropdown is rendered by ItemBuilder.cs. If you wanted to add your own ItemActions to it, you'd need to edit that script in at least a couple of places: adding your ItemType to the ActionType enum at the top of the script, also adding it as a switch case in the AddAction method. There may be other places in the script that would need to be edited too.

Note that you can simply add/remove ItemType components to an item gameobject too, so in most cases there's no need to worry about the editor side of things.

To create a custom ItemType, you'd need to simply create a subclass of whatever type you want to inherit from. E.g. if you want to create a custom ItemType which is based on ShootableWeapon, then you'd create a class that inherits from ShootableWeapon (e.g. public class MyCustomShootableWeapon : ShootableWeapon). Or to create a completely custom ItemAction, just inherit from ItemAction instead. I'd recommend taking a look through the base ItemAction class. Also the Flashlight class is a good example of a simple custom ItemAction (it inherits from UsableItem).
 
Top