/// <returns>Returns the found component, or <see langword="null"/> if one could not be found.</returns>
/// <remarks>
/// Does not include inactive GameObjects when finding the component, but if a component was previously created
/// as a direct result of this class, it will return that component even if the GameObject is now inactive.
/// </remarks>
publicstaticTFindComponent()
{
TryFindComponent(outvarcomponent);
returncomponent;
}
/// <summary>
/// Find a component <typeparamref name="T"/>.
/// </summary>
/// <param name="component">When this method returns, contains the found component, or <see langword="null"/> if one could not be found.</param>
/// <returns>Returns <see langword="true"/> if the component exists, otherwise returns <see langword="false"/>.</returns>
/// <remarks>
/// Does not include inactive GameObjects when finding the component, but if a component was previously created
/// as a direct result of this class, it will return that component even if the GameObject is now inactive.
/// </remarks>
/// <see cref="FindOrCreateComponent"/>
publicstaticboolTryFindComponent(outTcomponent)
{
if(s_ComponentCache!=null)
{
component=s_ComponentCache;
returntrue;
}
s_ComponentCache=Find();
component=s_ComponentCache;
returncomponent!=null;
}
/// <summary>
/// Find a component <typeparamref name="T"/>.
/// </summary>
/// <param name="component">When this method returns, contains the found component, or <see langword="null"/> if one could not be found.</param>
/// <param name="limitTryFindPerFrame">If <see langword="true"/>, this method will only perform <see cref="Find"/> if it has not already been unsuccessfully called this frame.</param>
/// <returns>Returns <see langword="true"/> if the component exists, otherwise returns <see langword="false"/>.</returns>
/// <remarks>This function will return a cached component from a previous search regardless if <see cref="limitTryFindPerFrame"/> is <see langword="true"/>.</remarks>