MonoBehaviours in Unity are generally pretty cool, but can instantly become uncool when you want to work with Generics. The UnityEditor doesn’t know how to find and instantiate generic behaviours. It won’t even let you attach them, but there is a solution.
In Part 2 of the series we added support for easing functions in our tweens. We followed an extensible model that allows us to create and plug in new easing functions on the fly without requiring drastic changes to our core Interpolator logic. Today, we’re going to do the same thing with looping.
If you’re building anything substantial in Unity, you ultimately will want to use base or code-only instantiated MonoBehaviour classes. It can be a real hassle to deal with these cluttering up your script component menu in the Unity editor when you never want to access them that way.
In Part 1 of this series we’re going to write an extremely basic Interpolator class that linearly interpolates a value between two numbers.