Utils/GameObjectExtensions.cs

An extension method for GameObject that schedules its destruction by adding or reusing a TemporaryEffect component and setting its DestroyAfterSeconds property.

Native Interop

public static class GameObjectExtensions
{
	public static void DestroyAsync( this GameObject go, float time )
	{
		var tempEffect = go.GetOrAddComponent<TemporaryEffect>();
		tempEffect.DestroyAfterSeconds = time;
	}
}