/// <summary>
 /// Registers an interactor with the repository.
 /// </summary>
 /// <param name="interactor">The interactor.</param>
 public void RegisterInteractor(EyeXInteractor interactor)
 {
     lock (_lock)
     {
         _interactors[interactor.Id] = interactor;
     }
 }
 /// <summary>
 /// Register the interactor when the game object is enabled.
 /// </summary>
 protected virtual void OnEnable()
 {
     var interactor = new EyeXInteractor(_interactorId, EyeXHost.NoParent);
     interactor.EyeXBehaviors = GetEyeXBehaviorsForGameObjectInteractor();
     UpdateInteractorLocation(interactor);
     _eyeXHost.RegisterInteractor(interactor);
 }
 /// <summary>
 /// Register the interactor when the game object is enabled.
 /// </summary>
 protected virtual void OnEnable()
 {
     var interactor = new EyeXInteractor(_interactorId, EyeXHost.NoParent);
     interactor.EyeXBehaviors = GetEyeXBehaviorsForGameObjectInteractor();
     UpdateInteractorLocation(interactor);
     _eyeXHost.RegisterInteractor(interactor);
 }
 /// <summary>
 /// Gets an interactor from the repository.
 /// </summary>
 /// <param name="interactorId">ID of the interactor.</param>
 /// <returns>Interactor, or null if not found.</returns>
 public EyeXInteractor GetInteractor(string interactorId)
 {
     lock (_lock)
     {
         EyeXInteractor interactor = null;
         _interactors.TryGetValue(interactorId, out interactor);
         return(interactor);
     }
 }
Exemple #5
0
    /// <summary>
    /// Gets a value indicating whether the specified interactor has received the user's gaze.
    /// Note that only interactors which have been assigned the GazeAware behavior will receive gaze events.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>True if the user's gaze is within the bounds of the interactor.</returns>
    public static bool HasGaze(this EyeXInteractor interactor)
    {
        var behavior = GetGazeAwareBehavior(interactor);

        if (behavior == null)
        {
            return(false);
        }
        return(behavior.HasGaze);
    }
    /// <summary>
    /// Gets a value indicating the activation focus state of the specified interactor.
    /// Note that only interactors which have been assigned the Activatable behavior have an activation focus state.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>The activation focus state.</returns>
    public static ActivationFocusState GetActivationFocusState(this EyeXInteractor interactor)
    {
        var behavior = GetActivatableBehavior(interactor);

        if (behavior == null)
        {
            return(ActivationFocusState.None);
        }
        return(behavior.ActivationHub.GetActivationFocusState(interactor.Id));
    }
    /// <summary>
    /// Gets a value indicating whether the specified interactor has been activated.
    /// Note that only interactors which have been assigned the Activatable behavior can be activated.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>True if the interactor has been activated.</returns>
    public static bool IsActivated(this EyeXInteractor interactor)
    {
        var behavior = GetActivatableBehavior(interactor);

        if (behavior == null)
        {
            return(false);
        }
        return(behavior.ActivationHub.GetIsActivated(interactor.Id));
    }
 /// <summary>
 /// Register an activatable interactor for each menu item when the game object is enabled.
 /// </summary>
 public void OnEnable()
 {
     foreach (var menuItem in _menuItems)
     {
         var interactorId = menuItem.name;
         var interactor = new EyeXInteractor(interactorId, EyeXHost.NoParent);
         interactor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub) { IsTentativeFocusEnabled = true });
         interactor.Location = CreateLocation(menuItem, _gameMenu.IsVisible);
         _eyeXHost.RegisterInteractor(interactor);
     }
 }
Exemple #9
0
 /// <summary>
 /// Gets the <see cref="EyeXPannable"/> behavior for the specified interactor.
 /// </summary>
 /// <param name="interactor">The interactor.</param>
 /// <returns>The <see cref="EyeXPannable"/> for the specified interactor.</returns>
 public static EyeXPannable GetPannableBehavior(EyeXInteractor interactor)
 {
     foreach (var behavior in interactor.EyeXBehaviors)
     {
         var gazeAwareBehavior = behavior as EyeXPannable;
         if (gazeAwareBehavior != null)
         {
             return(gazeAwareBehavior);
         }
     }
     return(null);
 }
Exemple #10
0
    public void OnEnable()
    {
        // Register activatable interactors for the GUI buttons when the game object is enabled.
        var spinInteractor = new EyeXInteractor(SpinButtonId, EyeXHost.NoParent);
        spinInteractor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub) { IsTentativeFocusEnabled = false });
        spinInteractor.Location = CreateLocation(SpinButtonBounds);
        _eyeXHost.RegisterInteractor(spinInteractor);

        var stopInteractor = new EyeXInteractor(StopButtonId, EyeXHost.NoParent);
        stopInteractor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub) { IsTentativeFocusEnabled = false });
        stopInteractor.Location = CreateLocation(StopButtonBounds);
        _eyeXHost.RegisterInteractor(stopInteractor);
    }
    /// <summary>
    /// Gets the EyeXActivatable behavior assigned to the interactor.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>The behavior. Null if no matching EyeX behavior has been assigned to the interactor.</returns>
    public static EyeXActivatable GetActivatableBehavior(EyeXInteractor interactor)
    {
        foreach (var behavior in interactor.EyeXBehaviors)
        {
            var activatableBehavior = behavior as EyeXActivatable;
            if (activatableBehavior != null)
            {
                return activatableBehavior;
            }
        }

        return null;
    }
    /// <summary>
    /// Gets the EyeXGazeAware behavior assigned to the interactor.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>The behavior. Null if no matching EyeX behavior has been assigned to the interactor.</returns>
    public static EyeXGazeAware GetGazeAwareBehavior(EyeXInteractor interactor)
    {
        foreach (var behavior in interactor.EyeXBehaviors)
        {
            var gazeAwareBehavior = behavior as EyeXGazeAware;
            if (gazeAwareBehavior != null)
            {
                return gazeAwareBehavior;
            }
        }

        return null;
    }
    /// <summary>
    /// Gets the EyeXActivatable behavior assigned to the interactor.
    /// </summary>
    /// <param name="interactor">The interactor.</param>
    /// <returns>The behavior. Null if no matching EyeX behavior has been assigned to the interactor.</returns>
    public static EyeXActivatable GetActivatableBehavior(EyeXInteractor interactor)
    {
        foreach (var behavior in interactor.EyeXBehaviors)
        {
            var activatableBehavior = behavior as EyeXActivatable;
            if (activatableBehavior != null)
            {
                return(activatableBehavior);
            }
        }

        return(null);
    }
Exemple #14
0
 /// <summary>
 /// Register an activatable interactor for each menu item when the game object is enabled.
 /// </summary>
 public void OnEnable()
 {
     foreach (var menuItem in _menuItems)
     {
         var interactorId = menuItem.name;
         var interactor   = new EyeXInteractor(interactorId, EyeXHost.NoParent);
         interactor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub)
         {
             IsTentativeFocusEnabled = true
         });
         interactor.Location = CreateLocation(menuItem, _gameMenu.IsVisible);
         _eyeXHost.RegisterInteractor(interactor);
     }
 }
    private void UpdateInteractorLocation(EyeXInteractor interactor)
    {
        var location = GetProjectedRect();

        EyeXMask mask = null;
        if (location.isValid && 
            maskType != EyeXMaskType.None)
        {
            // Create a mask for the interactor and move it to the top.
            mask = CreateMask(location.rect, Screen.height);
            location.relativeZ = Camera.main.farClipPlane;
        }

        interactor.Location = location;
        interactor.Mask = mask;
    }
Exemple #16
0
    public void OnEnable()
    {
        // Register activatable interactors for the GUI buttons when the game object is enabled.
        var spinInteractor = new EyeXInteractor(SpinButtonId, EyeXHost.NoParent);

        spinInteractor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub)
        {
            IsTentativeFocusEnabled = false
        });
        spinInteractor.Location = CreateLocation(SpinButtonBounds);
        _eyeXHost.RegisterInteractor(spinInteractor);

        var stopInteractor = new EyeXInteractor(StopButtonId, EyeXHost.NoParent);

        stopInteractor.EyeXBehaviors.Add(new EyeXActivatable(_eyeXHost.ActivationHub)
        {
            IsTentativeFocusEnabled = false
        });
        stopInteractor.Location = CreateLocation(StopButtonBounds);
        _eyeXHost.RegisterInteractor(stopInteractor);
    }
 /// <summary>
 /// Register the interactor when the game object is enabled.
 /// </summary>
 public void OnEnable()
 {
     var interactor = new EyeXInteractor(_interactorId, EyeXHost.NoParent, eyeXBehaviors, OnEyeXEvent);
     UpdateInteractorLocation(interactor);
     _eyeXHost.RegisterInteractor(interactor);
 }
    private void UpdateInteractorLocation(EyeXInteractor interactor)
    {
        var location = ProjectedRect.GetProjectedRect(gameObject, Camera.main);

        EyeXMask mask = null;
        if (location.isValid &&
            maskType != EyeXMaskType.None)
        {
            // Create a mask for the interactor and move it to the top.
            mask = CreateMask(location.rect, Screen.height);
            location.relativeZ = Camera.main.farClipPlane;
        }

        interactor.Location = location;
        interactor.Mask = mask;
    }
Exemple #19
0
    /// <summary>
    /// Gets the current panning velocity.
    /// </summary>
    /// <param name="interactor"></param>
    /// <returns></returns>
    public static Vector2 GetPanVelocity(this EyeXInteractor interactor)
    {
        var behavior = GetPannableBehavior(interactor);

        return(behavior == null ? Vector2.zero : behavior.Velocity);
    }
Exemple #20
0
 /// <summary>
 /// Registers an interactor with the repository.
 /// </summary>
 /// <param name="interactor">Interactor.</param>
 public void RegisterInteractor(EyeXInteractor interactor)
 {
     lock (_lock)
     {
         _interactors[interactor.Id] = interactor;
     }
 }