Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //base class
- public class BaseCube : MonoBehaviour
- {
- public virtual void DoStuff() {
- }
- }
- //child 1
- public class Cube1 : BaseCube
- {
- public override void DoStuff() {
- base.DoStuff();
- transform.Rotate(0, 1000, 0);
- }
- }
- //child 2
- public class Cube2 : BaseCube
- {
- float scaleFactor = 1.01f;
- public override void DoStuff() {
- base.DoStuff();
- transform.localScale *= scaleFactor;
- }
- }
- //child 3
- public class Cube3 : BaseCube
- {
- [SerializeField] Renderer myRenderer;
- public override void DoStuff() {
- base.DoStuff();
- myRenderer.material.color = Color.red;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement