#if FUSION2
using Fusion;
using System.Threading.Tasks;
using UnityEngine;
namespace BulletHellTemplate
{
public static class FusionUtils
{
///
/// Waits for a component to become available on the root or children of a NetworkObject.
///
public static async Task WaitForComponent(NetworkObject obj, int maxFrames = 60) where T : Component
{
T component = null;
while (component == null && maxFrames-- > 0)
{
component = obj.GetComponent() ?? obj.GetComponentInChildren(true);
await Task.Yield();
}
return component;
}
}
}
#endif