예제 #1
0
        // ------------------
        public TouchGestureConfig()
        {
            this.maxTapCount   = 1;
            this.cleanTapsOnly = true;

            this.swipeOriginalDirResetMode = DirectionState.OriginalDirResetMode.On180;
        }
예제 #2
0
//private float buttonHeight = 40;
        // ---------------------
        protected void DrawJoystickConfigGUI(JoystickConfig target)
        {
            bool
                blockX           = target.blockX,
                blockY           = target.blockY,
                perAxisDeadzones = target.perAxisDeadzones;

            JoystickConfig.ClampMode
                clampMode = target.clampMode;
            //circularClamp	= target.circularClamp;
            JoystickConfig.StickMode
                stickMode = target.stickMode;
            DirectionState.OriginalDirResetMode
                originalDirResetMode = target.originalDirResetMode;
            JoystickConfig.DigitalDetectionMode
                digitalDetectionMode = target.digitalDetectionMode;

            float
                angularMagnet = target.angularMagnet;



            stickMode = (JoystickConfig.StickMode)CFGUI.EnumPopup(new GUIContent("Mode", "Joystick mode"), stickMode, 120);             // GUILayout.MinWidth(30));

            clampMode = (JoystickConfig.ClampMode)CFGUI.EnumPopup(new GUIContent("Vector Range", "Vector Range Mode"), clampMode, 120); //GUILayout.MinWidth(30));

            digitalDetectionMode = (JoystickConfig.DigitalDetectionMode)CFGUI.EnumPopup(new GUIContent("Digi. Detect. Mode", "Digital Detection Mode"),
                                                                                        digitalDetectionMode, 120);

            angularMagnet = CFGUI.Slider(new GUIContent("Digi. Angular Magnet", "Angular Magnet Strength used when changing digital direction. Higher value will make changing direction harder, which is recommended for Touch Digital Detection Mode."),
                                         angularMagnet, 0f, 1f, 100);



            if (stickMode == JoystickConfig.StickMode.Analog)
            {
                perAxisDeadzones = EditorGUILayout.ToggleLeft(new GUIContent("Per-Axis Analog Range", "Per-Axis deadzone, endzone and ramp transformations."),
                                                              perAxisDeadzones, GUILayout.MinWidth(30));
            }

            blockX = EditorGUILayout.ToggleLeft(new GUIContent("Block X"), blockX, GUILayout.MinWidth(30));
            blockY = EditorGUILayout.ToggleLeft(new GUIContent("Block Y"), blockY, GUILayout.MinWidth(30));

            originalDirResetMode = (DirectionState.OriginalDirResetMode)CFGUI.EnumPopup(new GUIContent("Dir. Reset Mode", "Original Direction Reset Mode - choose when original stick direction will be reset. This option is used mainly by the Direction Binding..."),
                                                                                        originalDirResetMode, 120); // GUILayout.MinWidth(30));



            if ((blockX != target.blockX) ||
                (blockY != target.blockY) ||
                (perAxisDeadzones != target.perAxisDeadzones) ||
                (clampMode != target.clampMode) ||
                (originalDirResetMode != target.originalDirResetMode) ||
                (digitalDetectionMode != target.digitalDetectionMode) ||
                (stickMode != target.stickMode) ||
                (angularMagnet != target.angularMagnet))
            {
                CFGUI.CreateUndo("Joy Config modification", this.undoObject);


                target.perAxisDeadzones = perAxisDeadzones;
                target.blockX           = blockX;
                target.blockY           = blockY;
                //target.circularClamp		= circularClamp;
                target.clampMode            = clampMode;
                target.stickMode            = stickMode;
                target.originalDirResetMode = originalDirResetMode;
                target.angularMagnet        = angularMagnet;
                target.digitalDetectionMode = digitalDetectionMode;

                CFGUI.EndUndo(this.undoObject);
            }
        }
        // ---------------
        public void DrawGUI(TouchGestureConfig config)
        {
            int
                maxTapCount = config.maxTapCount;
            bool
                cleanTapsOnly          = config.cleanTapsOnly,
                detectLongTap          = config.detectLongTap,
                detectLongPress        = config.detectLongPress,
                endLongPressWhenMoved  = config.endLongPressWhenMoved,
                endLongPressWhenSwiped = config.endLongPressWhenSwiped;

            TouchGestureConfig.DirMode
                dirMode = config.dirMode;
            TouchGestureConfig.DirConstraint
                swipeConstraint    = config.swipeConstraint,
                swipeDirConstraint = config.swipeDirConstraint,
                scrollConstraint   = config.scrollConstraint;
            DirectionState.OriginalDirResetMode
                swipeOriginalDirResetMode = config.swipeOriginalDirResetMode;



            // GUI...


            InspectorUtils.BeginIndentedSection(this.titleContent);

            maxTapCount = CFGUI.IntSlider(new GUIContent("Max Number of Taps", "Maximal number of consecutive taps to detect.\nWhen \'Report All Taps\' option is turned off, system will wait for potential follow-up taps so they may be reported with slight delay."),
                                          maxTapCount, 0, 5, LABEL_WIDTH);

            dirMode = (TouchGestureConfig.DirMode)CFGUI.EnumPopup(new GUIContent("Swipe Dir. Mode", "Swipe Segmwnt Direction Mode"), dirMode, LABEL_WIDTH);

            swipeOriginalDirResetMode = (DirectionState.OriginalDirResetMode)CFGUI.EnumPopup(new GUIContent("Swipe Dir. Reset Mode", "Swipe Segment's Original Direction Reset Mode - choose when original direction is reset. This option is used by Direction Binding in ORIGINAL group modes..."),
                                                                                             swipeOriginalDirResetMode, LABEL_WIDTH);

            swipeDirConstraint = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Scroll Dir Constraint", "Scroll Direction Constraint Mode"), swipeDirConstraint, LABEL_WIDTH);
            swipeConstraint    = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Swipe Constraint", "Swipe Constraint Mode"), swipeConstraint, LABEL_WIDTH);
            scrollConstraint   = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Scroll Constraint", "Scroll Constraint Mode"), scrollConstraint, LABEL_WIDTH);

            cleanTapsOnly = EditorGUILayout.ToggleLeft(new GUIContent("Clean Taps Only", "When turned on, only clean taps will be reported."),
                                                       cleanTapsOnly);

            detectLongPress = EditorGUILayout.ToggleLeft(new GUIContent("Detect Long Press",
                                                                        "Long Press is a static touch (tap threshold) pressed for some time (Long Press Min. Duration)."),
                                                         detectLongPress);

            if (detectLongPress)
            {
                detectLongTap = EditorGUILayout.ToggleLeft(new GUIContent("Detect Long Tap", ""),
                                                           detectLongTap);


                endLongPressWhenMoved = EditorGUILayout.ToggleLeft(new GUIContent("End Long Press When Moved", "End Long Press (and start Normal Press) when touch moved past the Tap Threshold."),
                                                                   endLongPressWhenMoved);
                endLongPressWhenSwiped = EditorGUILayout.ToggleLeft(new GUIContent("End Long Press When Swiped", "End Long Press (and start Normal Press) when touch moved past the Swipe Threshold."),
                                                                    endLongPressWhenSwiped);
            }

            InspectorUtils.EndIndentedSection();


            // Register Undo...

            if ((maxTapCount != config.maxTapCount) ||
                (cleanTapsOnly != config.cleanTapsOnly) ||
                (detectLongTap != config.detectLongTap) ||
                (detectLongPress != config.detectLongPress) ||
                (dirMode != config.dirMode) ||
                (swipeConstraint != config.swipeConstraint) ||
                (swipeDirConstraint != config.swipeDirConstraint) ||
                (scrollConstraint != config.scrollConstraint) ||
                (swipeOriginalDirResetMode != config.swipeOriginalDirResetMode) ||
                (endLongPressWhenSwiped != config.endLongPressWhenSwiped) ||
                (endLongPressWhenMoved != config.endLongPressWhenMoved))
            {
                CFGUI.CreateUndo("Gesture Config modification", this.undoObject);

                config.dirMode            = dirMode;
                config.swipeConstraint    = swipeConstraint;
                config.swipeDirConstraint = swipeDirConstraint;
                config.scrollConstraint   = scrollConstraint;

                config.maxTapCount               = maxTapCount;
                config.cleanTapsOnly             = cleanTapsOnly;
                config.detectLongPress           = detectLongPress;
                config.detectLongTap             = detectLongTap;
                config.endLongPressWhenMoved     = endLongPressWhenMoved;
                config.endLongPressWhenSwiped    = endLongPressWhenSwiped;
                config.swipeOriginalDirResetMode = swipeOriginalDirResetMode;


                CFGUI.EndUndo(this.undoObject);
            }
        }