inheritance unity code example

Example: unity inheritance

using UnityEngine;
using System.Collections;
 
[System.Serializable]
 
public class ParentClass
{
        // Some code for things
 
}
Code (CSharp):
using UnityEngine;
using System.Collections;
 
[System.Serializable]
public class ChildClass : ParentClass
{
       //Some code to do business
 
}
Even if you want to add a new class inside the code you already have you have to do it. Example.
Code (CSharp):
using UnityEngine;
using System.Collections;
 
public class ClassYouMade : MonoBehaviour {
 
void Update() {
//code...
}
 
}
 
[System.Serializable]
public class SomethingYouMightNeed
{
 
//code...
 
}

Tags:

Misc Example