First-Person-Controller-VeryHotShark icon indicating copy to clipboard operation
First-Person-Controller-VeryHotShark copied to clipboard

Add event Action or event Func where appropriate

Open beardordie opened this issue 5 years ago • 1 comments

This is just a suggestion. In my local branch I've added several events that are initialized as empty delegates. By adding these, it is easy to subscribe/unsubscribe to relevant events invoked by the FirstPersonController. In the following example I added events that will fire OnZoomIn and OnZoomOut from the CameraController class. I've done similar for OnJump, OnLand, OnBeginCrouch, OnEndCrouch, etc.

CameraController.cs additions: cameraController-1 cameraController-2

Then any other MonoBehaviour can subscribe to the events in OnEnable, and unsubscribe in OnDisable like this: newMonoBehaviour

beardordie avatar Jun 28 '19 02:06 beardordie

Yes it a very good practice and way to structure a code :) can you somehow do a pull request so i can see other func and actions ?

VeryHotShark avatar Jul 13 '19 18:07 VeryHotShark