Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Disabled StatefulInteractable are interactable after set SpeechRecognitionKeyword or AllowSelectByVoice #591

Closed
anonymous2585 opened this issue Dec 19, 2023 · 1 comment · Fixed by #608
Assignees
Labels
Package: Core The Project core package is impacted by this issue. Priority: Medium The priority of the issue is medium. Type: Bug A problem with an existing feature that can be fixed with the next patched release.

Comments

@anonymous2585
Copy link
Contributor

Describe the bug

When setting the properties SpeechRecognitionKeyword or AllowSelectByVoice of a disabled StatefulInteractable, a warning is triggered and the interactable starts again to trigger clicks events even though it's disabled.

This is due to the button unregister and register back to the interaction manager.

To reproduce

Steps to reproduce the behavior:

  1. Open the CanvasExample scene
  2. Choose one of the "Action Button" and add this script:
using MixedReality.Toolkit;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(StatefulInteractable))]
public class VoiceRuntimeChange : MonoBehaviour
{
    private IEnumerator Start()
    {
        StatefulInteractable interactable = GetComponent<StatefulInteractable>();
        interactable.OnClicked.AddListener(OnClicked);
        interactable.enabled = false;
        yield return new WaitForSeconds(1.0f);
        interactable.SpeechRecognitionKeyword = "Hello world"; // trigger a warning and the button is enabled
        yield return new WaitForSeconds(1.0f);
        interactable.AllowSelectByVoice = false; // the button is enabled
    }

    private void OnClicked()
    {
        Debug.Log("Button clicked");
    }
}
  1. Press Play
  2. Wait 1 second and see the warning
  3. Click on the button and see the debug log triggered

Expected behavior

The interactable is doesn't trigger the warning and doesn't trigger click events

Your setup

  • Unity Version: 2021.3.21f1
  • MRTK Version or Commit: current main branch ec5c141

Target platform

  • HoloLens 2
  • OpenXR

Additional context

The fix is to check

if (Application.isPlaying && isActiveAndEnabled)

before unregister and register the interactable. This will also fix editor script using these properties.
The interactable will register himself on enable (in unity XRI code).

Side note: why is VoiceRequiresFocus private set? I needed to set it from code but I couldn't.

@anonymous2585 anonymous2585 added Needs: Triage Needs to be triaged. Type: Bug A problem with an existing feature that can be fixed with the next patched release. labels Dec 19, 2023
@AMollis AMollis added Priority: Medium The priority of the issue is medium. and removed Needs: Triage Needs to be triaged. labels Jan 2, 2024
@AMollis
Copy link
Contributor

AMollis commented Jan 2, 2024

Hi @anonymous2585 ,

Thank you for reporting this issue or requesting this feature. We appreciate your feedback and interest in MRTK3.

We have reviewed your issue or feature request and confirmed that it is valid. We have added it to our backlog and will prioritize it accordingly.

However, if you would like to speed up the process and contribute to the MRTK3 project, you are welcome to submit a Pull Request with your proposed fix or implementation. We would be happy to review your code and merge it into the main branch if it meets our quality standards.

Please let us know if you have any questions or need any assistance. Thank you for your support and collaboration.

Best regards,
The MRTK3 team

anonymous2585 pushed a commit to anonymous2585/MixedRealityToolkit-Unity that referenced this issue Jan 9, 2024
…r changing speech settings (MixedRealityToolkit#591)

+ Add tests
+ Make VoiceRequiresFocus public
@shaynie shaynie added the Package: Core The Project core package is impacted by this issue. label Jan 11, 2024
shaynie pushed a commit that referenced this issue Jan 12, 2024
…r changing speech settings (#591) (#608)

+ Add tests
+ Make VoiceRequiresFocus public

Co-authored-by: Anonymous <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: Core The Project core package is impacted by this issue. Priority: Medium The priority of the issue is medium. Type: Bug A problem with an existing feature that can be fixed with the next patched release.
Projects
None yet
4 participants