示例#1
0
        /// <summary>
        /// Function that converts the mirror class to the class that will be used at runtime.
        /// Cannot return null. If the input class is null, it returns a freshly generated BKI_GestureClass.
        /// </summary>
        private BKI_SingleGestureClass SerializeGesture(BKI_Hand h, BKI_GestureMirrorClass mirror)
        {
            BKI_SingleGestureClass returnVal = ScriptableObject.CreateInstance <BKI_SingleGestureClass>();

            if (mirror == null)
            {
                return(returnVal);
            }

            returnVal.SetValues(h, mirror.gestureIdentifier, mirror.requiresClench, mirror.fingerStates);

            return(returnVal);
        }
示例#2
0
        // Draws the base hand and the individual fingers dependent on selected values.
        private void DrawHandImages(BKI_Hand hand, BKI_GestureMirrorClass values, Rect pos, float scale = 1)
        {
            float flipValueWidth, flipValuePos;
            float valueHeight = 1 / scale;
            Rect  newPos      = pos;

            if (hand == BKI_Hand.right)
            {
                flipValueWidth = 1;
                flipValuePos   = 0;
                newPos.x      += 15;
            }
            else
            {
                flipValueWidth = -1;
                flipValuePos   = 1;
            }

            flipValueWidth /= scale;

            if (values.GetFingerState(BKI_Finger.thumb) == BKI_FingerState.FingerIgnored)
            {
                GUI.DrawTextureWithTexCoords(newPos, thumbHandCrossText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }
            else if (!(values.GetFingerState(BKI_Finger.thumb) == BKI_FingerState.fingerIn))
            {
                GUI.DrawTextureWithTexCoords(newPos, thumbHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }

            if (values.GetFingerState(BKI_Finger.index) == BKI_FingerState.FingerIgnored)
            {
                GUI.DrawTextureWithTexCoords(newPos, indexHandCrossText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }
            else if (!(values.GetFingerState(BKI_Finger.index) == BKI_FingerState.fingerIn))
            {
                GUI.DrawTextureWithTexCoords(newPos, indexHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }

            if (values.GetFingerState(BKI_Finger.middle) == BKI_FingerState.FingerIgnored)
            {
                GUI.DrawTextureWithTexCoords(newPos, middleHandCrossText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }
            else if (!(values.GetFingerState(BKI_Finger.middle) == BKI_FingerState.fingerIn))
            {
                GUI.DrawTextureWithTexCoords(newPos, middleHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }

            if (values.GetFingerState(BKI_Finger.ring) == BKI_FingerState.FingerIgnored)
            {
                GUI.DrawTextureWithTexCoords(newPos, ringHandCrossText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }
            else if (!(values.GetFingerState(BKI_Finger.ring) == BKI_FingerState.fingerIn))
            {
                GUI.DrawTextureWithTexCoords(newPos, ringHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }

            if (values.GetFingerState(BKI_Finger.pinky) == BKI_FingerState.FingerIgnored)
            {
                GUI.DrawTextureWithTexCoords(newPos, pinkyHandCrossText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }
            else if (!(values.GetFingerState(BKI_Finger.pinky) == BKI_FingerState.fingerIn))
            {
                GUI.DrawTextureWithTexCoords(newPos, pinkyHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
            }

            GUI.DrawTextureWithTexCoords(newPos, baseHandText2D, new Rect(flipValuePos, 0, flipValueWidth, valueHeight));
        }
示例#3
0
        // Draws the check boxes and their labels as seen in the tool UI.
        private void DrawBooleans(BKI_Hand hand)
        {
            BKI_GestureMirrorClass values = (hand == BKI_Hand.right) ? rightHandValues : leftHandValues;

            Rect containerRect = (hand == BKI_Hand.right) ? handGUIContainer : handGUIContainer;

            Rect r = new Rect(DEFAULT_AREA_PADDING + 5, TITLE_FIELD_SIZE + 2, containerRect.width - DEFAULT_AREA_PADDING * 1.5f, containerRect.height - DEFAULT_AREA_PADDING * 1.5f - TITLE_FIELD_SIZE);

            GUILayout.BeginArea(r);
            {
                // Parenthesis to clarify GUI layout at code side.
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.BeginVertical();
                    {
                        GUILayout.Label("Thumb: ");
                        GUILayout.Space(3);
                        GUILayout.Label("Index: ");
                        GUILayout.Space(3);
                        GUILayout.Label("Middle: ");
                        GUILayout.Space(3);
                        GUILayout.Label("Ring: ");
                        GUILayout.Space(3);
                        GUILayout.Label("Pinky: ");
                    }
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(-60);
                    EditorGUILayout.BeginVertical();
                    {
                        values.fingerStates[0] = (BKI_FingerState)GUILayout.Toolbar((int)values.fingerStates[0], toolbarText, GUILayout.Width(160));
                        values.fingerStates[1] = (BKI_FingerState)GUILayout.Toolbar((int)values.fingerStates[1], toolbarText, GUILayout.Width(160));
                        values.fingerStates[2] = (BKI_FingerState)GUILayout.Toolbar((int)values.fingerStates[2], toolbarText, GUILayout.Width(160));
                        values.fingerStates[3] = (BKI_FingerState)GUILayout.Toolbar((int)values.fingerStates[3], toolbarText, GUILayout.Width(160));
                        values.fingerStates[4] = (BKI_FingerState)GUILayout.Toolbar((int)values.fingerStates[4], toolbarText, GUILayout.Width(160));
                    }
                    EditorGUILayout.EndVertical();

                    //EditorGUILayout.BeginVertical();
                    //{
                    //	bool thumb = values.GetFingerPressed(BKI_Finger.thumb);
                    //	thumb = EditorGUILayout.Toggle(values.GetFingerPressed(BKI_Finger.thumb));
                    //	values.SetFingerPressed(BKI_Finger.thumb, thumb);

                    //	bool index = values.GetFingerPressed(BKI_Finger.index);
                    //	index = EditorGUILayout.Toggle(values.GetFingerPressed(BKI_Finger.index));
                    //	values.SetFingerPressed(BKI_Finger.index, index);

                    //	bool middle = values.GetFingerPressed(BKI_Finger.middle);
                    //	middle = EditorGUILayout.Toggle(values.GetFingerPressed(BKI_Finger.middle));
                    //	values.SetFingerPressed(BKI_Finger.middle, middle);

                    //	bool ring = values.GetFingerPressed(BKI_Finger.ring);
                    //	ring = EditorGUILayout.Toggle(values.GetFingerPressed(BKI_Finger.ring));
                    //	values.SetFingerPressed(BKI_Finger.ring, ring);

                    //	bool pinky = values.GetFingerPressed(BKI_Finger.pinky);
                    //	pinky = EditorGUILayout.Toggle(values.GetFingerPressed(BKI_Finger.pinky));
                    //	values.SetFingerPressed(BKI_Finger.pinky, pinky);
                    //}
                    //EditorGUILayout.EndVertical();

                    //EditorGUILayout.BeginVertical();
                    //{
                    //	GUILayout.Label("Ignore thumb: ");
                    //	GUILayout.Label("Ignore index: ");
                    //	GUILayout.Label("Ignore middle: ");
                    //	GUILayout.Label("Ignore ring: ");
                    //	GUILayout.Label("Ignore pinky: ");
                    //}
                    //EditorGUILayout.EndVertical();

                    //EditorGUILayout.BeginVertical();
                    //{
                    //	bool thumb = values.GetFingerIgnored(BKI_Finger.thumb);
                    //	thumb = EditorGUILayout.Toggle(values.GetFingerIgnored(BKI_Finger.thumb));
                    //	values.SetFingerIgnored(BKI_Finger.thumb, thumb);

                    //	bool index = values.GetFingerIgnored(BKI_Finger.index);
                    //	index = EditorGUILayout.Toggle(values.GetFingerIgnored(BKI_Finger.index));
                    //	values.SetFingerIgnored(BKI_Finger.index, index);

                    //	bool middle = values.GetFingerIgnored(BKI_Finger.middle);
                    //	middle = EditorGUILayout.Toggle(values.GetFingerIgnored(BKI_Finger.middle));
                    //	values.SetFingerIgnored(BKI_Finger.middle, middle);

                    //	bool ring = values.GetFingerIgnored(BKI_Finger.ring);
                    //	ring = EditorGUILayout.Toggle(values.GetFingerIgnored(BKI_Finger.ring));
                    //	values.SetFingerIgnored(BKI_Finger.ring, ring);

                    //	bool pinky = values.GetFingerIgnored(BKI_Finger.pinky);
                    //	pinky = EditorGUILayout.Toggle(values.GetFingerIgnored(BKI_Finger.pinky));
                    //	values.SetFingerIgnored(BKI_Finger.pinky, pinky);
                    //}
                    //EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndArea();

            if (hand == BKI_Hand.right)
            {
                if (rightHandValues != values && values.gestureIdentifier != pickerWindowGNameRh)
                {
                    ResetPickerWindow(false, true, false);
                    rightHandValues = values;
                }
            }
            else if (leftHandValues != values && values.gestureIdentifier != pickerWindowGNameLh)
            {
                ResetPickerWindow(true, false, false);
                leftHandValues = values;
            }
        }
示例#4
0
        // Draws one side of the tool.
        private void DrawHandGUI(BKI_Hand hand)
        {
            Rect r  = handGUIContainer;
            Rect r2 = handRect;

            if (hand == BKI_Hand.right)
            {
                r.x = r.x + (WINDOW_MAX_SIZE_X / 2) - 3;
            }

            r.width  += (DEFAULT_AREA_PADDING);
            r2.width += (DEFAULT_AREA_PADDING / 4);

            GUILayout.BeginArea(r);
            {
                GUI.DrawTexture(r2, containerHandTex2D);
                EditorGUILayout.BeginVertical();
                {
                    DrawHandTitle(hand);

                    DrawBooleans(hand);

                    GUILayout.Space(108);

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(12);
                        GUILayout.Label("Requires clench:");
                        ((hand == BKI_Hand.right) ? rightHandValues : leftHandValues).requiresClench = EditorGUILayout.Toggle(((hand == BKI_Hand.right) ? rightHandValues : leftHandValues).requiresClench);
                        GUILayout.Space(84);
                    }
                    EditorGUILayout.EndHorizontal();

                    BKI_GestureMirrorClass values = (hand == BKI_Hand.right) ? rightHandValues : leftHandValues;
                    DrawHandImages(hand, values, baseHandRect);

                    GUILayout.Space(WINDOW_MAX_SIZE_Y * 0.37f);

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(16);
                        EditorGUILayout.BeginVertical();
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                GUILayout.Label("Gesture identifier:");
                                ((hand == BKI_Hand.right) ? rightHandValues : leftHandValues).gestureIdentifier = EditorGUILayout.TextField(((hand == BKI_Hand.right) ? rightHandValues : leftHandValues).gestureIdentifier, GUILayout.Width(128));
                                GUILayout.Space(128);
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        DrawButtonsSingle(hand);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();
            }
            GUILayout.EndArea();
        }