Сustom GetComponent for the unity engine, which is faster than the built-in one by more than 10 times!
HOW TO USE
- Inherit your scripts from SMonoBehaviour.
- Set the Root tag on the GameObject that will be associated with its child SMonoBehaviours.
- Get the component using the Instance id of the Root GameObject.
Examples:
SMonoBehaviour instance = GetSharedComponent<SMonoBehaviour>(RootGameObject.GetInstanceID());
if(TryGetSharedComponent(RootGameObject.GetInstanceID(), out SMonoBehaviour sMonoBehaviour))
{
// Some code
}
if you need to get a component not from SMonoBehaviour, then you must directly call the GetSharedComponent method
SMonoBehaviour instance = SMonoBehaviour.GetSharedComponent<SMonoBehaviour>(RootGameObject.GetInstanceID());