10. Find

  03. Features No Comments

The Find class is a utility class that helps in locating instances of objects from loaded scenes as well as assets from the project.

It has been designed from the ground up to work well with interface types, making it easier to decouple your code from specific concrete classes.

All methods in the Find class have the following features:

  • Support for finding instances by interface type.
  • Support for finding instances by the wrapped object type.
  • Support for finding instances from inactive GameObjects.
  • Support for TryGet style queries, where the method returns true if results were found or false if not.

The Find class includes the following static methods:

  • Find.Any – Finds first instance of the provided type from active scenes.
  • Find.All – Finds all instances of the provided type from active scense.
  • Find.InParents – Finds object by type in GameObject and its parents.
  • Find.AllInParents – Finds all objects by type in GameObject and its parents.
  • Find.InChildren – Finds object by type in GameObject and its children.
  • Find.AllInChildren – Finds all objects by type in GameObject and its children.
  • Find.WithTag – Finds object with tag.
  • Find.GameObjectWith – Finds first GameObject from active scenes that has an object of the given type attached to it.
  • Find.GameObjectOf – Finds GameObject from active scenes that has the provided object attached to it.
  • Find.WrappedObject – Finds plain old class object of the provided type wrapped by a wrapper component from active scenes.
  • Find.AllWrappedObjects – Finds all plain old class objects of the provided type wrapped by wrapper components from active scenes.
  • Find.WrapperOf – Finds wrapper component of the provided object.
  • Find.Wrapper – Find first wrapper component from active scense that wraps a plain old class object of the provided type.
  • Find.AllWrappers – Find all wrapper components from active scense that wrap a plain old class object of the provided type.
  • Find.InFinds first object of the provided type that is attached to a specific GameObject.
  • Find.AllInFinds all objects of the provided type that are attached to a specific GameObject.
  • Find.AddressableFinds addressable asset synchronously. Has both runtime and edit mode support.
  • Find.ResourceFinds object from the provided resources path.
  • Find.AssetEditor only method that finds asset of the provided type from the asset database.

Leave a Reply

Your email address will not be published. Required fields are marked *