✅ Solved: Help with Integrating Rive Button Click Event in Unity (Error: 'RiveWidget' Not Found)

Hi Rive Community,


I'm new to using Rive and currently trying to implement a simple button click interaction in Unity.

I'm using Unity 2023.2.17f1 and have installed the Rive package v0.3.6.


I’ve followed the documentation on State Machines and Events and tried to connect a Rive event to a Unity script, but I keep running into the following error:

Assets\UI\UI Scripts\mainMenu.cs(9,30): error CS0246: The type or namespace name 'RiveWidget' could not be found (are you missing a using directive or an assembly reference?)


I’m not sure if I’m referencing the correct namespace or class.

I've tried using using Rive;, using Rive.Unity;, and a few other variations, but the error persists.

I’m starting to think RiveWidget might be outdated or incorrect – should I be using a different component instead?

Here’s the code I’m working with for context:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Rive;

using Rive.Unity;

public class mainMenu : MonoBehaviour

{

[SerializeField] private RiveWidget m_riveWidget;

private void OnEnable()

{

if (m_riveWidget != null)

{

m_riveWidget.OnRiveEventReported += HandleRiveEventReported;

}

}

private void OnDisable()

{

if (m_riveWidget != null)

{

m_riveWidget.OnRiveEventReported -= HandleRiveEventReported;

}

}

private void HandleRiveEventReported(ReportedEvent reportedEvent)

{

Debug.Log($"Event received: {reportedEvent.Name}");

if (reportedEvent.Name == "singleplayer_btn_clicked")

{

Debug.Log("Singleplayer button was clicked!");

// You can place logic like starting a game, loading a scene, etc. here

// SceneManager.LoadScene("SinglePlayerScene");

}

}

}


My goal is simply to trigger a scene change when the button is clicked in the Rive animation, but I'm stuck on this namespace/type issue and can’t move forward.

Any help or guidance would be greatly appreciated!


Thank you so much in advance! 🌸