public void OnGUI() { GUIStyle bb = new GUIStyle(); bb.normal.background = null; bb.normal.textColor = new Color(1, 0, 0); bb.fontSize = 30; if (m_hand.GetTrackingState() == ARTrackable.TrackingState.TRACKING) { GUI.Label(new Rect(0, 0, 200, 200), string.Format("GuestureType:{0}\n HandType:{1}\n" + " GuestureCoord:{2}\n SkeletonCoord:{3}", m_hand.GetGestureType(), m_hand.GetHandType(), m_hand.GetGestureCoordinateSystemType(), m_hand.GetSkeletonCoordinateSystemType()), bb); } }
private void _UpdateHandBox() { var handBox = m_hand.GetHandBox(); //The first one is the left top corner of the rectangle, and the second one is the right bottom corner if (handBox.Length < 2) { ARDebug.LogError("handbox's length is {0}", handBox.Length); return; } Vector3 glLeftTopCorner = handBox[0]; Vector3 glRightBottomCorner = handBox[1]; Vector3 glLeftBottomCorner = new Vector3(glLeftTopCorner.x, glRightBottomCorner.y); Vector3 glRightTopCorner = new Vector3(glRightBottomCorner.x, glLeftTopCorner.y); float glCenterX = (glLeftTopCorner.x + glRightTopCorner.x) / 2; float glCenterY = (glLeftTopCorner.y + glLeftBottomCorner.y) / 2; Vector3 glCenter = new Vector3(glCenterX, glCenterY); m_boxLineRenderer.SetPosition(0, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner)); m_boxLineRenderer.SetPosition(1, _TransferGLCoord2UnityWoldCoordWithDepth(glRightTopCorner)); m_boxLineRenderer.SetPosition(2, _TransferGLCoord2UnityWoldCoordWithDepth(glRightBottomCorner)); m_boxLineRenderer.SetPosition(3, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftBottomCorner)); m_boxLineRenderer.SetPosition(4, _TransferGLCoord2UnityWoldCoordWithDepth(glLeftTopCorner)); m_boxLineRenderer.material = (Material)Resources.Load("Line", typeof(Material)); m_boxLineRenderer.startColor = new Color(1, 0, 0, 1); m_boxLineRenderer.endColor = new Color(1, 0, 0, 1); m_boxLineRenderer.gameObject.SetActive(true); m_spider.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter)); m_lightBlast.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter)); m_bulbasaur.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter)); m_spiderColor.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter)); m_hwCube.transform.position = (_TransferGLCoord2UnityWoldCoordWithDepth(glCenter)); switch (m_hand.GetGestureType()) { case 0: _DonotShow3DObjects(); break; case 1: _DonotShow3DObjects(); m_spider.gameObject.SetActive(true); break; case 5: _DonotShow3DObjects(); m_lightBlast.gameObject.SetActive(true); break; case 6: _DonotShow3DObjects(); m_spiderColor.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); break; case 7: _DonotShow3DObjects(); m_hwCube.gameObject.SetActive(true); break; case 10: _DonotShow3DObjects(); m_bulbasaur.gameObject.SetActive(true); break; } }