コード例 #1
0
        // ------------------
        public void Draw(JoystickStateBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();

            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                InspectorUtils.BeginIndentedSection();

                this.horzAxisInspector.Draw(bind.horzAxisBinding, rig);
                this.vertAxisInspector.Draw(bind.vertAxisBinding, rig);


                this.dirInspector.Draw(bind.dirBinding, rig);

                InspectorUtils.EndIndentedSection();

                GUILayout.Space(InputBindingGUIUtils.VERT_MARGIN);
            }

            EditorGUILayout.EndVertical();


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

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
コード例 #2
0
        // ----------------
        public void MoveElem(int elemId, bool moveUp)
        {
            if ((elemId < 0) || (elemId >= this.targetList.Count))
            {
                return;
            }

            int targetId = elemId + (moveUp ? -1 : 1);

            if ((targetId < 0) || (targetId >= this.targetList.Count))
            {
                return;
            }

            CFGUI.CreateUndo(this.GetUndoPrefix() + "Reorder ", this.undoObject);

            object elem = this.targetList[elemId];

            this.targetList.RemoveAt(elemId);

            ElemInspector elemInsp = this.elemInspList[elemId];

            this.elemInspList.RemoveAt(elemId);

            this.targetList.Insert(targetId, elem);
            this.elemInspList.Insert(targetId, elemInsp);

            this.ResetElemIds();

            CFGUI.EndUndo(this.undoObject);
        }
コード例 #3
0
            // --------------------
            public void DrawGUI(DigitalBinding.AxisElem target, InputRig rig)
            {
                string axisName         = target.axisName;
                bool   axisPositiveSide = target.axisPositiveSide;

                EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpSunkenBG);

                axisPositiveSide = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.texPlusSign, "Bind to positive side of target axis."),
                                                    new GUIContent("", CFEditorStyles.Inst.texMinusSign, "Bind to negative side of target axis"), axisPositiveSide, CFEditorStyles.Inst.iconButtonStyle, GUILayout.Width(16));

                axisName = this.axisField.Draw("", axisName, rig);

                EditorGUILayout.EndHorizontal();


                if ((axisName != target.axisName) ||
                    (axisPositiveSide != target.axisPositiveSide))
                {
                    CFGUI.CreateUndo("Digital Binding Axis modification.", this.parent.undoObject);

                    target.axisName         = axisName;
                    target.axisPositiveSide = axisPositiveSide;

                    CFGUI.EndUndo(this.parent.undoObject);
                }
            }
        // ------------------
        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);
            }
        }
コード例 #5
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchSteeringWheelSpriteAnimator target = this.target as TouchSteeringWheelSpriteAnimator;

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

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



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

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

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


            InspectorUtils.EndIndentedSection();


            // Scaling GUI...

            float
                rotationRange         = target.rotationRange,
                rotationSmoothingTime = target.rotationSmoothingTime;


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

            rotationRange = CFGUI.Slider(new GUIContent("Rot. range", "Wheel's Rotation Range"), rotationRange, 0, 180, 65);

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

            EditorGUILayout.Space();

//			TouchControlSpriteAnimatorInspector.DrawScaleGUI(target);

            InspectorUtils.EndIndentedSection();



            if ((rotationRange != target.rotationRange) ||
                (rotationSmoothingTime != target.rotationSmoothingTime))
            {
                CFGUI.CreateUndo("Sprite Animator Trsnaform modification", target);

                target.rotationRange         = rotationRange;
                target.rotationSmoothingTime = rotationSmoothingTime;

                CFGUI.EndUndo(target);
            }
        }
        // ------------------
        public void Draw(MousePositionBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;
            int  priority       = bind.priority;

            EditorGUILayout.BeginVertical();
            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
                InspectorUtils.BeginIndentedSection();

                priority = EditorGUILayout.IntSlider(new GUIContent("Pos. prio.", "Position priority used to pick mouse position if there is more than one mouse position source in the rig at given frame."),
                                                     priority, 0, 100, GUILayout.MinWidth(30));

                InspectorUtils.EndIndentedSection();
            }
            EditorGUILayout.EndVertical();


            if ((bindingEnabled != bind.enabled) ||
                (priority != bind.priority))
            {
                CFGUI.CreateUndo("Mouse Position Binding modification.", this.undoObject);

                bind.enabled  = bindingEnabled;
                bind.priority = priority;

                CFGUI.EndUndo(this.undoObject);
            }
        }
コード例 #7
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchTrackPad c = (TouchTrackPad)this.target;

            float
                touchSmoothing = c.touchSmoothing;

            this.emulateTouchPressure = c.emulateTouchPressure;

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


            this.DrawWarnings(c);



            //Trackpad inspector....

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

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

            InspectorUtils.EndIndentedSection();


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


            this.pressBindingInsp.Draw(c.pressBinding, c.rig);
            this.touchPressureBindingInsp.Draw(c.touchPressureBinding, c.rig);
            this.horzSwipeBindingInsp.Draw(c.horzSwipeBinding, c.rig);
            this.vertSwipeBindingInsp.Draw(c.vertSwipeBinding, c.rig);

            InspectorUtils.EndIndentedSection();


            // Register Undo...

            if ((touchSmoothing != c.touchSmoothing) ||
                (this.emulateTouchPressure != c.emulateTouchPressure))
            {
                CFGUI.CreateUndo("Dynamic Touch Control modification.", c);

                c.SetTouchSmoothing(touchSmoothing);

                c.emulateTouchPressure = this.emulateTouchPressure;

                CFGUI.EndUndo(c);
            }


            // Draw Shared Control Params...

            this.DrawTouchContolGUI(c);
        }
コード例 #8
0
                // --------------
                override public bool DrawGUI()         //object targetObj)
                {
                    bool retVal = true;

                    string name = this.target.name;
                    bool   disableWhenSwitchIsOff = this.target.disableWhenSwitchIsOff;



                    EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpBevelBG);

                    // Keyboard input...


                    string actionName = ((DisablingRigSwitchSetInspector)this.listInsp).actionName;

                    disableWhenSwitchIsOff = CFGUI.PushButton(new GUIContent("When OFF", actionName + " When OFF"), new GUIContent("When ON", actionName + " when ON"),
                                                              disableWhenSwitchIsOff, CFEditorStyles.Inst.buttonStyle, GUILayout.Width(80));

                    name = this.flagNameInsp.Draw("", name, this.rig, 0);


                    GUILayout.Space(10);



                    if (!this.DrawDefaultButtons(false, true))
                    {
                        retVal = false;
                    }


                    EditorGUILayout.EndHorizontal();


                    if (retVal)
                    {
                        if ((name != this.target.name) ||
                            (disableWhenSwitchIsOff != this.target.disableWhenSwitchIsOff))
                        {
                            CFGUI.CreateUndo("Disabling Switch modification", this.listInsp.undoObject);

                            this.target.name = name;
                            this.target.disableWhenSwitchIsOff = disableWhenSwitchIsOff;

                            CFGUI.EndUndo(this.listInsp.undoObject);
                        }
                    }

                    return(retVal);
                }
コード例 #9
0
        // -------------------
        protected void AddNewElem(object targetObject)
        {
            //if (targetObject == null)
            //	return;

            CFGUI.CreateUndo(this.GetUndoPrefix() + "Add new elem.", this.undoObject);

            this.targetList.Insert(0, targetObject);
            this.elemInspList.Insert(0, this.CreateElemInspector(targetObject));

            this.ResetElemIds();

            CFGUI.EndUndo(this.undoObject);
        }
コード例 #10
0
        // ---------------
        public override void OnInspectorGUI()
        {
            GamepadManager m = (GamepadManager)this.target;


            // Gamepad Manager GUI...

            float
                connectionCheckInterval = m.connectionCheckInterval;
            bool
                dontDestroyOnLoad = m.dontDestroyOnLoad;


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


            EditorGUILayout.Space();

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

            connectionCheckInterval = CFGUI.FloatFieldEx(new GUIContent("Connection Check Interval (ms)", "Gamepad connection Check Interval in milliseconds.\nEach call of Input.GetJoystickNames() allocates at least 40 bytes - that's not much, but..."),
                                                         connectionCheckInterval, 0, 10, 1000, true, 190);

            dontDestroyOnLoad = EditorGUILayout.ToggleLeft(new GUIContent("Don't destroy on load.", "This game object will not be destroyed when new scene/level is loaded."),
                                                           dontDestroyOnLoad);

            InspectorUtils.EndIndentedSection();


            EditorGUILayout.Space();


            // Register undo...

            if (    //(gamepadOrderMode			!= m.gamepadOrderMode)
                (connectionCheckInterval != m.connectionCheckInterval) ||
                (dontDestroyOnLoad != m.dontDestroyOnLoad)

                )
            {
                CFGUI.CreateUndo("CF2 Gamepad Manager modification", m);

                //m.gamepadOrderMode		 = gamepadOrderMode;

                m.connectionCheckInterval = connectionCheckInterval;
                m.dontDestroyOnLoad       = dontDestroyOnLoad;

                CFGUI.EndUndo(m);
            }
        }
コード例 #11
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchJoystick c = (TouchJoystick)this.target;

            this.emulateTouchPressure = c.emulateTouchPressure;

            this.DrawWarnings(c);

            // Joystick GUI...


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

            // Steering Wheel specific inspector....

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

            this.joyConfigInsp.DrawGUI(c.config);

            InspectorUtils.EndIndentedSection();


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


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

            this.joyStateBindingInsp.Draw(c.joyStateBinding, c.rig);

            InspectorUtils.EndIndentedSection();


            // Register Undo...

            if ((this.emulateTouchPressure != c.emulateTouchPressure))
            {
                CFGUI.CreateUndo("Dynamic Touch Control modification.", c);

                c.emulateTouchPressure = this.emulateTouchPressure;

                CFGUI.EndUndo(c);
            }


            // Draw Shared Dynamic Control Params...

            this.DrawDynamicTouchControlGUI(c);
        }
コード例 #12
0
        // -----------------------
        public void DrawGUI()
        {
            bool
                disableWhenTouchScreenInactive = this.target.disableWhenTouchScreenInactive,
                disableWhenCursorIsUnlocked    = this.target.disableWhenCursorIsUnlocked;

            DisablingConditionSet.MobileModeRelation
                mobileModeRelation = this.target.mobileModeRelation;


            InspectorUtils.BeginIndentedSection(this.titleContent);

            mobileModeRelation = (DisablingConditionSet.MobileModeRelation)CFGUI.EnumPopup(new GUIContent("Mobile Mode Relation"),
                                                                                           mobileModeRelation, 130);

            disableWhenCursorIsUnlocked = EditorGUILayout.ToggleLeft(new GUIContent("Disable when Cursor is unlocked", "Disable this element when mouse cursor is unlocked. \nUse this option if your game is using cursor lock state to display menus and things like that..."),
                                                                     disableWhenCursorIsUnlocked);
            disableWhenTouchScreenInactive = EditorGUILayout.ToggleLeft(new GUIContent("Disable when Touch Screen is inactive", "Disable this element when touch screen hasn't been used for some time (Check out Input Rig's General Settings)."),
                                                                        disableWhenTouchScreenInactive);

            EditorGUILayout.Space();

            if (this.switchListInsp != null)
            {
                this.switchListInsp.DrawGUI();
            }


            InspectorUtils.EndIndentedSection();



            // Refister undo...

            if ((mobileModeRelation != this.target.mobileModeRelation) ||
                (disableWhenCursorIsUnlocked != this.target.disableWhenCursorIsUnlocked) ||
                (disableWhenTouchScreenInactive != this.target.disableWhenTouchScreenInactive))
            {
                CFGUI.CreateUndo("Disabling Conditions modification", this.undoObject);

                this.target.mobileModeRelation             = mobileModeRelation;
                this.target.disableWhenCursorIsUnlocked    = disableWhenCursorIsUnlocked;
                this.target.disableWhenTouchScreenInactive = disableWhenTouchScreenInactive;

                CFGUI.EndUndo(this.undoObject);
            }
        }
コード例 #13
0
        // ----------------
        public void DeleteElem(int elemId)
        {
            if ((elemId < 0) || (elemId >= this.targetList.Count))
            {
//Debug.LogError("Delete Elem ListInsp - out of range! " + elemId + "/" + this.targetList.Count);
                return;
            }


            CFGUI.CreateUndo(this.GetUndoPrefix() + "Delete elem", this.undoObject);

            this.targetList.RemoveAt(elemId);
            this.elemInspList.RemoveAt(elemId);

            this.ResetElemIds();

            CFGUI.EndUndo(this.undoObject);
        }
コード例 #14
0
        // ------------------
        public void Draw(EmuTouchBinding bind, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;

            EditorGUILayout.BeginVertical();
            if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)))
            {
            }
            EditorGUILayout.EndVertical();


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

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }
コード例 #15
0
            // --------------
            override public bool DrawGUI()     //object targetObj)
            {
                bool retVal = true;

                Object originalObj = (Object)this.listInsp.GetTargetList()[this.elemId];
                Object obj         = originalObj;

                EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpBevelBG);

                obj = EditorGUILayout.ObjectField(obj, ((ObjectListInspector)this.listInsp).objType, true, GUILayout.ExpandWidth(true));

                if (!this.DrawDefaultButtons(false, true))
                {
                    retVal = false;
                }


                EditorGUILayout.EndHorizontal();


                if (retVal)
                {
                    if (obj != originalObj)
                    {
                        obj = ((ObjectListInspector)this.listInsp).HandleObjectChange(originalObj, obj);
                    }

                    if ((obj != originalObj))
                    {
                        CFGUI.CreateUndo(this.listInsp.GetUndoPrefix() + "Modification", this.listInsp.undoObject);

                        this.listInsp.GetTargetList()[this.elemId] = obj;

                        CFGUI.EndUndo(this.listInsp.undoObject);
                    }
                }

                return(retVal);
            }
コード例 #16
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);
            }
        }
コード例 #17
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);
        }
        // -------------------
        static public bool DrawSourceGUI(TouchControlSpriteAnimatorBase target)
        {
            bool
                autoConnect = target.autoConnectToSource;
            TouchControl
                sourceControl = target.sourceControl;


            bool initiallyEnabled = GUI.enabled;

            InspectorUtils.BeginIndentedSection(new GUIContent("Source Control Connection"));

            GUI.enabled = (sourceControl != null);
            if (GUILayout.Button(new GUIContent("Select Source Control"), GUILayout.ExpandWidth(true), GUILayout.Height(20)))
            {
                Selection.activeObject = sourceControl;
                return(false);
            }

            GUI.enabled = initiallyEnabled;

            autoConnect = EditorGUILayout.ToggleLeft(new GUIContent("Auto Connect To Control", "When enabled, this animator will automatically pick source control whenever this gameobject's hierarchy changes."),
                                                     autoConnect, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

            if (autoConnect)
            {
                GUI.enabled = false;
            }

            sourceControl = (TouchControl)EditorGUILayout.ObjectField(new GUIContent("Source Control"), sourceControl, target.GetSourceControlType(), true,
                                                                      GUILayout.MaxWidth(30), GUILayout.ExpandWidth(true));

            GUI.enabled = initiallyEnabled;

            if (sourceControl == null)
            {
                InspectorUtils.DrawErrorBox("Source Control is not connected!");
            }
            else if (target.IsIllegallyAttachedToSource())
            {
                InspectorUtils.DrawErrorBox("This Animator is attached to the source control's game object!!\nTransformation Animation will not be possible!!");
            }

            InspectorUtils.EndIndentedSection();


            // Register Undo...

            if ((autoConnect != target.autoConnectToSource) ||
                (sourceControl != target.sourceControl))
            {
                CFGUI.CreateUndo("Sprite Animator Source modification", target);

                target.autoConnectToSource = autoConnect;
                target.SetSourceControl(sourceControl);

                if (target.autoConnectToSource)
                {
                    target.AutoConnectToSource();
                }

                CFGUI.EndUndo(target);
            }

            return(true);
        }
コード例 #19
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);
            }
        }
コード例 #20
0
            // ---------------------
            public void DrawGUI(AxisBinding.TargetElem target, InputRig rig, bool isLast)
            {
                bool   separateAxes      = target.separateAxes;
                string singleAxis        = target.singleAxis;
                bool   reverseSingleAxis = target.reverseSingleAxis;

                string positiveAxis       = target.positiveAxis;
                string negativeAxis       = target.negativeAxis;
                bool   positiveAsPositive = target.positiveAxisAsPositive;
                bool   negativeAsPositive = target.negativeAxisAsPositive;

                if (this.parent.allowAxisSeparation)
                {
                    EditorGUILayout.BeginHorizontal(CFEditorStyles.Inst.transpSunkenBG);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                }

                {
                    if (!this.parent.allowAxisSeparation)
                    {
                        separateAxes = false;
                    }
                    else
                    {
                        EditorGUILayout.BeginVertical(GUILayout.Width(20));

                        GUILayout.Space(separateAxes ? 12 : 3);

                        separateAxes = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.sepAxesOnTex, "Separate axes for positive and negative values."),
                                                        new GUIContent("", CFEditorStyles.Inst.sepAxesOffTex, "Single target axis."), separateAxes, CFEditorStyles.Inst.buttonStyle, //CFEditorStyles.Inst.iconButtonStyle,
                                                        GUILayout.Width(18), GUILayout.Height(18));                                                                                  //.ExpandHeight(true), GUILayout.ExpandWidth(true));


                        EditorGUILayout.EndVertical();
                    }
                }

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


                    if (!separateAxes)
                    {
                        EditorGUILayout.BeginHorizontal();

                        reverseSingleAxis = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.texMinusSign, "Reverse source value."),
                                                             new GUIContent("", CFEditorStyles.Inst.texPlusSign, "Don't reverse source value."), reverseSingleAxis, CFEditorStyles.Inst.iconButtonStyle);

                        singleAxis = this.singleAxisField.Draw("", singleAxis, rig);
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.LabelField(new GUIContent("Axis +", "Posiitive value axis"), GUILayout.Width(40));

                        positiveAsPositive = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.texPlusSign, "Send positive values as positive to target axis."),
                                                              new GUIContent("", CFEditorStyles.Inst.texMinusSign, "Send positive values as negative."), positiveAsPositive, CFEditorStyles.Inst.iconButtonStyle);

                        positiveAxis = this.positiveAxisField.Draw("", positiveAxis, rig);
                        EditorGUILayout.EndHorizontal();



                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.LabelField(new GUIContent("Axis -", "Negative value axis"), GUILayout.Width(40));

                        negativeAsPositive = CFGUI.PushButton(new GUIContent("", CFEditorStyles.Inst.texPlusSign, "Send negative values as positive to target axis."),
                                                              new GUIContent("", CFEditorStyles.Inst.texMinusSign, "Send negative values as negative."), negativeAsPositive, CFEditorStyles.Inst.iconButtonStyle);
                        //EditorGUILayout.ToggleLeft(new GUIContent("-", "Activate the negative side of the axis."), axisNegSide,

                        negativeAxis = this.negativeAxisField.Draw("", negativeAxis, rig);
                        EditorGUILayout.EndHorizontal();
                    }


                    EditorGUILayout.EndVertical();
                }

                EditorGUILayout.EndHorizontal();


                if (        //(bindingEnabled	!=	bind.enabled) ||
                    (separateAxes != target.separateAxes) ||
                    (singleAxis != target.singleAxis) ||
                    (reverseSingleAxis != target.reverseSingleAxis) ||
                    (positiveAxis != target.positiveAxis) ||
                    (negativeAxis != target.negativeAxis) ||
                    (positiveAsPositive != target.positiveAxisAsPositive) ||
                    (negativeAsPositive != target.negativeAxisAsPositive))
                {
                    CFGUI.CreateUndo("Analog Axis Binding modification.", this.parent.undoObject);

                    //bind.enabled			= bindingEnabled;
                    target.separateAxes           = separateAxes;
                    target.singleAxis             = singleAxis;
                    target.positiveAxis           = positiveAxis;
                    target.negativeAxis           = negativeAxis;
                    target.positiveAxisAsPositive = positiveAsPositive;
                    target.negativeAxisAsPositive = negativeAsPositive;
                    target.reverseSingleAxis      = reverseSingleAxis;

                    CFGUI.EndUndo(this.parent.undoObject);
                }
            }
コード例 #21
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchSteeringWheel c = (TouchSteeringWheel)this.target;

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

            this.DrawWarnings(c);

            // Steerign wheel GUI...

            TouchSteeringWheel.WheelMode
                wheelMode = c.wheelMode;

            bool
                limitTurnSpeed = c.limitTurnSpeed;
            float
                minTurnTime      = c.minTurnTime,
                maxReturnTime    = c.maxReturnTime,
                maxTurnAngle     = c.maxTurnAngle,
                turnModeDeadZone = c.turnModeDeadZone;
            //	digitalThresh		= c.digitalThresh;
            bool
                physicalMode            = c.physicalMode,
                sendInputWhileReturning = c.sendInputWhileReturning;
            float
                physicalMoveRangeCm = c.physicalMoveRangeCm;

            this.emulateTouchPressure = c.emulateTouchPressure;


            const float LABEL_WIDTH = 120;


            // Steering Wheel specific inspector....

            InspectorUtils.BeginIndentedSection(new GUIContent("Steering Wheel Settings"));

            wheelMode = (TouchSteeringWheel.WheelMode)CFGUI.EnumPopup(new GUIContent("Wheel Mode"), wheelMode, LABEL_WIDTH);

            if (c.wheelMode == TouchSteeringWheel.WheelMode.Turn)
            {
                maxTurnAngle = CFGUI.FloatField(new GUIContent("Max. Turn Angle", "Maximal Turn angle in degrees (TURN Wheel Mode)."),
                                                maxTurnAngle, 1, 3600, LABEL_WIDTH);

                turnModeDeadZone = CFGUI.Slider(new GUIContent("Dead-zone", "Dead-zone - how far from wheel's center a finger must be to interact with it."),
                                                turnModeDeadZone, 0.01f, 0.9f, LABEL_WIDTH);
            }
            else
            {
                physicalMode = EditorGUILayout.ToggleLeft(new GUIContent("Physical Swipe Mode", "Define wheel's range in centimeters."), physicalMode);
                if (physicalMode)
                {
                    InspectorUtils.BeginIndentedSection();
                    physicalMoveRangeCm = CFGUI.FloatFieldEx(new GUIContent("Range (cm)", "Physical Mode's range in centimeters."),
                                                             physicalMoveRangeCm, 0.1f, 10, 1, false, LABEL_WIDTH);
                    InspectorUtils.EndIndentedSection();
                }
            }

            limitTurnSpeed = EditorGUILayout.ToggleLeft(new GUIContent("Limit turn speed", "Limit how fast the wheel can turn and how fast it can return to neutral position."),
                                                        limitTurnSpeed);


            if (limitTurnSpeed)
            {
                InspectorUtils.BeginIndentedSection();
                minTurnTime = CFGUI.FloatFieldEx(new GUIContent("Turn Time", "Turn Time in milliseconds - how quick can this wheel move from neutral position to maximal turn angle.\nSet to zero to remove speed limit."),
                                                 minTurnTime, 0, 5, 1000, true, LABEL_WIDTH);
                maxReturnTime = CFGUI.FloatFieldEx(new GUIContent("Return Time", "Time in milliseconds needed to return from maximal turn angle to neutral position."),
                                                   maxReturnTime, 0, 5, 1000, true, LABEL_WIDTH);
                InspectorUtils.EndIndentedSection();
            }



            EditorGUILayout.Space();

            this.analogConfigInsp.DrawGUI(c.analogConfig);

            InspectorUtils.EndIndentedSection();



            InspectorUtils.BeginIndentedSection(new GUIContent("Steering Wheel Bindings"));

            sendInputWhileReturning = EditorGUILayout.ToggleLeft(new GUIContent("Send input while returning", "If enabled, wheel's analog state will be sent to the rig while the wheel is returning to the neutral position."),
                                                                 sendInputWhileReturning, GUILayout.MinWidth(30));

            EditorGUILayout.Space();

            this.pressBindingInsp.Draw(c.pressBinding, c.rig);
            this.touchPressureBindingInsp.Draw(c.touchPressureBinding, c.rig);
            this.analogTurnBindingInsp.Draw(c.analogTurnBinding, c.rig);
            this.turnLeftBindingInsp.Draw(c.turnLeftBinding, c.rig);
            this.turnRightBindingInsp.Draw(c.turnRightBinding, c.rig);

            InspectorUtils.EndIndentedSection();


            // Register undo...


            if ((limitTurnSpeed != c.limitTurnSpeed) ||
                (minTurnTime != c.minTurnTime) ||
                (maxReturnTime != c.maxReturnTime) ||
                (wheelMode != c.wheelMode) ||
                (maxTurnAngle != c.maxTurnAngle) ||
                (turnModeDeadZone != c.turnModeDeadZone) ||
                (sendInputWhileReturning != c.sendInputWhileReturning) ||
                (this.emulateTouchPressure != c.emulateTouchPressure) ||
                (physicalMode != c.physicalMode) ||
                (physicalMoveRangeCm != c.physicalMoveRangeCm))
            {
                if ((wheelMode == TouchSteeringWheel.WheelMode.Turn) && (wheelMode != c.wheelMode) && (c.analogConfig.analogDeadZone != 0))
                {
                    c.analogConfig.analogDeadZone = 0;
                }


                CFGUI.CreateUndo("CF2 Steering Wheel modification", c);

                c.limitTurnSpeed          = limitTurnSpeed;
                c.minTurnTime             = minTurnTime;
                c.maxReturnTime           = maxReturnTime;
                c.emulateTouchPressure    = this.emulateTouchPressure;
                c.physicalMode            = physicalMode;
                c.physicalMoveRangeCm     = physicalMoveRangeCm;
                c.wheelMode               = wheelMode;
                c.maxTurnAngle            = maxTurnAngle;
                c.turnModeDeadZone        = turnModeDeadZone;
                c.sendInputWhileReturning = sendInputWhileReturning;


                CFGUI.EndUndo(c);
            }

            // Draw Shared Dynamic Control Params...

            this.DrawDynamicTouchControlGUI(c);
        }
コード例 #22
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);
            }
        }
コード例 #23
0
            // -------------------
            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);
                }
            }
コード例 #24
0
        // ---------------
        public override void OnInspectorGUI()
        {
            ControlFreak2.SuperTouchZone c = (ControlFreak2.SuperTouchZone) this.target;

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


            this.DrawWarnings(c);



            int
                maxFingers = c.maxFingers;
            float
                strictMultiTouchTime = c.strictMultiTouchTime;
            float
                touchSmoothing = c.touchSmoothing;
            bool
                strictMultiTouch        = c.strictMultiTouch,
                freezeTwistWhenTooClose = c.freezeTwistWhenTooClose,
                noPinchAfterDrag        = c.noPinchAfterDrag,
                noPinchAfterTwist       = c.noPinchAfterTwist,
                noTwistAfterDrag        = c.noTwistAfterDrag,
                noTwistAfterPinch       = c.noTwistAfterPinch,
                noDragAfterPinch        = c.noDragAfterPinch,
                noDragAfterTwist        = c.noDragAfterTwist,
                startPinchWhenTwisting  = c.startPinchWhenTwisting,
                startPinchWhenDragging  = c.startPinchWhenDragging,
                startDragWhenPinching   = c.startDragWhenPinching,
                startDragWhenTwisting   = c.startDragWhenTwisting,
                startTwistWhenDragging  = c.startTwistWhenDragging,
                startTwistWhenPinching  = c.startTwistWhenPinching;

            ControlFreak2.SuperTouchZone.GestureDetectionOrder
                gestureDetectionOrder = c.gestureDetectionOrder;



            bool
                emuWithKeys = c.emuWithKeys;
            KeyCode
                emuKeyOneFinger         = c.emuKeyOneFinger,
                emuKeyTwoFingers        = c.emuKeyTwoFingers,
                emuKeyThreeFingers      = c.emuKeyThreeFingers,
                emuKeySwipeU            = c.emuKeySwipeU,
                emuKeySwipeR            = c.emuKeySwipeR,
                emuKeySwipeD            = c.emuKeySwipeD,
                emuKeySwipeL            = c.emuKeySwipeL,
                emuKeyTwistR            = c.emuKeyTwistR,
                emuKeyTwistL            = c.emuKeyTwistL,
                emuKeyPinch             = c.emuKeyPinch,
                emuKeySpread            = c.emuKeySpread,
                emuMouseTwoFingersKey   = c.emuMouseTwoFingersKey,
                emuMouseTwistKey        = c.emuMouseTwistKey,
                emuMousePinchKey        = c.emuMousePinchKey,
                emuMouseThreeFingersKey = c.emuMouseThreeFingersKey;

            ControlFreak2.SuperTouchZone.EmuMouseAxis
                emuMousePinchAxis = c.emuMousePinchAxis,
                emuMouseTwistAxis = c.emuMouseTwistAxis;

            float
                emuKeySwipeSpeed          = c.emuKeySwipeSpeed,
                emuKeyPinchSpeed          = c.emuKeyPinchSpeed,
                emuKeyTwistSpeed          = c.emuKeyTwistSpeed,
                mouseEmuTwistScreenFactor = c.mouseEmuTwistScreenFactor;



            if (InspectorUtils.BeginIndentedSection(new GUIContent("Touch Zone Settings"), ref this.settingsFoldedOut))
            {
                maxFingers = CFGUI.IntSlider(new GUIContent("Max finger number", "Maximal number of fingers allowed at the same time."),
                                             maxFingers, 1, ControlFreak2.SuperTouchZone.MAX_FINGERS, 120);

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



                if (maxFingers >= 2)
                {
                    EditorGUILayout.Space();

                    InspectorUtils.BeginIndentedSection(new GUIContent("Multi-finger Gesture Settings"));

                    strictMultiTouch = EditorGUILayout.ToggleLeft(new GUIContent("Strict multi-touch", "Use strict rules when detecting multi-finger touch gestures."),
                                                                  strictMultiTouch);

                    if (strictMultiTouch)
                    {
                        strictMultiTouchTime = CFGUI.FloatFieldEx(new GUIContent("Strict multi-touch time", "Time in milliseconds to wait for more fingers when starting a multi-finger touch. Touh zone will wait (and not report the fingers already pressed) until time runs out or any of the fingers already pressed moves."),
                                                                  strictMultiTouchTime, 0, 1.0f, 1000, true, 150);
                    }

                    freezeTwistWhenTooClose = EditorGUILayout.ToggleLeft(new GUIContent("Freeze twist when too close.", "Freeze Twist angle when two fingers get too close."),
                                                                         freezeTwistWhenTooClose);

                    EditorGUILayout.Space();

                    noPinchAfterDrag = EditorGUILayout.ToggleLeft(new GUIContent("No Pinch after Swipe.", "Don't allow Pinch gesture to activate after swipe has been detected."),
                                                                  noPinchAfterDrag);
                    noPinchAfterTwist = EditorGUILayout.ToggleLeft(new GUIContent("No Pinch after Twist.", "Don't allow Pinch gesture to activate after twist has been detected."),
                                                                   noPinchAfterTwist);

                    EditorGUILayout.Space();

                    noTwistAfterDrag = EditorGUILayout.ToggleLeft(new GUIContent("No Twist after Swipe.", "Don't allow Twist gesture to activate after swipe has been detected."),
                                                                  noTwistAfterDrag);
                    noTwistAfterPinch = EditorGUILayout.ToggleLeft(new GUIContent("No Twist after Pinch.", "Don't allow Twist gesture to activate after pinch has been detected."),
                                                                   noTwistAfterPinch);

                    EditorGUILayout.Space();

                    noDragAfterPinch = EditorGUILayout.ToggleLeft(new GUIContent("No Swipe after Pinch.", "Don't allow Swipe gesture to activate after pinch has been detected."),
                                                                  noDragAfterPinch);
                    noDragAfterTwist = EditorGUILayout.ToggleLeft(new GUIContent("No Swipe after Twist.", "Don't allow Swipe gesture to activate after twist has been detected."),
                                                                  noDragAfterTwist);

                    EditorGUILayout.Space();


                    startPinchWhenTwisting = EditorGUILayout.ToggleLeft(new GUIContent("Start Pinch when Twisting", "Auto-activate Pinch gesture when Twist gesture has been detected."),
                                                                        startPinchWhenTwisting);
                    startPinchWhenDragging = EditorGUILayout.ToggleLeft(new GUIContent("Start Pinch when Swiping", "Auto-activate Pinch gesture when Swipe gesture has been detected."),
                                                                        startPinchWhenDragging);
                    EditorGUILayout.Space();

                    startDragWhenPinching = EditorGUILayout.ToggleLeft(new GUIContent("Start Swipe when Pinching", "Auto-activate Swipe gesture when Pinch gesture has been detected."),
                                                                       startDragWhenPinching);
                    startDragWhenTwisting = EditorGUILayout.ToggleLeft(new GUIContent("Start Swipe when Twisting", "Auto-activate Swipe gesture when Twist gesture has been detected."),
                                                                       startDragWhenTwisting);
                    EditorGUILayout.Space();

                    startTwistWhenDragging = EditorGUILayout.ToggleLeft(new GUIContent("Start Twist when Swiping", "Auto-activate Twist esture when Swipe gesture has been detected."),
                                                                        startTwistWhenDragging);
                    startTwistWhenPinching = EditorGUILayout.ToggleLeft(new GUIContent("Start Twist when Pinching", "Auto-activate Twist gesture when Pinching gesture has been detected."),
                                                                        startTwistWhenPinching);
                    EditorGUILayout.Space();



                    gestureDetectionOrder = (SuperTouchZone.GestureDetectionOrder)CFGUI.EnumPopup(new GUIContent("Gesture detect. order",
                                                                                                                 "Gesture Detection Order. Useful is you don't allow some gesture combinations at the same time."), gestureDetectionOrder, 130);

                    InspectorUtils.EndIndentedSection();
                }


                // Thresholds...

                EditorGUILayout.Space();

                this.touchThreshInsp.DrawGUI(c.customThresh);

                // Finger configs...

                for (int i = 0; i < Mathf.Min(c.maxFingers, this.multiFingerConfigInspArray.Length); ++i)
                {
                    EditorGUILayout.Space();

                    this.multiFingerConfigInspArray[i].DrawConfigGUI(c.multiFingerConfigs[i]);
                }



                InspectorUtils.EndIndentedSection();
            }



            EditorGUILayout.Space();

            if (InspectorUtils.BeginIndentedSection(new GUIContent("Touch Zone Bindings"), ref this.multiFingerBindingsFoldedOut))
            {
                //InspectorUtils.BeginIndentedSection(new GUIContent("Touch Zone Bindings"));
                //	if (InspectorUtils.BeginIndentedSection(new GUIContent("Multi-Finger Touch Bindings"), ref this.multiFingerBindingsFoldedOut))
                //		{


                for (int i = 0; i < Mathf.Min(c.maxFingers, this.multiFingerConfigInspArray.Length); ++i)
                {
                    this.multiFingerConfigInspArray[i].DrawBindingGUI(c.multiFingerConfigs[i]);
                    EditorGUILayout.Space();
                }

                //InspectorUtils.EndIndentedSection();
                //}

                if (maxFingers >= 2)
                {
                    if (InspectorUtils.BeginIndentedSection(new GUIContent("Twist and Pinch Bindings"), ref this.twistAndPinchBindingFoldedOut))
                    {
                        this.twistAnalogBindingInsp.Draw(c.twistAnalogBinding, c.rig);
                        this.twistDeltaBindingInsp.Draw(c.twistDeltaBinding, c.rig);
                        //this.twistKeyBindingInsp.Draw(c.twistKeyBinding, c.rig);

                        this.twistRightDigitalBindingInsp.Draw(c.twistRightDigitalBinding, c.rig);
                        this.twistLeftDigitalBindingInsp.Draw(c.twistLeftDigitalBinding, c.rig);

                        this.twistScrollDeltaBindingInsp.Draw(c.twistScrollDeltaBinding, c.rig);


                        EditorGUILayout.Space();

                        this.pinchAnalogBindingInsp.Draw(c.pinchAnalogBinding, c.rig);
                        this.pinchDeltaBindingInsp.Draw(c.pinchDeltaBinding, c.rig);
                        //this.pinchKeyBindingInsp.Draw(c.pinchKeyBinding, c.rig);

                        this.pinchDigitalBindingInsp.Draw(c.pinchDigitalBinding, c.rig);
                        this.spreadDigitalBindingInsp.Draw(c.spreadDigitalBinding, c.rig);

                        this.pinchScrollDeltaBindingInsp.Draw(c.pinchScrollDeltaBinding, c.rig);

                        InspectorUtils.EndIndentedSection();
                    }
                }


                EditorGUILayout.Space();

                InspectorUtils.BeginIndentedSection(new GUIContent("Misc. Touch Zone Bindings"));


                this.separateFingersAsEmuTouchesBindingInsp.Draw(c.separateFingersAsEmuTouchesBinding, c.rig);

                InspectorUtils.EndIndentedSection();

                InspectorUtils.EndIndentedSection();
            }


            EditorGUILayout.Space();


            if (InspectorUtils.BeginIndentedSection(new GUIContent("Keyboard Settings"), ref this.keyboardFoldedOut))
            {
                emuWithKeys = EditorGUILayout.ToggleLeft(new GUIContent("Keyboard control", "Use keyboard to control this touch control."),
                                                         emuWithKeys);

                const float KEY_LABEL_WIDTH = 120;

                if (emuWithKeys)
                {
                    emuKeyOneFinger = (KeyCode)CFGUI.EnumPopup(new GUIContent("One Finger Press", "Static press with one finger."),
                                                               emuKeyOneFinger, KEY_LABEL_WIDTH);

                    if (maxFingers >= 2)
                    {
                        emuKeyTwoFingers = (KeyCode)CFGUI.EnumPopup(new GUIContent("Two Finger Press", "Static press with two fingers."),
                                                                    emuKeyTwoFingers, KEY_LABEL_WIDTH);
                    }

                    if (maxFingers >= 3)
                    {
                        emuKeyThreeFingers = (KeyCode)CFGUI.EnumPopup(new GUIContent("Three Finger Press", "Static press with three fingers."),
                                                                      emuKeyThreeFingers, KEY_LABEL_WIDTH);
                    }

                    EditorGUILayout.Space();

                    emuKeySwipeU = (KeyCode)CFGUI.EnumPopup(new GUIContent("Swipe Up", "Swipe Up.\nNote: you can start a multi-finger press with one of keys defined above and then simulate swipe with one of these keys."),
                                                            emuKeySwipeU, KEY_LABEL_WIDTH);
                    emuKeySwipeR = (KeyCode)CFGUI.EnumPopup(new GUIContent("Swipe Right", "Swipe Right.\nNote: you can start a multi-finger press with one of keys defined above and then simulate swipe with one of these keys."),
                                                            emuKeySwipeR, KEY_LABEL_WIDTH);
                    emuKeySwipeD = (KeyCode)CFGUI.EnumPopup(new GUIContent("Swipe Down", "Swipe Down.\nNote: you can start a multi-finger press with one of keys defined above and then simulate swipe with one of these keys."),
                                                            emuKeySwipeD, KEY_LABEL_WIDTH);
                    emuKeySwipeL = (KeyCode)CFGUI.EnumPopup(new GUIContent("Swipe Left", "Swipe Left.\nNote: you can start a multi-finger press with one of keys defined above and then simulate swipe with one of these keys."),
                                                            emuKeySwipeL, KEY_LABEL_WIDTH);


                    if (maxFingers >= 2)
                    {
                        EditorGUILayout.Space();

                        emuKeyTwistR = (KeyCode)CFGUI.EnumPopup(new GUIContent("Twist Right", "Start a two-finger press and twist clockwise.\nNote: This can be combined with pinching and swiping!"),
                                                                emuKeyTwistR, KEY_LABEL_WIDTH);
                        emuKeyTwistL = (KeyCode)CFGUI.EnumPopup(new GUIContent("Twist Left", "Start a two-finger press and twist counter-colckwise.\nNote: This can be combined with pinching and swiping!"),
                                                                emuKeyTwistL, KEY_LABEL_WIDTH);

                        emuKeyPinch = (KeyCode)CFGUI.EnumPopup(new GUIContent("Pinch", "Start a two-finger press and pinch them together.\nNote: This can be combined with twisting and swiping!"),
                                                               emuKeyPinch, KEY_LABEL_WIDTH);
                        emuKeySpread = (KeyCode)CFGUI.EnumPopup(new GUIContent("Spread", "Start a two-finger press and spread them apart.\nNote: This can be combined with twisting and swiping!"),
                                                                emuKeySpread, KEY_LABEL_WIDTH);

                        emuKeySwipeSpeed = CFGUI.Slider(new GUIContent("Key Swipe Speed", "Keyboard swipe speed in screen widths per second."),
                                                        emuKeySwipeSpeed, 0.1f, 1.0f, KEY_LABEL_WIDTH);
                        emuKeyPinchSpeed = CFGUI.Slider(new GUIContent("Key Pinch Speed", "Keyboard pinch speed in screen widths per second."),
                                                        emuKeyPinchSpeed, 0.1f, 1.0f, KEY_LABEL_WIDTH);
                        emuKeyTwistSpeed = CFGUI.Slider(new GUIContent("Key Twist Speed", "Keyboard twist speed in degrees per second."),
                                                        emuKeyTwistSpeed, 25, 360, KEY_LABEL_WIDTH);


                        EditorGUILayout.Space();

                        emuMouseTwoFingersKey = (KeyCode)CFGUI.EnumPopup(new GUIContent("2-finger mouse mod.", "Holding this key and clicking with a mouse will start two virtual touches."),
                                                                         emuMouseTwoFingersKey, KEY_LABEL_WIDTH);

                        if (maxFingers >= 3)
                        {
                            emuMouseThreeFingersKey = (KeyCode)CFGUI.EnumPopup(new GUIContent("3-finger mouse mod.", "Holding this key and clicking with a mouse will start three virtual touches."),
                                                                               emuMouseThreeFingersKey, KEY_LABEL_WIDTH);
                        }

                        EditorGUILayout.Space();

                        emuMouseTwistKey = (KeyCode)CFGUI.EnumPopup(new GUIContent("Twist mouse mod.", "Twist mouse modifier. Holding this key and clicking with a mouse will start two virtual touches. Dragging the mouse along axis selected below will simulate twist."),
                                                                    emuMouseTwistKey, KEY_LABEL_WIDTH);

                        emuMousePinchKey = (KeyCode)CFGUI.EnumPopup(new GUIContent("Pinch mouse mod.", "Pinch mouse modifier. Holding this key and clicking with a mouse will start two virtual touches. Dragging the mouse along axis selected below will simulate pinch."),
                                                                    emuMousePinchKey, KEY_LABEL_WIDTH);

                        emuMouseTwistAxis = (ControlFreak2.SuperTouchZone.EmuMouseAxis)CFGUI.EnumPopup(new GUIContent("Mouse twist axis", "Select mouse drag axis to simulate twist.\nNote: If twist and pinch axes are not the same, twist and pinch mouse modifers can be combined to twist and pinch with a mouse at the same time."),
                                                                                                       emuMouseTwistAxis, KEY_LABEL_WIDTH);
                        emuMousePinchAxis = (ControlFreak2.SuperTouchZone.EmuMouseAxis)CFGUI.EnumPopup(new GUIContent("Mouse pinch axis", "Select mouse drag axis to simulate pinch.\nNote: If twist and pinch axes are not the same, twist and pinch mouse modifers can be combined to twist and pinch with a mouse at the same time."),
                                                                                                       emuMousePinchAxis, KEY_LABEL_WIDTH);


                        mouseEmuTwistScreenFactor = CFGUI.Slider(new GUIContent("Mouse Twist Factor", "Fraction of screen width to drag to twist virtual fingers by 360 degrees."),
                                                                 mouseEmuTwistScreenFactor, 0.2f, 1.0f, KEY_LABEL_WIDTH);
                    }
                }

                InspectorUtils.EndIndentedSection();
            }


            // Register undo...



            if ((maxFingers != c.maxFingers) ||
                (touchSmoothing != c.touchSmoothing) ||
                (strictMultiTouchTime != c.strictMultiTouchTime) ||
                (strictMultiTouch != c.strictMultiTouch) ||
                (freezeTwistWhenTooClose != c.freezeTwistWhenTooClose) ||
                (noPinchAfterDrag != c.noPinchAfterDrag) ||
                (noPinchAfterTwist != c.noPinchAfterTwist) ||
                (noTwistAfterDrag != c.noTwistAfterDrag) ||
                (noTwistAfterPinch != c.noTwistAfterPinch) ||
                (noDragAfterPinch != c.noDragAfterPinch) ||
                (noDragAfterTwist != c.noDragAfterTwist) ||
                (startPinchWhenTwisting != c.startPinchWhenTwisting) ||
                (startPinchWhenDragging != c.startPinchWhenDragging) ||
                (startDragWhenPinching != c.startDragWhenPinching) ||
                (startDragWhenTwisting != c.startDragWhenTwisting) ||
                (startTwistWhenDragging != c.startTwistWhenDragging) ||
                (startTwistWhenPinching != c.startTwistWhenPinching) ||
                (gestureDetectionOrder != c.gestureDetectionOrder) ||
                //(bindSeparateFingersToEmuTouches	!= c.bindSeparateFingersToEmuTouches) ||
//			(twistBindMode			!= c.twistBindMode) ||
//			(pinchBindMode			!= c.pinchBindMode) ||
                (emuWithKeys != c.emuWithKeys) ||
                (emuKeyOneFinger != c.emuKeyOneFinger) ||
                (emuKeyTwoFingers != c.emuKeyTwoFingers) ||
                (emuKeyThreeFingers != c.emuKeyThreeFingers) ||
                (emuKeySwipeU != c.emuKeySwipeU) ||
                (emuKeySwipeR != c.emuKeySwipeR) ||
                (emuKeySwipeD != c.emuKeySwipeD) ||
                (emuKeySwipeL != c.emuKeySwipeL) ||
                (emuKeyTwistR != c.emuKeyTwistR) ||
                (emuKeyTwistL != c.emuKeyTwistL) ||
                (emuKeyPinch != c.emuKeyPinch) ||
                (emuKeySpread != c.emuKeySpread) ||
                (emuMouseTwoFingersKey != c.emuMouseTwoFingersKey) ||
                (emuMouseTwistKey != c.emuMouseTwistKey) ||
                (emuMousePinchKey != c.emuMousePinchKey) ||
                (emuMouseThreeFingersKey != c.emuMouseThreeFingersKey) ||
                (emuMousePinchAxis != c.emuMousePinchAxis) ||
                (emuMouseTwistAxis != c.emuMouseTwistAxis) ||
                (emuKeySwipeSpeed != c.emuKeySwipeSpeed) ||
                (emuKeyPinchSpeed != c.emuKeyPinchSpeed) ||
                (emuKeyTwistSpeed != c.emuKeyTwistSpeed) ||
                (mouseEmuTwistScreenFactor != c.mouseEmuTwistScreenFactor))
            {
                CFGUI.CreateUndo("CF2 Touch Zone modification", c);

                c.maxFingers              = maxFingers;
                c.strictMultiTouchTime    = strictMultiTouchTime;
                c.strictMultiTouch        = strictMultiTouch;
                c.freezeTwistWhenTooClose = freezeTwistWhenTooClose;
                c.noPinchAfterDrag        = noPinchAfterDrag;
                c.noPinchAfterTwist       = noPinchAfterTwist;
                c.noTwistAfterDrag        = noTwistAfterDrag;
                c.noTwistAfterPinch       = noTwistAfterPinch;
                c.noDragAfterPinch        = noDragAfterPinch;
                c.noDragAfterTwist        = noDragAfterTwist;
                c.startPinchWhenTwisting  = startPinchWhenTwisting;
                c.startPinchWhenDragging  = startPinchWhenDragging;
                c.startDragWhenPinching   = startDragWhenPinching;
                c.startDragWhenTwisting   = startDragWhenTwisting;
                c.startTwistWhenDragging  = startTwistWhenDragging;
                c.startTwistWhenPinching  = startTwistWhenPinching;
                c.gestureDetectionOrder   = gestureDetectionOrder;

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


                c.emuWithKeys               = emuWithKeys;
                c.emuKeyOneFinger           = emuKeyOneFinger;
                c.emuKeyTwoFingers          = emuKeyTwoFingers;
                c.emuKeyThreeFingers        = emuKeyThreeFingers;
                c.emuKeySwipeU              = emuKeySwipeU;
                c.emuKeySwipeR              = emuKeySwipeR;
                c.emuKeySwipeD              = emuKeySwipeD;
                c.emuKeySwipeL              = emuKeySwipeL;
                c.emuKeyTwistR              = emuKeyTwistR;
                c.emuKeyTwistL              = emuKeyTwistL;
                c.emuKeyPinch               = emuKeyPinch;
                c.emuKeySpread              = emuKeySpread;
                c.emuMouseTwoFingersKey     = emuMouseTwoFingersKey;
                c.emuMouseTwistKey          = emuMouseTwistKey;
                c.emuMousePinchKey          = emuMousePinchKey;
                c.emuMouseThreeFingersKey   = emuMouseThreeFingersKey;
                c.emuMousePinchAxis         = emuMousePinchAxis;
                c.emuMouseTwistAxis         = emuMouseTwistAxis;
                c.emuKeySwipeSpeed          = emuKeySwipeSpeed;
                c.emuKeyPinchSpeed          = emuKeyPinchSpeed;
                c.emuKeyTwistSpeed          = emuKeyTwistSpeed;
                c.mouseEmuTwistScreenFactor = mouseEmuTwistScreenFactor;



                CFGUI.EndUndo(c);
            }


            // Draw Shared Control Params...

            this.DrawTouchContolGUI(c);
        }
コード例 #25
0
        // ---------------
        public void Draw(SpriteConfig target, Object undoObject, bool skipTransforms, bool canBeDisabled = true)
        {
            bool
                enabled = target.enabled;
            Color
                color = target.color;
            Sprite
                sprite = target.sprite;
            float
                rotation = target.rotation,
                scale    = target.scale;
            Vector2
                offset = target.offset;
            bool
                resetOffset   = target.resetOffset,
                resetScale    = target.resetScale,
                resetRotation = target.resetRotation;

            float
                baseTransitionTime       = target.baseTransitionTime,
                colorTransitionFactor    = target.colorTransitionFactor,
                offsetTransitionFactor   = target.offsetTransitionFactor,
                rotationTransitionFactor = target.rotationTransitionFactor,
                scaleTransitionFactor    = target.scaleTransitionFactor,
                duration = target.duration;


            if (!canBeDisabled)
            {
                enabled = true;
            }

            Color initialGuiColor = GUI.color;


            EditorGUILayout.BeginVertical(CFEditorStyles.Inst.transpBevelBG);

            EditorGUILayout.BeginVertical();


            GUI.enabled = canBeDisabled;
            enabled     = EditorGUILayout.ToggleLeft(labelContent, enabled, CFEditorStyles.Inst.boldText, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));
            GUI.enabled = true;


            if (enabled)
            {
#if UNITY_PRE_5_2
                color  = EditorGUILayout.ColorField(color, GUILayout.ExpandWidth(true));
                sprite = (Sprite)EditorGUILayout.ObjectField(sprite, typeof(Sprite), false);
#else
                EditorGUILayout.BeginHorizontal();
                color  = EditorGUILayout.ColorField(color, GUILayout.ExpandWidth(true));
                sprite = (Sprite)EditorGUILayout.ObjectField(sprite, typeof(Sprite), false, GUILayout.Width(64), GUILayout.Height(64));
                EditorGUILayout.EndHorizontal();
#endif
            }



//			EditorGUILayout.BeginHorizontal();
//				//GUILayout.Label(labelContent, CFEditorStyles.Inst.boldText, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true));

//				if (enabled)
//					color = EditorGUILayout.ColorField(color,  GUILayout.ExpandWidth(true));

//			if (enabled)
//				{
//#if UNITY_PRE_5_2
//				sprite = (Sprite)EditorGUILayout.ObjectField(sprite, typeof(Sprite), false);
//#else
//				sprite = (Sprite)EditorGUILayout.ObjectField(sprite, typeof(Sprite), false, GUILayout.Width(64), GUILayout.Height(64));
//#endif
//				}
//			EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            if (enabled)
            {
                if (target.oneShotState)
                {
                    duration = CFGUI.FloatFieldEx(new GUIContent("Duration", "Duration if this one-shot state in milliseconds."),
                                                  duration, 0, 100, 1000, true, 120);
                }

                baseTransitionTime = CFGUI.FloatFieldEx(new GUIContent("Base transition time", "Base transition time in milliseconds to all transtions below..."),
                                                        baseTransitionTime, 0, 100, 1000, true, 120);

                colorTransitionFactor = CFGUI.Slider(new GUIContent("Color Transition", "Color Transition as a fraction on the Base Transition Time."),
                                                     colorTransitionFactor, 0, 1, 120);
                offsetTransitionFactor = CFGUI.Slider(new GUIContent("Offset Transition", "Offset Transition as a fraction on the Base Transition Time."),
                                                      offsetTransitionFactor, 0, 1, 120);
                rotationTransitionFactor = CFGUI.Slider(new GUIContent("Rotation Transition", "Rotation Transition as a fraction on the Base Transition Time."),
                                                        rotationTransitionFactor, 0, 1, 120);
                scaleTransitionFactor = CFGUI.Slider(new GUIContent("Scale Transition", "Scale Transition as a fraction on the Base Transition Time."),
                                                     scaleTransitionFactor, 0, 1, 120);


                if (!skipTransforms)
                {
                    EditorGUILayout.Space();

                    resetScale = EditorGUILayout.ToggleLeft(new GUIContent("Reset Scale", "Reset scale on start."),
                                                            resetScale, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));
                    scale = CFGUI.FloatField(new GUIContent("Scale", "State specific scale"),
                                             scale, 0, 100, 80);

                    EditorGUILayout.Space();

                    resetRotation = EditorGUILayout.ToggleLeft(new GUIContent("Reset Rotation", "Reset rotation on start."),
                                                               resetRotation, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));
                    rotation = CFGUI.FloatField(new GUIContent("Rotation", "State specific rotation"),
                                                rotation, -10000, 10000, 80);
                    EditorGUILayout.Space();

                    resetOffset = EditorGUILayout.ToggleLeft(new GUIContent("Reset Offset", "Reset Offset on start."),
                                                             resetOffset, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30));

                    offset.x = CFGUI.FloatField(new GUIContent("Offset X", "State specific offset X"),
                                                offset.x, -1000000, 100000, 80);
                    offset.y = CFGUI.FloatField(new GUIContent("Offset Y", "State specific offset X"),
                                                offset.y, -1000000, 100000, 80);
                }
            }


            EditorGUILayout.EndVertical();



            GUI.color = initialGuiColor;


            // Record undo...

            if ((enabled != target.enabled) ||
                (color != target.color) ||
                (rotation != target.rotation) ||
                (scale != target.scale) ||
                (offset != target.offset) ||
                (sprite != target.sprite) ||
                (resetOffset != target.resetOffset) ||
                (resetScale != target.resetScale) ||
                (resetRotation != target.resetRotation) ||
                (baseTransitionTime != target.baseTransitionTime) ||
                (colorTransitionFactor != target.colorTransitionFactor) ||
                (offsetTransitionFactor != target.offsetTransitionFactor) ||
                (rotationTransitionFactor != target.rotationTransitionFactor) ||
                (scaleTransitionFactor != target.scaleTransitionFactor) ||
                (duration != target.duration))
            {
                CFGUI.CreateUndo("Modify sprite config for " + undoObject.name, undoObject);

                target.enabled  = enabled;
                target.color    = color;
                target.sprite   = sprite;
                target.scale    = scale;
                target.rotation = rotation;
                target.offset   = offset;

                target.resetOffset   = resetOffset;
                target.resetScale    = resetScale;
                target.resetRotation = resetRotation;


                target.baseTransitionTime       = baseTransitionTime;
                target.colorTransitionFactor    = colorTransitionFactor;
                target.offsetTransitionFactor   = offsetTransitionFactor;
                target.rotationTransitionFactor = rotationTransitionFactor;
                target.scaleTransitionFactor    = scaleTransitionFactor;
                target.duration = duration;


                CFGUI.EndUndo(undoObject);
            }
        }
コード例 #26
0
        // -------------------
        public void DrawTouchContolGUI(TouchControl c)
        {
            if (c == null)
            {
                return;
            }

            bool
                ignoreFingerRadius       = c.ignoreFingerRadius,
                cantBeControlledDirectly = c.cantBeControlledDirectly,
                shareTouch = c.shareTouch,
                dontAcceptSharedTouches = c.dontAcceptSharedTouches,
                canBeSwipedOver         = c.canBeSwipedOver,
                restictSwipeOverTargets = c.restictSwipeOverTargets;

            TouchControl.SwipeOverOthersMode
                swipeOverOthersMode = c.swipeOverOthersMode;
            TouchControl.SwipeOffMode
                swipeOffMode = c.swipeOffMode;
            TouchControl.Shape
                shape = c.shape;


            // GUI...

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

            shape = (TouchControl.Shape)CFGUI.EnumPopup(new GUIContent("Shape", "Control's shape"), shape, LABEL_WIDTH);

            ignoreFingerRadius = EditorGUILayout.ToggleLeft(new GUIContent("Ignore finger radius", "When enabled, this can only be hit by finger's center - finger's radius defined in Touch Control Panel will be ignored when hit testing."),
                                                            ignoreFingerRadius, GUILayout.MinWidth(30));

            cantBeControlledDirectly = EditorGUILayout.ToggleLeft(new GUIContent("Can't be touched directly", "When enabled, this control will not respond to direct touches, only to touches passed by it's dynamic region or other controls."),
                                                                  cantBeControlledDirectly, GUILayout.MinWidth(30));
            shareTouch = EditorGUILayout.ToggleLeft(new GUIContent("Touch-Through", "When touched, this control will pass it's controling touch down to control other controls below (if they accept shared touches)."),
                                                    shareTouch, GUILayout.MinWidth(30));
            dontAcceptSharedTouches = EditorGUILayout.ToggleLeft(new GUIContent("Don't accept shared touches", "When enabled, this control will not respond to touches already controlling other controls."),
                                                                 dontAcceptSharedTouches, GUILayout.MinWidth(30));

            EditorGUILayout.Space();

            canBeSwipedOver = EditorGUILayout.ToggleLeft(new GUIContent("Can be swiped over", "This control can be touched by swiping over it."),
                                                         canBeSwipedOver, GUILayout.MinWidth(30));

            swipeOffMode = (TouchControl.SwipeOffMode)CFGUI.EnumPopup(new GUIContent("Swipe Off", "Release when finger swipes off this control?"),
                                                                      swipeOffMode, 100);

            swipeOverOthersMode = (TouchControl.SwipeOverOthersMode)CFGUI.EnumPopup(new GUIContent("Swipe Over Others", "When to allow swiping over other controls?"),
                                                                                    swipeOverOthersMode, 100);



            if (swipeOverOthersMode != TouchControl.SwipeOverOthersMode.Disabled)
            {
                restictSwipeOverTargets = EditorGUILayout.ToggleLeft(new GUIContent("Restrict Swipe Over Targets", "Choose specific controls that can be swiped over from this control..."),
                                                                     restictSwipeOverTargets, GUILayout.MinWidth(30));

                if (restictSwipeOverTargets)
                {
                    this.swipeOverTargetListInsp.DrawGUI();
                }
            }


            InspectorUtils.EndIndentedSection();



            // Hiding conditions section...

            this.disablingConditionSetInsp.DrawGUI();



            // Refister undo...

            if (
                (ignoreFingerRadius != c.ignoreFingerRadius) ||
                (cantBeControlledDirectly != c.cantBeControlledDirectly) ||
                (shareTouch != c.shareTouch) ||
                (shareTouch != c.shareTouch) ||
                (dontAcceptSharedTouches != c.dontAcceptSharedTouches) ||

                (canBeSwipedOver != c.canBeSwipedOver) ||
                (swipeOffMode != c.swipeOffMode) ||
                (swipeOverOthersMode != c.swipeOverOthersMode) ||
                (restictSwipeOverTargets != c.restictSwipeOverTargets) ||

                (shape != c.shape))
            {
                CFGUI.CreateUndo("Touch Control Base Param modification", c);

                c.ignoreFingerRadius       = ignoreFingerRadius;
                c.cantBeControlledDirectly = cantBeControlledDirectly;
                c.shareTouch = shareTouch;
                c.dontAcceptSharedTouches = dontAcceptSharedTouches;
                c.shape = shape;

                c.canBeSwipedOver         = canBeSwipedOver;
                c.swipeOffMode            = swipeOffMode;
                c.swipeOverOthersMode     = swipeOverOthersMode;
                c.restictSwipeOverTargets = restictSwipeOverTargets;


                CFGUI.EndUndo(c);
            }
        }
コード例 #27
0
        // ------------------
        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);
            }
        }
コード例 #28
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);
            }
        }
コード例 #29
0
        // -----------------
        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);
            }
        }
コード例 #30
0
        // ------------------
        public void Draw(TouchGestureStateBinding bind, TouchGestureConfig config, InputRig rig)
        {
            bool bindingEnabled = bind.enabled;


            //EditorGUILayout.BeginVertical();

            //if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30), GUILayout.ExpandWidth(true)))
            //	{
            //	CFGUI.BeginIndentedVertical();

            if (InspectorUtils.BeginIndentedCheckboxSection(this.labelContent, ref bindingEnabled))
            {
                InspectorUtils.BeginIndentedSection(new GUIContent("Press bindings"));

                this.rawPressBinding.Draw(bind.rawPressBinding, rig);
                this.rawPressMousePosBindingInsp.Draw(bind.rawPressMousePosBinding, rig);
                EditorGUILayout.Space();

                this.normalPressBinding.Draw(bind.normalPressBinding, rig);
                this.normalPressMousePosBindingInsp.Draw(bind.normalPressMousePosBinding, rig);
                EditorGUILayout.Space();

                if ((config == null) || config.detectLongPress)
                {
                    this.longPressBinding.Draw(bind.longPressBinding, rig);
                    this.longPressMousePosBindingInsp.Draw(bind.longPressMousePosBinding, rig);
                }

                EditorGUILayout.Space();

                this.rawPressEmuTouchInsp.Draw(bind.rawPressEmuTouchBinding, rig);
                this.normalPressEmuTouchInsp.Draw(bind.normalPressEmuTouchBinding, rig);

                if ((config == null) || config.detectLongPress)
                {
                    this.longPressEmuTouchInsp.Draw(bind.longPressEmuTouchBinding, rig);
                }


                InspectorUtils.EndIndentedSection();

                if ((config == null) || (config.maxTapCount >= 1) || (config.detectLongTap))
                {
                    InspectorUtils.BeginIndentedSection(new GUIContent("Tap bindings"));

                    if ((config == null) || (config.maxTapCount >= 1))
                    {
                        this.tapBinding.Draw(bind.tapBinding, rig);
                        this.tapMousePosBindingInsp.Draw(bind.tapMousePosBinding, rig);
                        EditorGUILayout.Space();
                    }

                    if ((config == null) || (config.maxTapCount >= 2))
                    {
                        this.doubleTapBinding.Draw(bind.doubleTapBinding, rig);
                        this.doubleTapMousePosBindingInsp.Draw(bind.doubleTapMousePosBinding, rig);
                        EditorGUILayout.Space();
                    }


                    if ((config == null) || (config.detectLongPress && config.detectLongTap))
                    {
                        this.longTapBinding.Draw(bind.longTapBinding, rig);
                        this.longTapMousePosBindingInsp.Draw(bind.longTapMousePosBinding, rig);
                        EditorGUILayout.Space();
                    }

                    InspectorUtils.EndIndentedSection();
                }


                InspectorUtils.BeginIndentedSection(new GUIContent("Swipe bindings"));

                this.normalPressSwipeHorzAxisBinding.Draw(bind.normalPressSwipeHorzAxisBinding, rig);
                this.normalPressSwipeVertAxisBinding.Draw(bind.normalPressSwipeVertAxisBinding, rig);
                this.normalPressSwipeMousePosBindingInsp.Draw(bind.normalPressSwipeMousePosBinding, rig);
                this.normalPressSwipeDirBinding.Draw(bind.normalPressSwipeDirBinding, rig);
                this.normalPressSwipeJoyBinding.Draw(bind.normalPressSwipeJoyBinding, rig);

                if ((config == null) || config.detectLongPress)
                {
                    this.longPressSwipeHorzAxisBinding.Draw(bind.longPressSwipeHorzAxisBinding, rig);
                    this.longPressSwipeVertAxisBinding.Draw(bind.longPressSwipeVertAxisBinding, rig);
                    this.longPressSwipeMousePosBindingInsp.Draw(bind.longPressSwipeMousePosBinding, rig);
                    this.longPressSwipeDirBinding.Draw(bind.longPressSwipeDirBinding, rig);
                    this.longPressSwipeJoyBinding.Draw(bind.longPressSwipeJoyBinding, rig);
                }

                InspectorUtils.EndIndentedSection();

                InspectorUtils.BeginIndentedSection(new GUIContent("Scroll bindings"));
                this.normalPressScrollHorzBinding.Draw(bind.normalPressScrollHorzBinding, rig);
                this.normalPressScrollVertBinding.Draw(bind.normalPressScrollVertBinding, rig);

                if ((config == null) || config.detectLongPress)
                {
                    this.longPressScrollHorzBinding.Draw(bind.longPressScrollHorzBinding, rig);
                    this.longPressScrollVertBinding.Draw(bind.longPressScrollVertBinding, rig);
                }
                InspectorUtils.EndIndentedSection();



                if (this.customPostGUICallback != null)
                {
                    InspectorUtils.BeginIndentedSection(new GUIContent("Other"));

                    this.customPostGUICallback();

                    InspectorUtils.EndIndentedSection();
                }


                InspectorUtils.EndIndentedSection();
                //CFGUI.EndIndentedVertical();
                //GUILayout.Space(InputBindingGUIUtils.VERT_MARGIN);
            }

            //EditorGUILayout.EndVertical();



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

                bind.enabled = bindingEnabled;

                CFGUI.EndUndo(this.undoObject);
            }
        }