Skip to content

Commit

Permalink
Merge pull request #3270 from KBVE/patch-zeta-vuplex-switch-to-iwebvi…
Browse files Browse the repository at this point in the history
…ew-11-18-2024-1731929463

[CI] Merge patch-zeta-vuplex-switch-to-iwebview-11-18-2024-1731929463 into dev
  • Loading branch information
h0lybyte authored Nov 18, 2024
2 parents 43e4b52 + 846358f commit daca975
Showing 1 changed file with 18 additions and 28 deletions.
46 changes: 18 additions & 28 deletions packages/kilonet/kilonet/Utils/VuplexHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public class VuplexHelper : MonoBehaviour
{
public Canvas CanvasObject;
public CanvasWebViewPrefab CanvasWebViewPrefab;

public CanvasWebViewPrefab CanvasWebViewPrefabView;
private CanvasWebViewPrefab _canvasWebViewPrefab;
public IWebView CanvasWebViewPrefabView;

private Supabase.Client _supabaseClient;

Expand All @@ -38,32 +36,24 @@ private async void Start()
}


private async UniTask InitializeWebView()
private async UniTask InitializeWebView()
{
if (CanvasObject == null)
{
Debug.LogError("CanvasObject is not set in the Unity Editor.");
return;
}

if (CanvasWebViewPrefab == null)
{
Debug.LogError("CanvasWebViewPrefab is not set in the Unity Editor.");
return;
}

if (CanvasWebViewPrefabView == null)
{
Debug.LogError("CanvasWebViewPrefabView is not set in the Unity Editor.");
return;
}

// Ensure CanvasWebViewPrefabView is properly initialized
await CanvasWebViewPrefabView.WaitUntilInitialized();
try
{
if (CanvasObject == null || CanvasWebViewPrefab == null || CanvasWebViewPrefabView == null)
{
Debug.LogError("CanvasObject, CanvasWebViewPrefab, or CanvasWebViewPrefabView is not set in the Unity Editor.");
return;
}

// Register message handling
CanvasWebViewPrefabView.WebView.MessageEmitted += OnMessageReceived;
Debug.Log("Vuplex CanvasWebView successfully initialized and ready to receive messages.");
await CanvasWebViewPrefabView.WaitUntilInitialized();
CanvasWebViewPrefabView.MessageEmitted += OnMessageReceived;
Debug.Log("Vuplex WebView successfully initialized.");
}
catch (Exception ex)
{
Debug.LogError($"Error during WebView initialization: {ex.Message}\n{ex.StackTrace}");
}
}


Expand All @@ -75,7 +65,7 @@ private async UniTask InitializeSupabaseClientAsync()
var options = new SupabaseOptions { AutoRefreshToken = true, AutoConnectRealtime = false, };

_supabaseClient = new Supabase.Client(SUPABASE_URL, SUPABASE_ANON_KEY, options);
await _supabaseClient.InitializeAsync(); // Await the initialization instead of using .Wait()
await _supabaseClient.InitializeAsync();

Debug.Log("Supabase client initialized successfully.");
}
Expand Down

0 comments on commit daca975

Please sign in to comment.