-
Notifications
You must be signed in to change notification settings - Fork 23
Mouse Input
The mouse input control allows you to receive over video mouse events.
Add a mouse control to your project (note, you can only create one per project).
Next, adjust the settings to support your needs. There are two adjustable properties:
Send Move Events
*mousedown
(default) - this will only send mouse move events during a mousedown event
-
always
- mouse move events are sent on hover and during mousedown -
never
- never send mouse move events. You will still receive click events.
Move Throttle
You can also adjust mouse move event throttling. The moveThrottle
duration, given in milliseconds, will throttle movement events sent to the game client. The default is 50ms.
If you want to get click events, you can write something such as the following:
if (MixerInteractive.GetMouseButton())
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(MixerInteractive.MousePosition), out hit, 100))
{
target = hit.point;
}
}
If you want to get mouse move events, you can write something such as the following:
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target, step);
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(MixerInteractive.MousePosition), out hit, 100))
{
target = hit.point;
}
Alternatively, you can listen directly to the coordinates change event like so:
MixerInteractive.OnInteractiveCoordinatesChangedEvent += MixerInteractive_OnInteractiveCoordinatesChangedEvent;
...
private void MixerInteractive_OnInteractiveCoordinatesChangedEvent(object sender, Microsoft.Mixer.InteractiveCoordinatesChangedEventArgs e)
{
string viewName = e.Participant.UserName;
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(e.Position), out hit, 100))
{
Debug.Log("HitPoint " + hit);
}
}