I know of several methods, but they all have drawbacks I would like to avoid:
- The obvious way would be to use GameObject.Find(), but this breaks, as soon as the object gets renamed (and is very costly). Thus I would like to avoid using it.
- FindObjectOfType() will not guarantee, that the correct object is found (there are several objects with the relevant component).
- The last alternative I know of, is using GameObject.FindWithTag(), for which I would need to introduce a tag to the object, while tags are not used in other parts of the project, thus I would break existing conventions.
Is there another solution/best practice for this problem you know of?
I tried researching other ways, but did not find a completely suitable approach, as described above.