Page 1 of 1
Mark Start() and Awake() as protected virtual
Posted: 2021/06/26 11:38
by ZeroX
Hi Arbor team,
I am creating a class that inherits ArborFSM to add some features I want. I need to init some things when Awake() or Start(), but they are not marked as virtual. I had to fix it in your source.
Can you mark those 2 methods as virtual, or create methods OnAwake(), OnStart() for easy inheritance.
Re: Mark Start() and Awake() as protected virtual
Posted: 2021/06/26 12:21
by caitsithware
Thank you for your request.
There is no problem to mark it as protected virtual, but it is not supposed to be used by inheriting from ArborFSM.
Please consider providing an extension method or a control component.
Re: Mark Start() and Awake() as protected virtual
Posted: 2021/06/26 15:53
by ZeroX
Extension methods will not be able to access non-public properties, nor can they store data on the component itself.
The Control Component will make it look unencapsulated.
Currently, I'm using like this:
Re: Mark Start() and Awake() as protected virtual
Posted: 2021/06/27 00:09
by caitsithware
Control components are Unity's theory, so I recommend it.
For example, a PlayerInput script that controls the CharacterController component with Input.
It is okay to inherit it, but please do so at your own risk.
It seems better to mark the protected virtual in the internal design, so I will consider it in the next major version (3.9.0?).
Re: Mark Start() and Awake() as protected virtual
Posted: 2021/06/27 12:01
by ZeroX
Thank you for accepting the request, I look forward to it in the next version.