// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Collections.Generic; using System.Text; using TMPro; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics.Examples { /// /// Writes collider trigger from articulated hands events to a TextMeshPro object /// public class PhysicsTriggerEventReadout : MonoBehaviour { [SerializeField] [Tooltip("TextMeshPro object that will write the events")] private TextMeshPro textField; /// /// TextMeshPro object that will write the events /// public TextMeshPro TextField { get { return textField; } set { textField = value; } } //private List currentJoints = new List(); private void OnTriggerEnter(Collider other) { //JointKinematicBody joint = other.GetComponent(); //if (joint == null) { return; } //currentJoints.Add(joint); //WriteText(); } private void OnTriggerExit(Collider other) { //JointKinematicBody joint = other.GetComponent(); //if (joint == null) { return; } //if (currentJoints.Contains(joint)) //{ // currentJoints.Remove(joint); //} //else //{ // currentJoints.Add(joint); // WriteText(); // currentJoints.Remove(joint); //} //if (currentJoints.Count <= 0) //{ // WriteText(true); //} } private void WriteText(bool clear = false) { if (textField == null) { return; } if (clear) { textField.text = ""; return; } StringBuilder text = new StringBuilder(); //foreach (var joint in currentJoints) //{ // text.Append(joint.name + " is touching.
"); //} //textField.text = text + "
"; } } }