public class RunFromTemplate_Script : GameEngine_Script {
When i call a function in the “GameEngine_Script”, from the “RunFromTemplate_Script” it requires that the associated properties, as well as the function, is “static”. Could someone please explain to me why? Have been trying to read about it but with my little brain i still don’t get it 100%.
It doesn’t ‘have’ to be static, unless you’re trying to access a method/property on the class itself, rather than an instance of the class.
A class is supposed to be the blueprint for an object. It defines how an object is shaped and operates, then you create an instance of it (either with the ‘new’ command, or AddComponent in the case of unity). You can than access the properties/methods of the object on that specific instance.
Static methods/properties exist as a sort of ‘global’ access point of that class. It’s useful for utility functions, constants, factory methods, the sort. Think like the ‘Mathf’ class which is full of static methods. The class itself doesn’t have a state, instead the functions just do some stuff to the inputs and returns an output as a result.