// ------------------
        public void Draw(ScrollDeltaBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();

            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);

                this.deltaBinding.Draw(bind.deltaBinding, rig);
                this.positiveDigitalBinding.Draw(bind.positiveDigitalBinding, rig);
                this.negativeDigitalBinding.Draw(bind.negativeDigitalBinding, rig);


                CFGUI.EndIndentedVertical();

                GUILayout.Space(InputBindingGUIUtils.VERT_MARGIN);
            }

            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled))
            {
                CFGUI.CreateUndo("Scroll Delta Binding modification.", this.undoObject);

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
        static public bool BeginIndentedSection(GUIContent sectionTitle, ref bool foldedOut)
        {
            if (!CFGUI.BoldFoldout(sectionTitle, ref foldedOut))
            {
                return(false);
            }

            CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);

            return(true);
        }
Example #3
0
        // -------------------
        public void DrawGUI(AnalogConfig target)
        {
            EditorGUILayout.BeginVertical();

            if (!string.IsNullOrEmpty(this.titleContent.text))
            {
//EditorGUILayout.LabelField("Fodable: " + this.isFoldable  + " Folded:" + this.isFoldedOut);

                if (this.isFoldable)
                {
                    InspectorUtils.DrawSectionHeader(this.titleContent, ref this.isFoldedOut);
                }
                else
                {
                    EditorGUILayout.LabelField(this.titleContent, CFEditorStyles.Inst.boldText, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));
                    this.isFoldedOut = true;
                }
            }
            else
            {
                this.isFoldedOut = true;
            }


            if (this.isFoldedOut)
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);

                JoystickConfig joyConfig = target as JoystickConfig;
                if (joyConfig != null)
                {
                    this.DrawJoystickConfigGUI(joyConfig);
                }

                this.DrawAnalogConfigGUI(target);

                CFGUI.EndIndentedVertical();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }
Example #4
0
            // --------------------
            virtual public bool DrawGUI()
            {
                bool retVal = true;

                EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpBevelBG);

                this.DrawDefaultLabel();

                this.DrawExtraHeaderGUI();

                this.DrawDefaultButtons();

                EditorGUILayout.EndHorizontal();

                if (this.isFoldedOut && retVal)
                {
                    CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);
                    this.DrawGUIContent();
                    CFGUI.EndIndentedVertical();
                }

                return(retVal);
            }
        static public void BeginIndentedSection(GUIContent sectionTitle)
        {
            EditorGUILayout.LabelField(sectionTitle, CFEditorStyles.Inst.boldText, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

            CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);
        }
 // -----------------
 static public void BeginIndentedSection()
 {
     CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);
 }
Example #7
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchButton c = (TouchButton)this.target;

            GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerButton, GUILayout.ExpandWidth(true));

            this.DrawWarnings(c);


            bool
                toggle = c.toggle,
                linkToggleToRigSwitch = c.linkToggleToRigSwitch,
                autoToggleOff         = c.autoToggleOff,
                toggleOffWhenHiding   = c.toggleOffWhenHiding;
            float
                autoToggleOffTimeOut = c.autoToggleOffTimeOut;

            TouchButton.ToggleOnAction
                toggleOnAction = c.toggleOnAction;
            TouchButton.ToggleOffAction
                toggleOffAction = c.toggleOffAction;
            string
                toggleRigSwitchName = c.toggleRigSwitchName;

            this.emulateTouchPressure = c.emulateTouchPressure;

            // Button specific inspector....



            const float LABEL_WIDTH = 110;


            InspectorUtils.BeginIndentedSection(new GUIContent("Toggle Settings"));

            toggle = EditorGUILayout.ToggleLeft(new GUIContent("Toggle Mode", "Enable toggle mode."),
                                                toggle);

            if (toggle)
            {
                CFGUI.BeginIndentedVertical();

                toggleOnAction = (TouchButton.ToggleOnAction)CFGUI.EnumPopup(new GUIContent("Toggle On Action", "Select when toggle state should change from OFF to ON."),
                                                                             toggleOnAction, LABEL_WIDTH);
                toggleOffAction = (TouchButton.ToggleOffAction)CFGUI.EnumPopup(new GUIContent("Toggle Off Action", "Select when toggle state should change from ON to OFF."),
                                                                               toggleOffAction, LABEL_WIDTH);

                if (toggleOffAction != TouchButton.ToggleOffAction.OnTimeout)
                {
                    autoToggleOff = EditorGUILayout.ToggleLeft(new GUIContent("Auto Toggle Off", "When enabled, this button will auto-toggle off itself after specified amount of time."),
                                                               autoToggleOff);
                }

                if (autoToggleOff || toggleOffAction == TouchButton.ToggleOffAction.OnTimeout)
                {
                    CFGUI.BeginIndentedVertical();

                    autoToggleOffTimeOut = CFGUI.FloatFieldEx(new GUIContent("Timeout (ms)", "Auto-toggle off time-out in milliseconds."),
                                                              autoToggleOffTimeOut, 0.1f, 1000, 1000, true, LABEL_WIDTH);

                    CFGUI.EndIndentedVertical();
                }

                linkToggleToRigSwitch = EditorGUILayout.ToggleLeft(new GUIContent("Link toggle to Rig Switch", "Links this toggle button to Rig Switch's state.\nExternal modification to assigned flag will also affect this button's toggle state!"),
                                                                   linkToggleToRigSwitch);

                if (linkToggleToRigSwitch)
                {
                    CFGUI.BeginIndentedVertical();

                    toggleRigSwitchName = this.toggleRigSwitchInsp.Draw("Switch", toggleRigSwitchName, c.rig, 50);

                    toggleOffWhenHiding = EditorGUILayout.ToggleLeft(new GUIContent("Turn the Switch Off when hiding", "When enabled, this button will turn off linked Rig Switch when hidden."),
                                                                     toggleOffWhenHiding);

                    CFGUI.EndIndentedVertical();
                }



                CFGUI.EndIndentedVertical();
            }

            InspectorUtils.EndIndentedSection();



            InspectorUtils.BeginIndentedSection(new GUIContent("Button Bindings"));


            this.pressBindingInsp.Draw(c.pressBinding, c.rig);
            this.touchPressureBindingInsp.Draw(c.touchPressureBinding, c.rig);

            if (toggle)
            {
                this.toggleBindingInsp.Draw(c.toggleOnlyBinding, c.rig);
            }

            InspectorUtils.EndIndentedSection();


            // Register undo...

            if ((toggle != c.toggle) ||
                (linkToggleToRigSwitch != c.linkToggleToRigSwitch) ||
                (toggleOnAction != c.toggleOnAction) ||
                (toggleOffAction != c.toggleOffAction) ||
                (autoToggleOff != c.autoToggleOff) ||
                (autoToggleOffTimeOut != c.autoToggleOffTimeOut) ||
                (this.emulateTouchPressure != c.emulateTouchPressure) ||
                (toggleOffWhenHiding != c.toggleOffWhenHiding) ||
                (toggleRigSwitchName != c.toggleRigSwitchName))
            {
                CFGUI.CreateUndo("CF2 Button modification", c);

                c.toggle = toggle;
                c.linkToggleToRigSwitch = linkToggleToRigSwitch;
                c.toggleOnAction        = toggleOnAction;
                c.toggleOffAction       = toggleOffAction;
                c.toggleRigSwitchName   = toggleRigSwitchName;
                c.autoToggleOff         = autoToggleOff;
                c.autoToggleOffTimeOut  = autoToggleOffTimeOut;
                c.toggleOffWhenHiding   = toggleOffWhenHiding;
                c.emulateTouchPressure  = this.emulateTouchPressure;


                CFGUI.EndUndo(c);
            }


            // Draw Shared Dynamic Control Params...

            this.DrawDynamicTouchControlGUI(c);
        }
Example #8
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchJoystickSpriteAnimator target = this.target as TouchJoystickSpriteAnimator;

            if ((target == null))
            {
                return;
            }



            if (!TouchControlSpriteAnimatorInspector.DrawSourceGUI(target))
            {
                return;
            }


            TouchJoystickSpriteAnimator.SpriteMode
                spriteMode = target.spriteMode;
            TouchJoystickSpriteAnimator.RotationMode
                rotationMode = target.rotationMode;
            float
                simpleRotationRange      = target.simpleRotationRange,
                rotationSmoothingTime    = target.rotationSmoothingTime,
                translationSmoothingTime = target.translationSmoothingTime;
            Vector2
                moveScale = target.moveScale;
            bool
                animateTransl = target.animateTransl;


            if (target.sourceControl == null)
            {
            }
            else
            {
                InspectorUtils.BeginIndentedSection(new GUIContent("Sprite Settings"));

                spriteMode = (TouchJoystickSpriteAnimator.SpriteMode)EditorGUILayout.EnumPopup(new GUIContent("Sprite Mode", ""),
                                                                                               spriteMode, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

                this.spriteNeutral.Draw(target.spriteNeutral, target, true, false);

                EditorGUILayout.Space();                this.spriteNeutralPressed.Draw(target.spriteNeutralPressed, target, target.IsIllegallyAttachedToSource());

                if (spriteMode >= TouchJoystickSpriteAnimator.SpriteMode.FourWay)
                {
                    EditorGUILayout.Space();                this.spriteUp.Draw(target.spriteUp, target, target.IsIllegallyAttachedToSource());

                    if (spriteMode >= TouchJoystickSpriteAnimator.SpriteMode.EightWay)
                    {
                        EditorGUILayout.Space();        this.spriteUpRight.Draw(target.spriteUpRight, target, target.IsIllegallyAttachedToSource());
                    }

                    EditorGUILayout.Space();                this.spriteRight.Draw(target.spriteRight, target, target.IsIllegallyAttachedToSource());

                    if (spriteMode >= TouchJoystickSpriteAnimator.SpriteMode.EightWay)
                    {
                        EditorGUILayout.Space();        this.spriteDownRight.Draw(target.spriteDownRight, target, target.IsIllegallyAttachedToSource());
                    }

                    EditorGUILayout.Space();                this.spriteDown.Draw(target.spriteDown, target, target.IsIllegallyAttachedToSource());

                    if (spriteMode >= TouchJoystickSpriteAnimator.SpriteMode.EightWay)
                    {
                        EditorGUILayout.Space();        this.spriteDownLeft.Draw(target.spriteDownLeft, target, target.IsIllegallyAttachedToSource());
                    }

                    EditorGUILayout.Space();                this.spriteLeft.Draw(target.spriteLeft, target, target.IsIllegallyAttachedToSource());

                    if (spriteMode >= TouchJoystickSpriteAnimator.SpriteMode.EightWay)
                    {
                        EditorGUILayout.Space();        this.spriteUpLeft.Draw(target.spriteUpLeft, target, target.IsIllegallyAttachedToSource());
                    }
                }

                InspectorUtils.EndIndentedSection();
            }


            InspectorUtils.BeginIndentedSection(new GUIContent("Transform Animation Settings"));



            animateTransl = EditorGUILayout.ToggleLeft(new GUIContent("Animate Translation"),
                                                       animateTransl, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

            if (animateTransl)
            {
                CFGUI.BeginIndentedVertical();

                moveScale.x = CFGUI.Slider(new GUIContent("X Move. Scale", "Horizontal Movement scale"), moveScale.x, 0, 2, 50);
                moveScale.y = CFGUI.Slider(new GUIContent("Y Move. Scale", "Vertical Movement scale"), moveScale.y, 0, 2, 50);

                translationSmoothingTime = CFGUI.FloatFieldEx(new GUIContent("Smooting Time (ms)", "Translation Smooting Time in milliseconds"),
                                                              translationSmoothingTime, 0, 10, 1000, true, 120);

                CFGUI.EndIndentedVertical();
            }


            EditorGUILayout.Space();

            rotationMode = (TouchJoystickSpriteAnimator.RotationMode)CFGUI.EnumPopup(new GUIContent("Rotation Animation Mode", "How rotation should be animated..."),
                                                                                     rotationMode, 150);

            if (rotationMode != TouchJoystickSpriteAnimator.RotationMode.Disabled)
            {
                CFGUI.BeginIndentedVertical();

                if ((rotationMode == TouchJoystickSpriteAnimator.RotationMode.SimpleHorizontal) ||
                    (rotationMode == TouchJoystickSpriteAnimator.RotationMode.SimpleVertical))
                {
                    simpleRotationRange = CFGUI.Slider(new GUIContent("Rotation Range"),
                                                       simpleRotationRange, -360, 360, 120);
                }

                rotationSmoothingTime = CFGUI.FloatFieldEx(new GUIContent("Smooting Time (ms)", "Rotation Smooting Time in milliseconds"),
                                                           rotationSmoothingTime, 0, 10, 1000, true, 120);

                CFGUI.EndIndentedVertical();
            }

            EditorGUILayout.Space();

//			TouchControlSpriteAnimatorInspector.DrawScaleGUI(target);



            InspectorUtils.EndIndentedSection();



            // Register Undo...

            if ((spriteMode != target.spriteMode) ||
                (simpleRotationRange != target.simpleRotationRange) ||
                (rotationSmoothingTime != target.rotationSmoothingTime) ||
                (translationSmoothingTime != target.translationSmoothingTime) ||
                (rotationMode != target.rotationMode) ||
                (moveScale != target.moveScale) ||
                (animateTransl != target.animateTransl))
            {
                CFGUI.CreateUndo("Joystick Sprite Animator modification", target);



                target.spriteMode               = spriteMode;
                target.simpleRotationRange      = simpleRotationRange;
                target.rotationSmoothingTime    = rotationSmoothingTime;
                target.translationSmoothingTime = translationSmoothingTime;
                target.rotationMode             = rotationMode;
                target.moveScale     = moveScale;
                target.animateTransl = animateTransl;


                CFGUI.EndUndo(target);
            }
        }
Example #9
0
        // ------------------
        public void Draw(DirectionBinding bind, InputRig rig)
        {
            bool
                bindingEnabled = bind.enabled,
                bindDiagonals  = bind.bindDiagonals;

            DirectionBinding.BindMode
                bindMode = bind.bindMode;

            EditorGUILayout.BeginVertical();

            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);

                if (this.customPreGUI != null)
                {
                    this.customPreGUI();
                }

                bindMode = (DirectionBinding.BindMode)CFGUI.EnumPopup(new GUIContent("Bind mode"),
                                                                      bindMode, 70);

                bindDiagonals = EditorGUILayout.ToggleLeft(new GUIContent("Bind diagonals",
                                                                          "Bind diagonal directions separately. When turned off, diagonal directions are translated into combinations of main directions."),
                                                           bindDiagonals, GUILayout.MinWidth(30));

                EditorGUILayout.Space();

                this.dirN.Draw(bind.dirBindingN, rig);
                this.dirAny.Draw(bind.dirBindingAny, rig);

                this.dirU.Draw(bind.dirBindingU, rig);
                if (bindDiagonals)
                {
                    this.dirUR.Draw(bind.dirBindingUR, rig);
                }

                this.dirR.Draw(bind.dirBindingR, rig);
                if (bindDiagonals)
                {
                    this.dirDR.Draw(bind.dirBindingDR, rig);
                }

                this.dirD.Draw(bind.dirBindingD, rig);
                if (bindDiagonals)
                {
                    this.dirDL.Draw(bind.dirBindingDL, rig);
                }

                this.dirL.Draw(bind.dirBindingL, rig);
                if (bindDiagonals)
                {
                    this.dirUL.Draw(bind.dirBindingUL, rig);
                }

                CFGUI.EndIndentedVertical();

                GUILayout.Space(InputBindingGUIUtils.VERT_MARGIN);
            }

            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled) ||
                (bindMode != bind.bindMode) ||
                (bindDiagonals != bind.bindDiagonals))
            {
                CFGUI.CreateUndo("Direction Binding modification.", this.undoObject);

                bind.enabled       = bindingEnabled;
                bind.bindDiagonals = bindDiagonals;
                bind.bindMode      = bindMode;

                CFGUI.EndUndo(this.undoObject);
            }
        }
            // -------------------
            public void DrawConfigGUI(ControlFreak2.SuperTouchZone.MultiFingerTouchConfig config)
            {
                //if (!CFGUI.BoldFoldout(this.configTitleContent, ref this.configFoldedOut))
                //	return;

                InspectorUtils.BeginIndentedSection(this.configTitleContent);

                //CFGUI.BeginIndentedVerticalCFEditorStyles.Inst.boldText);

                bool
                    driveOtherControl = config.driveOtherControl;
                //swipeToDrive		= config.swipeToDrive;
                //useSwipeJoystick	= config.useSwipeJoystick;
                TouchControl
                //controlToDrive				= config.controlToDrive;
                    controlToDriveOnRawPress    = config.controlToDriveOnRawPress,
                    controlToDriveOnNormalPress = config.controlToDriveOnNormalPress,
                    controlToDriveOnLongPress   = config.controlToDriveOnLongPress,

                    controlToDriveOnNormalPressSwipe  = config.controlToDriveOnNormalPressSwipe,
                    controlToDriveOnNormalPressSwipeU = config.controlToDriveOnNormalPressSwipeU,
                    controlToDriveOnNormalPressSwipeR = config.controlToDriveOnNormalPressSwipeR,
                    controlToDriveOnNormalPressSwipeD = config.controlToDriveOnNormalPressSwipeD,
                    controlToDriveOnNormalPressSwipeL = config.controlToDriveOnNormalPressSwipeL,

                    controlToDriveOnLongPressSwipe  = config.controlToDriveOnLongPressSwipe,
                    controlToDriveOnLongPressSwipeU = config.controlToDriveOnLongPressSwipeU,
                    controlToDriveOnLongPressSwipeR = config.controlToDriveOnLongPressSwipeR,
                    controlToDriveOnLongPressSwipeD = config.controlToDriveOnLongPressSwipeD,
                    controlToDriveOnLongPressSwipeL = config.controlToDriveOnLongPressSwipeL;


                //InspectorUtils.BeginIndentedSection(GUIContent.none); //this.configTitleContent);

                //CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);



                this.touchGestureConfigInsp.DrawGUI(config.touchConfig);

                EditorGUILayout.Space();

                //useSwipeJoystick = EditorGUILayout.ToggleLeft(new GUIContent("Use Swipe Joystick", "When enabled, this option gives access to virtual joystick controlled by swiping."),
                //	useSwipeJoystick);

                //if (useSwipeJoystick)
                this.swipeJoyConfigInsp.DrawGUI(config.swipeJoyConfig);

                EditorGUILayout.Space();


                driveOtherControl = EditorGUILayout.ToggleLeft(new GUIContent(" Drive other control", "Use this multi-finger touch to drive other touch control, like joystick or even other touch zone!"),
                                                               driveOtherControl, CFEditorStyles.Inst.boldText);

                if (driveOtherControl)
                {
                    CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);

                    //swipeToDrive = EditorGUILayout.ToggleLeft(new GUIContent("Swipe to drive", "Swipe first to drive other control. This option is useful for joysticks, as it allows to detect many static gestures such as tap without activating the joystick."),
                    //	swipeToDrive);


                    controlToDriveOnRawPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Raw Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                               controlToDriveOnRawPress, typeof(TouchControl), 150);

                    if (controlToDriveOnRawPress == null)
                    {
                        controlToDriveOnNormalPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Normal Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                      controlToDriveOnNormalPress, typeof(TouchControl), 150);

                        if (config.touchConfig.detectLongPress)
                        {
                            controlToDriveOnLongPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Long Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                        controlToDriveOnLongPress, typeof(TouchControl), 150);
                        }

                        controlToDriveOnNormalPressSwipe = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe in Any dir. (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                           controlToDriveOnNormalPressSwipe, typeof(TouchControl), 150);

                        if (controlToDriveOnNormalPressSwipe == null)
                        {
                            controlToDriveOnNormalPressSwipeU = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Up (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                controlToDriveOnNormalPressSwipeU, typeof(TouchControl), 150);
                            controlToDriveOnNormalPressSwipeR = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Right (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                controlToDriveOnNormalPressSwipeR, typeof(TouchControl), 150);
                            controlToDriveOnNormalPressSwipeD = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Down (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                controlToDriveOnNormalPressSwipeD, typeof(TouchControl), 150);
                            controlToDriveOnNormalPressSwipeL = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Left (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                controlToDriveOnNormalPressSwipeL, typeof(TouchControl), 150);
                        }

                        if (config.touchConfig.detectLongPress)
                        {
                            controlToDriveOnLongPressSwipe = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe in Any dir. (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                             controlToDriveOnLongPressSwipe, typeof(TouchControl), 120);

                            if (controlToDriveOnLongPressSwipe == null)
                            {
                                controlToDriveOnLongPressSwipeU = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Up (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                  controlToDriveOnLongPressSwipeU, typeof(TouchControl), 120);
                                controlToDriveOnLongPressSwipeR = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Right (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                  controlToDriveOnLongPressSwipeR, typeof(TouchControl), 120);
                                controlToDriveOnLongPressSwipeD = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Down (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                  controlToDriveOnLongPressSwipeD, typeof(TouchControl), 120);
                                controlToDriveOnLongPressSwipeL = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Left (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."),
                                                                                                  controlToDriveOnLongPressSwipeL, typeof(TouchControl), 120);
                            }
                        }
                    }


                    CFGUI.EndIndentedVertical();
                }


                //EditorGUILayout.Space();


                InspectorUtils.EndIndentedSection();


                // Register Undo...


                if ((driveOtherControl != config.driveOtherControl) ||
                    //(swipeToDrive		!= config.swipeToDrive) ||
                    //(controlToDrive		!= config.controlToDrive) )
                    (controlToDriveOnRawPress != config.controlToDriveOnRawPress) ||
                    (controlToDriveOnNormalPress != config.controlToDriveOnNormalPress) ||
                    (controlToDriveOnLongPress != config.controlToDriveOnLongPress) ||

                    (controlToDriveOnNormalPressSwipe != config.controlToDriveOnNormalPressSwipe) ||
                    (controlToDriveOnNormalPressSwipeU != config.controlToDriveOnNormalPressSwipeU) ||
                    (controlToDriveOnNormalPressSwipeR != config.controlToDriveOnNormalPressSwipeR) ||
                    (controlToDriveOnNormalPressSwipeD != config.controlToDriveOnNormalPressSwipeD) ||
                    (controlToDriveOnNormalPressSwipeL != config.controlToDriveOnNormalPressSwipeL) ||

                    (controlToDriveOnLongPressSwipe != config.controlToDriveOnLongPressSwipe) ||
                    (controlToDriveOnLongPressSwipeU != config.controlToDriveOnLongPressSwipeU) ||
                    (controlToDriveOnLongPressSwipeR != config.controlToDriveOnLongPressSwipeR) ||
                    (controlToDriveOnLongPressSwipeD != config.controlToDriveOnLongPressSwipeD) ||
                    (controlToDriveOnLongPressSwipeL != config.controlToDriveOnLongPressSwipeL)
                    )
                //||    (useSwipeJoystick	!= config.useSwipeJoystick))
                {
                    CFGUI.CreateUndo("Multi-finger touch config mod.", this.touchZone);

                    config.driveOtherControl = driveOtherControl;
                    //config.swipeToDrive			= swipeToDrive;
                    //config.controlToDrive		= controlToDrive;
                    //config.useSwipeJoystick		= useSwipeJoystick;
                    config.controlToDriveOnRawPress    = controlToDriveOnRawPress;
                    config.controlToDriveOnNormalPress = controlToDriveOnNormalPress;
                    config.controlToDriveOnLongPress   = controlToDriveOnLongPress;

                    config.controlToDriveOnNormalPressSwipe  = controlToDriveOnNormalPressSwipe;
                    config.controlToDriveOnNormalPressSwipeU = controlToDriveOnNormalPressSwipeU;
                    config.controlToDriveOnNormalPressSwipeR = controlToDriveOnNormalPressSwipeR;
                    config.controlToDriveOnNormalPressSwipeD = controlToDriveOnNormalPressSwipeD;
                    config.controlToDriveOnNormalPressSwipeL = controlToDriveOnNormalPressSwipeL;

                    config.controlToDriveOnLongPressSwipe  = controlToDriveOnLongPressSwipe;
                    config.controlToDriveOnLongPressSwipeU = controlToDriveOnLongPressSwipeU;
                    config.controlToDriveOnLongPressSwipeR = controlToDriveOnLongPressSwipeR;
                    config.controlToDriveOnLongPressSwipeD = controlToDriveOnLongPressSwipeD;
                    config.controlToDriveOnLongPressSwipeL = controlToDriveOnLongPressSwipeL;

                    CFGUI.EndUndo(this.touchZone);
                }
            }
        // ------------------
        public void Draw(AxisBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();

            bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30));


            if (bindingEnabled)
            {
                if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add target"), CFEditorStyles.Inst.iconButtonStyle))                 //, GUILayout.Width(20), GUILayout.Height(20)))
                {
                    CFGUI.CreateUndo("Add new target to Analog Binding.", this.undoObject);
                    bind.AddTarget();
                    CFGUI.EndUndo(this.undoObject);
                }

                if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove target"), CFEditorStyles.Inst.iconButtonStyle))                 //, GUILayout.Width(20), GUILayout.Height(20)))
                {
                    CFGUI.CreateUndo("Remove target from Analog Binding.", this.undoObject);
                    bind.RemoveLastTarget();
                    CFGUI.EndUndo(this.undoObject);
                }
            }


            EditorGUILayout.EndHorizontal();

            if (bindingEnabled)
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);


                if (this.customExtraGUI != null)
                {
                    this.customExtraGUI();
                }


                this.PrepareTargetElemListInspectors(bind.targetList.Count);

                if (bind.targetList.Count == 0)
                {
                    EditorGUILayout.LabelField("No targets defined...", CFEditorStyles.Inst.centeredTextTranspBG);
                }
                else
                {
                    for (int i = 0; i < bind.targetList.Count; ++i)
                    {
                        this.targetElemInspList[i].DrawGUI(bind.targetList[i], rig, (i == (bind.targetList.Count - 1)));
                    }
                }

                CFGUI.EndIndentedVertical();
            }
            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled)
                )
            {
                CFGUI.CreateUndo("Analog Axis Binding modification.", this.undoObject);

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
        // -----------------
        public void DrawDynamicTouchControlGUI(DynamicTouchControl c)
        {
            // Draw basic TouchControl GUI...

            this.DrawTouchContolGUI(c);


            // Dynamic-only GUI...

            bool
                fadeOutWhenReleased = c.fadeOutWhenReleased,
                startFadedOut       = c.startFadedOut;
            float
                fadeOutTargetAlpha = c.fadeOutTargetAlpha,
                fadeInDuration     = c.fadeInDuration,
                fadeOutDelay       = c.fadeOutDelay,
                fadeOutDuration    = c.fadeOutDuration;

            bool
                centerOnDirectTouch   = c.centerOnDirectTouch,
                centerOnIndirectTouch = c.centerOnIndirectTouch,
                centerWhenFollowing   = c.centerWhenFollowing,

                stickyMode        = c.stickyMode,
                clampInsideRegion = c.clampInsideRegion,
                clampInsideCanvas = c.clampInsideCanvas,

                returnToStartingPosition = c.returnToStartingPosition;

            Vector2
                directInitialVector   = c.directInitialVector,
                indirectInitialVector = c.indirectInitialVector;
            float
                originSmoothTime = c.originSmoothTime,
                touchSmoothing   = c.touchSmoothing;
            DynamicRegion
                targetDynamicRegion = c.targetDynamicRegion;


            // GUI...



            InspectorUtils.BeginIndentedSection(new GUIContent("Dynamic Control Settings"));

            if (targetDynamicRegion == null)
            {
                EditorGUILayout.HelpBox("Connect this control to a Dynamic Region to make it dynamic.", MessageType.Info);
            }
            //else
            //	{
            //	GUI.enabled = false;
            targetDynamicRegion = (DynamicRegion)CFGUI.ObjectField(new GUIContent("Region", "Control's Dynamic Region.\n\nWARNING: Only one control can be assigned to a dynamic region!"),
                                                                   targetDynamicRegion, typeof(DynamicRegion), LABEL_WIDTH);
            //	GUI.enabled = true;
            //	}

            EditorGUILayout.Space();

            if (targetDynamicRegion != null)
            {
                if ((fadeOutWhenReleased = EditorGUILayout.ToggleLeft(new GUIContent("Fade-out when released", "Fade-out control when released (Dynamic mode ONLY)."),
                                                                      fadeOutWhenReleased)))
                {
                    CFGUI.BeginIndentedVertical();

                    startFadedOut = EditorGUILayout.ToggleLeft(new GUIContent("Start faded out", "This tontrol will start invisible at the begining."),
                                                               startFadedOut);

                    fadeOutTargetAlpha = CFGUI.Slider(new GUIContent("F.O. Alpha", "Fade-Out Target Alpha. Default value is ZERO (completely invisible)."),
                                                      fadeOutTargetAlpha, 0, 1, LABEL_WIDTH);

                    EditorGUILayout.Space();

                    fadeInDuration = CFGUI.FloatFieldEx(new GUIContent("Fade-In Dur.", "Fade-In duration (ms) : 0 = instant fade-in."),
                                                        fadeInDuration, 0, 2, 1000, true, 100);
                    fadeOutDuration = CFGUI.FloatFieldEx(new GUIContent("Fade-Out Dur.", "Fade-Out duration (ms) : 0 = instant fade-out."),
                                                         fadeOutDuration, 0, 2, 1000, true, 100);

                    fadeOutDelay = CFGUI.FloatFieldEx(new GUIContent("Fade-Out Delay.", "Fade-Out delay (ms)."),
                                                      fadeOutDelay, 0, 2, 1000, true, 100);

                    CFGUI.EndIndentedVertical();

                    EditorGUILayout.Space();
                }
            }


            if (targetDynamicRegion != null)
            {
                centerOnDirectTouch = EditorGUILayout.ToggleLeft(new GUIContent("Center On Direct Touch"),
                                                                 centerOnDirectTouch);
                centerOnIndirectTouch = EditorGUILayout.ToggleLeft(new GUIContent("Center On Indirect Touch"),
                                                                   centerOnIndirectTouch);

                if (centerOnIndirectTouch)
                {
                    const string initialPosTooltip =
                        "Normalized position that the control will center itself after being activated by a touch.\n" +
                        "Default if (0,0) (center).";

                    EditorGUILayout.LabelField(new GUIContent("Direct Touch Initial Pos", initialPosTooltip));
                    CFGUI.BeginIndentedVertical();
                    directInitialVector.x = CFGUI.Slider(new GUIContent("X", initialPosTooltip), directInitialVector.x, -1, 1, 20);
                    directInitialVector.y = CFGUI.Slider(new GUIContent("Y", initialPosTooltip), directInitialVector.y, -1, 1, 20);
                    CFGUI.EndIndentedVertical();

                    EditorGUILayout.LabelField(new GUIContent("Indirect Touch Initial Pos", initialPosTooltip));
                    CFGUI.BeginIndentedVertical();
                    indirectInitialVector.x = CFGUI.Slider(new GUIContent("X", initialPosTooltip), indirectInitialVector.x, -1, 1, 20);
                    indirectInitialVector.y = CFGUI.Slider(new GUIContent("Y", initialPosTooltip), indirectInitialVector.y, -1, 1, 20);
                    CFGUI.EndIndentedVertical();
                }

                EditorGUILayout.Space();
            }



            //GUI.enabled = (c.swipeOffMode == TouchControl.SwipeOffMode.Disabled);
            GUI.enabled = (c.swipeOffMode != TouchControl.SwipeOffMode.Enabled);


            stickyMode = EditorGUILayout.ToggleLeft(new GUIContent("Sticky Mode", "Control will follow the finger is it goes out of control bounds. This option will be disabled if control's Swipe Off Mode is det to Enabled!"),
                                                    stickyMode);

            if (stickyMode)
            {
                CFGUI.BeginIndentedVertical();
                centerWhenFollowing = EditorGUILayout.ToggleLeft(new GUIContent("Center when following.", "WARNING! Don't use this option on Joysticks or Steering Wheels - it will make them unusable!"),
                                                                 centerWhenFollowing);
                CFGUI.EndIndentedVertical();
            }

            GUI.enabled = true;

            EditorGUILayout.Space();


            clampInsideRegion = EditorGUILayout.ToggleLeft(new GUIContent("Clamp Inside Region", "Control will be clamped inside Dynamic Region when in Sticky Mode or when started by indirect touch."),
                                                           clampInsideRegion);

            clampInsideCanvas = EditorGUILayout.ToggleLeft(new GUIContent("Clamp Inside Canvas", "Control will be clamped inside parent canvas when in Sticky Mode or when started by indirect touch."),
                                                           clampInsideCanvas);


            EditorGUILayout.Space();

            if (targetDynamicRegion != null)
            {
                returnToStartingPosition = EditorGUILayout.ToggleLeft(new GUIContent("Return to start position", "Control will return to starting position after being released (Dynamic Mode)"),
                                                                      returnToStartingPosition);

                EditorGUILayout.Space();
            }


            originSmoothTime = CFGUI.Slider(new GUIContent("Move. smoothing", "Movement smoothing time (sticky mode, dynamic mode).\n\n0.0 = no smoothing/no animation.\n1.0 = slow movement."),
                                            originSmoothTime, 0, 1, 110);

            touchSmoothing = CFGUI.Slider(new GUIContent("Touch smoothing", "Amount of smoothing applied to controlling touch position. "),
                                          touchSmoothing, 0, 1, 110);


            InspectorUtils.EndIndentedSection();



            // Register Undo...

            if ((fadeOutWhenReleased != c.fadeOutWhenReleased) ||
                (startFadedOut != c.startFadedOut) ||
                (fadeOutTargetAlpha != c.fadeOutTargetAlpha) ||
                (fadeInDuration != c.fadeInDuration) ||
                (fadeOutDelay != c.fadeOutDelay) ||
                (fadeOutDuration != c.fadeOutDuration) ||
                (centerOnDirectTouch != c.centerOnDirectTouch) ||
                (centerOnIndirectTouch != c.centerOnIndirectTouch) ||
                (stickyMode != c.stickyMode) ||
                (clampInsideRegion != c.clampInsideRegion) ||
                (clampInsideCanvas != c.clampInsideCanvas) ||
                (targetDynamicRegion != c.targetDynamicRegion) ||
                (returnToStartingPosition != c.returnToStartingPosition) ||
                (directInitialVector != c.directInitialVector) ||
                (indirectInitialVector != c.indirectInitialVector) ||
                (touchSmoothing != c.touchSmoothing) ||
                (originSmoothTime != c.originSmoothTime))
            {
                CFGUI.CreateUndo("Dynamic Touch Control modification.", c);

                c.fadeOutWhenReleased      = fadeOutWhenReleased;
                c.startFadedOut            = startFadedOut;
                c.fadeOutTargetAlpha       = fadeOutTargetAlpha;
                c.fadeInDuration           = fadeInDuration;
                c.fadeOutDelay             = fadeOutDelay;
                c.fadeOutDuration          = fadeOutDuration;
                c.centerOnDirectTouch      = centerOnDirectTouch;
                c.centerOnIndirectTouch    = centerOnIndirectTouch;
                c.stickyMode               = stickyMode;
                c.clampInsideRegion        = clampInsideRegion;
                c.clampInsideCanvas        = clampInsideCanvas;
                c.returnToStartingPosition = returnToStartingPosition;
                c.directInitialVector      = directInitialVector;
                c.indirectInitialVector    = indirectInitialVector;
                c.originSmoothTime         = originSmoothTime;

                if (c.touchSmoothing != touchSmoothing)
                {
                    c.SetTouchSmoothing(touchSmoothing);
                }

                if (targetDynamicRegion != c.targetDynamicRegion)
                {
                    c.SetTargetDynamicRegion(targetDynamicRegion);
                }

                CFGUI.EndUndo(c);
            }
        }
Example #13
0
        // ------------------
        public void Draw(DigitalBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();

            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);


                EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Axis Targets"), GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

                {
                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add Axis Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Add new axis to Digital Binding.", this.undoObject);
                        bind.AddAxis();
                        CFGUI.EndUndo(this.undoObject);
                    }

                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove Axis Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Remove axis from Digital Binding.", this.undoObject);
                        bind.RemoveLastAxis();
                        CFGUI.EndUndo(this.undoObject);
                    }
                }

                EditorGUILayout.EndHorizontal();


                {
                    this.PrepareAxisElemInspList(bind.axisList.Count);

                    if (bind.axisList.Count == 0)
                    {
                        EditorGUILayout.LabelField("No axis targets defined...", CFEditorStyles.Inst.centeredTextTranspBG);
                    }
                    else
                    {
                        for (int i = 0; i < bind.axisList.Count; ++i)
                        {
                            this.axisElemInspList[i].DrawGUI(bind.axisList[i], rig);
                        }
                    }
                }

                EditorGUILayout.EndVertical();


                // Key targets...


                EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(new GUIContent("Key Targets"), GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

                {
                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add Key Target"), CFEditorStyles.Inst.iconButtonStyle))                             //, GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Add new key to Digital Binding.", this.undoObject);
                        bind.AddKey(KeyCode.None);
                        CFGUI.EndUndo(this.undoObject);
                    }

                    if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove Key Target"), CFEditorStyles.Inst.iconButtonStyle))                             //GUILayout.Width(20), GUILayout.Height(20)))
                    {
                        CFGUI.CreateUndo("Remove key from Digital Binding.", this.undoObject);
                        bind.RemoveLastKey();
                        CFGUI.EndUndo(this.undoObject);
                    }
                }

                EditorGUILayout.EndHorizontal();

                {
                    if (bind.keyList.Count == 0)
                    {
                        EditorGUILayout.LabelField("No key targets defined...", CFEditorStyles.Inst.centeredTextTranspBG);
                    }
                    else
                    {
                        EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpSunkenBG);

                        for (int i = 0; i < bind.keyList.Count; ++i)
                        {
                            KeyCode
                                keyOriginal = bind.keyList[i],
                                key         = keyOriginal;

                            key = (KeyCode)EditorGUILayout.EnumPopup("" /*"KeyCode"*/, key, GUILayout.MinWidth(30), GUILayout.ExpandWidth(false));

                            if (key != keyOriginal)
                            {
                                CFGUI.CreateUndo("Digital Binding Key modification.", this.undoObject);
                                bind.keyList[i] = key;
                                CFGUI.EndUndo(this.undoObject);
                            }
                        }

                        EditorGUILayout.EndVertical();
                    }
                }


                EditorGUILayout.EndVertical();



                CFGUI.EndIndentedVertical();
            }

            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled))
            {
                CFGUI.CreateUndo("Digital Binding modification.", this.undoObject);

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
Example #14
0
        // ------------------
        public void DrawGUI()
        {
            if (this.elemInspList.Count != this.targetList.Count)
            {
//Debug.Log("[" + Time.frameCount + "] Rebuilding list onGUI (" + this.GetType() + ")!");
                this.Rebuild();
            }

            EditorGUILayout.BeginVertical();

            // Draw header...

            Color initialBgColor = GUI.backgroundColor;

            GUI.backgroundColor = InspectorUtils.SectionHeaderColor;
            EditorGUILayout.BeginHorizontal(InspectorUtils.SectionHeaderStyle);
            GUI.backgroundColor = initialBgColor;

            //this.isFoldedOut = EditorGUILayout.Foldout(this.isFoldedOut, this.GetListTitleContent(), CFEditorStyles.Inst.foldout, );
            if (this.isFoldable)
            {
                this.isFoldedOut = GUILayout.Toggle(this.isFoldedOut, this.GetListTitleContent(), CFEditorStyles.Inst.foldout, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));
            }
            else
            {
                GUILayout.Label(this.GetListTitleContent(), GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));
            }

            EditorGUILayout.Space();

            if (GUILayout.Button(new GUIContent("", CFEditorStyles.Inst.createNewTex, "Add new element..."), CFEditorStyles.Inst.iconButtonStyle, GUILayout.Width(BUTTON_WIDTH)))
            {
                this.OnNewElemClicked();
            }

            EditorGUILayout.EndHorizontal();

            // Draw elements...

            if (this.isFoldedOut)
            {
                if (this.elemInspList.Count == 0)
                {
                    CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG);
                    EditorGUILayout.LabelField("List is empty.", CFEditorStyles.Inst.centeredTextTranspBG);
                    CFGUI.EndIndentedVertical();
                }
                else
                {
                    CFGUI.BeginIndentedVertical();

                    for (int i = 0; i < this.elemInspList.Count; ++i)
                    {
                        if (!this.elemInspList[i].DrawGUI())
                        {
                            break;
                        }
                    }

                    CFGUI.EndIndentedVertical();
                }
            }

            EditorGUILayout.EndVertical();
        }