I’m current trying to understand some of the logic behind unity engine and just can’t wrap my head around this. Unfortunately looking at declarations and assemblies doesn’t help at all.
Every GameObject in unity can have a transform, collider, rigidbody, renderer, etc as these properties are defined in class “Component”, that derives from “Object”.
My question is, how can I create a custom component (ie “MyGlobalComponent” with public field “delta”) that every GameObject will have and can be accessed via code, for example:
public class MyClass : MonoBehaviour
{
public GameObject go; //set in editor
public int myInt = 0;
void Update ()
{
myInt = go.MyGlobalComponent.delta;
}
}
Thank you.