- Home /
Question by
Catlard · Dec 28, 2018 at 04:06 AM ·
monobehaviourcoroutines
Wrapping Monobehavior?
Should I wrap most of my (150+) C# monobehaviors with another abstract class that I control, and add functions to it? Or is this hilariously inefficient, if only, say, 60% of the monobehaviors will use the functions in my special wrapper class? The alternative is adding an onDestroy and various other functions to every class. What are the advantages to having these functions in by composition, rather than just inheriting them automatically everywhere?
I work with DoTween (a tweening library) and MEC (instead of coroutines), and I run every coroutine and tween with a tag, or on a gameobject. Whenever I do these things, I register the tag or gameobject with a class that tracks them for me. I do this so I can pause the game at any time without messing with Time.timeScale, and get a "real" pause. The downside to using MEC is that when you kill a gameobject, it does not automatically stop your coroutine -- I'd like to do this manually in my wrapper class. This is why I am wondering whether I should do this.
Comment
Your answer
Follow this Question
Related Questions
Yield return null? 3 Answers
WaitForEndOfFrame vs Time.frameCount 1 Answer
Serializable class with coroutines? 1 Answer
Is there a way to tell if a particular coroutine is running? 2 Answers