First of all, thanks for this amazing exporter, I'm pleased with the result so far!
I'm having issues with how I could retrieve information about the current controllers being used. I want to activate my gaze logic if we discovered the player doesn't have controllers. So far my solution was to check with XR but I get some errors on my build. I know that's the problem since I get a functional build without this script enable.
////////////////////////////////////////// Beginning of the script /////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
/*
This script detect if we got both controllers connected for a fullVRExperience
*/
public class CheckCurrentDevice : MonoBehaviour
{
public SimpleGazeCursor SimpleGazeCursorScript;
public NextSteps nsScript;
//public SoapDistributor soapDistributorScript;
// Start is called before the first frame update
void Start()
{
}
void FixedUpdate()
{
// TODO : Find a way to optimize this
// If controllers found
if (HasTwoDifferentHand())
{
SimpleGazeCursorScript.enabled = false;
nsScript.DisableButton();
this.enabled = false;
}
else
{
SimpleGazeCursorScript.enabled = true;
//soapDistributorScript.SetTimeForRubbingHands(30.0f);
this.enabled = false;
}
}
// Finds controllers associated with the current vr device
private bool HasTwoDifferentHand()
{
var nbHands = 0; // 2 means we got both controller
var inputDevices = new List();
InputDevices.GetDevices(inputDevices);
foreach (var device in inputDevices)
{
if (device.role.ToString() == "LeftHanded" || device.role.ToString() == "RightHanded")
{
Debug.Log(string.Format("Device found with name '{0}' and role '{1}'", device.name, device.role.ToString()));
nbHands++;
}
}
return (nbHands == 2 ? true : false);
}
}
//////////////////////////////// End of script /////////////////////
Hello,
First of all, thanks for this amazing exporter, I'm pleased with the result so far!
I'm having issues with how I could retrieve information about the current controllers being used. I want to activate my gaze logic if we discovered the player doesn't have controllers. So far my solution was to check with XR but I get some errors on my build. I know that's the problem since I get a functional build without this script enable.
////////////////////////////////////////// Beginning of the script ///////////////////// using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.XR;
/*
This script detect if we got both controllers connected for a fullVRExperience */ public class CheckCurrentDevice : MonoBehaviour { public SimpleGazeCursor SimpleGazeCursorScript; public NextSteps nsScript; //public SoapDistributor soapDistributorScript;
// Start is called before the first frame update void Start() { }
void FixedUpdate() { // TODO : Find a way to optimize this // If controllers found if (HasTwoDifferentHand()) { SimpleGazeCursorScript.enabled = false; nsScript.DisableButton(); this.enabled = false; } else { SimpleGazeCursorScript.enabled = true; //soapDistributorScript.SetTimeForRubbingHands(30.0f); this.enabled = false; }
}
// Finds controllers associated with the current vr device private bool HasTwoDifferentHand() { var nbHands = 0; // 2 means we got both controller var inputDevices = new List();
InputDevices.GetDevices(inputDevices);
} } //////////////////////////////// End of script /////////////////////
Thanks for the help, Niko Girardelli