- Home /
Whats the most efficient/elegant way to code custom actions for same prefab
Hello,
I'm currently working on a boss battle that takes place in different phases. To this end I have a Phase class that contains info about the phase, such as the health percentage when it triggers, the particle systems that light up and so on. I serialize this class and create a list of it on the inspector that I can then manipulate as I desire (i.e at 75% health, set the boss material to x). This all works fine, but I would like to have a little more control on what triggers during each phase by having code that is specific to it. So far I'm doing it by writing the custom code on a "library" class and then link these methods to the Phase class on the inspector (the Phase class has an Action members that can be invoked when these links are done). This works but I'm not happy with the "have everything on one class approach". I also thought about having an abstract class and inheriting from it, creating custom code in each new child script but this also feels incorrect. Any suggestions? Thanks immensely for helping me become a better programmer :D
Answer by Bunny83 · Dec 07, 2019 at 01:02 AM
Just use Scriptable Objects as plugable actions. If you have an hour to spare, have a look at this Unite talk from 2017
Your answer
![](https://koobas.hobune.stream/wayback/20220612215814im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Public script references in the Inspector 2 Answers
Enabling multiple Monobehaviour Components in a game object 1 Answer
When I Try To Open Scripts in Unity It will look for an app instead of Monodevelop or Visual Studio. 2 Answers
Does anyone know how to activate different scripts OnTrigger? 1 Answer
Design Tokens 0 Answers