Home Forums Software Development Can't use 2 Gaze aware objects

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #6855
    Kirsten Chong
    Participant

    I’m having some trouble adding second gaze aware object for my project

    #6858
    Alex [Tobii]
    Participant

    Hi! Is it Unity? Could you please try to explain your problem in details so that I can help you.

    #6859
    Kirsten Chong
    Participant

    Yes, 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)

    #6860
    Alex [Tobii]
    Participant

    Hi!

    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/releases

    Documentation:
    https://tobii.github.io/UnitySDK/

    #6884
    Kirsten Chong
    Participant

    Thanks, 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.

    #6885
    Kirsten Chong
    Participant

    using 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

    #6888
    Alex [Tobii]
    Participant

    Hi!

    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

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.