Camera.main look up

How exactly unity API store Camera.main? I know gameobject with a tag MainCamera is looked up and returned. But, does that mean that every time i get the property a gameobject find by tag is executed, or it’s cached somehow more efficiently to save unnecessary tag search?

Can’t be 100% certain without access to the Unity source, but I would bet money that Camera.main is just a convenience property that wraps finds by tag and calls it every time.

Game object tags can be changed at runtime (meaning that the “main camera” object can theoretically change moment-to-moment), so caching the value would require listening for tag changes on all game objects. Even if there were an API for that, it would be a performance imposition on any code that changes game object tags, which is unreasonable when callers of Camera.main can just cache the return value.