Init(args) contains new generic versions of the ScriptableObject base class, extending it with the ability to specify upto six objects that the class depends on.
For example the following GameEvent class depends on a string and a GameObject.
public class GameEvent : ScriptableObject<string, GameObject>
When you create a class that inherits from one of the generic ScriptableObject base classes, you’ll always also need to implement the Init function for receiving the arguments.
protected override void Init(string id, GameObject target) { Id = id; Target = target; }
The Init function is called when the object is being initialized, before the Awake function.
Creating Instances
If you have a ScriptableObject of type TScriptableObject that inherits from ScriptableObject<TArgument>, you can create a new instance of the class and initialize it with an argument using the following syntax:
Create.Instance<TScriptableObject, TArgument>(argument);
You can create a clone of an existing instance using the following syntax:
sciptableObject.Instantiate(argument);
Awake Event
Do not add an Awake function to classes that inherit from one of the generic ScriptableObject classes, because the classes already define an Awake function. If you need to do something during the Awake event, override the OnAwake function instead.
Reset Event
Do not add a Reset function to classes that inherit from one of the generic ScriptableObject classes, because the classes already define a Reset function. If you need to do something during the Reset event, override the OnReset function instead.