- Home /
virtual function, will it effect performance?
As a seasoned C# developer do i really dislike the "magic function" used in unity, it was one of the reasons i changes from PHP to C# for my web development. I thought of making an abstract class that implements the function functions as virtual function. But given that all the methods have been implements, will this effect performance in Unity, or will it cause other problems?
using UnityEngine;
public abstract class MyMonoBehavior : MonoBehaviour
{
/// <summary>
/// Awake is called when the script instance is being loaded.
/// </summary>
public virtual void Awake()
{
}
/// <summary>
/// Start is called just before any of the Update methods is called the first time.
/// </summary>
public virtual void Start()
{
}
/// <summary>
/// Update is called every frame, if the MonoBehaviour is enabled.
/// </summary>
public virtual void Update()
{
}
}
public class TestMonoBehavior : MyMonoBehavior
{
public override void Start()
{
// Insert code here
}
public override void Update()
{
// Inset code here
}
}
Comment
Your answer
Follow this Question
Related Questions
Function GUI with a Return value 1 Answer
A NullReferenceException even though I'm sure that object was assigned? 1 Answer
.setactive not working? on new unity ui 4.6 1 Answer
Using inheritance does base.Update() call overriden functions? 1 Answer
Javascript Inheritance; how to not override functions? 1 Answer