Home › Forums › Software Development › Can't use 2 Gaze aware objects
- This topic has 6 replies, 2 voices, and was last updated 7 years, 5 months ago by Alex [Tobii].
- AuthorPosts
- 14/05/2017 at 00:47 #6855Kirsten ChongParticipant
I’m having some trouble adding second gaze aware object for my project
14/05/2017 at 15:08 #6858Alex [Tobii]ParticipantHi! Is it Unity? Could you please try to explain your problem in details so that I can help you.
14/05/2017 at 16:10 #6859Kirsten ChongParticipantYes, unity. My code is the explame of SpinOnGaze that makes the cubes spin and it works, but when I add a second gaze aware object only one of them works(the last one that I added)
15/05/2017 at 14:35 #6860Alex [Tobii]ParticipantHi!
Sounds weird.
We have just released a major update for the Unity SDK. Please check the new samples and see if they work. If there’s still a problem, please record a video with what you are doing using OBS or some other screen capture software and I will take a look at it.
Tobii Unity SDK for Desktop 3.0:
Download:
https://github.com/Tobii/UnitySDK/releasesDocumentation:
https://tobii.github.io/UnitySDK/17/05/2017 at 00:06 #6884Kirsten ChongParticipantThanks, now I can use two gaze aware objects.
I still cant run my code properly. When connecting tobii to IO ports, it give me an error “System.NullReferenceException if I add two objects, if I just add one it works properly.
17/05/2017 at 00:14 #6885Kirsten ChongParticipantusing Tobii.Gaming;
using UnityEngine;
using System.Collections;
using System.IO.Ports;[RequireComponent(typeof(GazeAware))]
public class SpinOnGaze : MonoBehaviour {
SerialPort serial = new SerialPort (“COM3”, 9600);
private GazeAware _gazeAware;void Start()
{
serial.Open();
_gazeAware = GetComponent<GazeAware>();
}void Update()
{
if (_gazeAware.HasGazeFocus)
{
transform.Rotate(Vector3.forward);
{ serial.Write(“e”);}
}
}
}If i just use one gameObject, the servo and the cube moves. But if I add a second object, with this line of code
using Tobii.Gaming;
using UnityEngine;
using System.Collections;
using System.IO.Ports;[RequireComponent(typeof(GazeAware))]
public class SpinOnGazee : MonoBehaviour {
SerialPort serial = new SerialPort (“COM3”, 9600);
private GazeAware _gazeAware;void Start()
{
serial.Open();
_gazeAware = GetComponent<GazeAware>();
}void Update()
{
if (_gazeAware.HasGazeFocus)
{
transform.Rotate(Vector3.forward);
{ serial.Write(“e”);}
}
}
}I get a Null reference exception
17/05/2017 at 11:19 #6888Alex [Tobii]ParticipantHi!
Hard to say where exactly you get Null reference exception, but I would guess that in serial.Open();
And most likely it’s because you are trying to open the port twice.
Check https://msdn.microsoft.com/en-us/library/system.io.ports.serialport.open(v=vs.110).aspx
- AuthorPosts
- You must be logged in to reply to this topic.