// --------------- 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; // 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.releasedBindingInsp.Draw(c.releasedBinding, 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) || (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; CFGUI.EndUndo(c); } // Draw Shared Dynamic Control Params... this.DrawDynamicTouchControlGUI(c); }
// ----------------- 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); const string initialPosTooltip = "Normalized position that the control will center itself after being activated by a touch.\n" + "Default if (0,0) (center)."; if (centerOnDirectTouch) { 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(); } if (centerOnIndirectTouch) { 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); } }
// ------------------- 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); } }
// --------------- public void DrawGUI(TouchGestureConfig config) { int maxTapCount = config.maxTapCount; bool cleanTapsOnly = config.cleanTapsOnly, detectLongTap = config.detectLongTap, detectLongPress = config.detectLongPress, endLongPressWhenMoved = config.endLongPressWhenMoved, endLongPressWhenSwiped = config.endLongPressWhenSwiped; TouchGestureConfig.DirMode dirMode = config.dirMode; TouchGestureConfig.DirConstraint swipeConstraint = config.swipeConstraint, swipeDirConstraint = config.swipeDirConstraint, scrollConstraint = config.scrollConstraint; DirectionState.OriginalDirResetMode swipeOriginalDirResetMode = config.swipeOriginalDirResetMode; // GUI... InspectorUtils.BeginIndentedSection(this.titleContent); maxTapCount = CFGUI.IntSlider(new GUIContent("Max Number of Taps", "Maximal number of consecutive taps to detect.\nWhen \'Report All Taps\' option is turned off, system will wait for potential follow-up taps so they may be reported with slight delay."), maxTapCount, 0, 5, LABEL_WIDTH); dirMode = (TouchGestureConfig.DirMode)CFGUI.EnumPopup(new GUIContent("Swipe Dir. Mode", "Swipe Segmwnt Direction Mode"), dirMode, LABEL_WIDTH); swipeOriginalDirResetMode = (DirectionState.OriginalDirResetMode)CFGUI.EnumPopup(new GUIContent("Swipe Dir. Reset Mode", "Swipe Segment's Original Direction Reset Mode - choose when original direction is reset. This option is used by Direction Binding in ORIGINAL group modes..."), swipeOriginalDirResetMode, LABEL_WIDTH); swipeDirConstraint = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Scroll Dir Constraint", "Scroll Direction Constraint Mode"), swipeDirConstraint, LABEL_WIDTH); swipeConstraint = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Swipe Constraint", "Swipe Constraint Mode"), swipeConstraint, LABEL_WIDTH); scrollConstraint = (TouchGestureConfig.DirConstraint)CFGUI.EnumPopup(new GUIContent("Scroll Constraint", "Scroll Constraint Mode"), scrollConstraint, LABEL_WIDTH); cleanTapsOnly = EditorGUILayout.ToggleLeft(new GUIContent("Clean Taps Only", "When turned on, only clean taps will be reported."), cleanTapsOnly); detectLongPress = EditorGUILayout.ToggleLeft(new GUIContent("Detect Long Press", "Long Press is a static touch (tap threshold) pressed for some time (Long Press Min. Duration)."), detectLongPress); if (detectLongPress) { detectLongTap = EditorGUILayout.ToggleLeft(new GUIContent("Detect Long Tap", ""), detectLongTap); endLongPressWhenMoved = EditorGUILayout.ToggleLeft(new GUIContent("End Long Press When Moved", "End Long Press (and start Normal Press) when touch moved past the Tap Threshold."), endLongPressWhenMoved); endLongPressWhenSwiped = EditorGUILayout.ToggleLeft(new GUIContent("End Long Press When Swiped", "End Long Press (and start Normal Press) when touch moved past the Swipe Threshold."), endLongPressWhenSwiped); } InspectorUtils.EndIndentedSection(); // Register Undo... if ((maxTapCount != config.maxTapCount) || (cleanTapsOnly != config.cleanTapsOnly) || (detectLongTap != config.detectLongTap) || (detectLongPress != config.detectLongPress) || (dirMode != config.dirMode) || (swipeConstraint != config.swipeConstraint) || (swipeDirConstraint != config.swipeDirConstraint) || (scrollConstraint != config.scrollConstraint) || (swipeOriginalDirResetMode != config.swipeOriginalDirResetMode) || (endLongPressWhenSwiped != config.endLongPressWhenSwiped) || (endLongPressWhenMoved != config.endLongPressWhenMoved)) { CFGUI.CreateUndo("Gesture Config modification", this.undoObject); config.dirMode = dirMode; config.swipeConstraint = swipeConstraint; config.swipeDirConstraint = swipeDirConstraint; config.scrollConstraint = scrollConstraint; config.maxTapCount = maxTapCount; config.cleanTapsOnly = cleanTapsOnly; config.detectLongPress = detectLongPress; config.detectLongTap = detectLongTap; config.endLongPressWhenMoved = endLongPressWhenMoved; config.endLongPressWhenSwiped = endLongPressWhenSwiped; config.swipeOriginalDirResetMode = swipeOriginalDirResetMode; CFGUI.EndUndo(this.undoObject); } }
// ------------------ public void DrawGUI() { if (this.elemInspList.Count != this.targetList.Count) { //Debug.Log("[" + Time.frameCount + "] Rebuilding list onGUI (" + this.GetType() + ")!"); this.Rebuild(); } EditorGUILayout.BeginVertical(); // Draw header... Color initialBgColor = GUI.backgroundColor; GUI.backgroundColor = InspectorUtils.SectionHeaderColor; EditorGUILayout.BeginHorizontal(InspectorUtils.SectionHeaderStyle); GUI.backgroundColor = initialBgColor; //this.isFoldedOut = EditorGUILayout.Foldout(this.isFoldedOut, this.GetListTitleContent(), CFEditorStyles.Inst.foldout, ); if (this.isFoldable) { this.isFoldedOut = GUILayout.Toggle(this.isFoldedOut, this.GetListTitleContent(), CFEditorStyles.Inst.foldout, GUILayout.ExpandWidth(true), GUILayout.MinWidth(30)); } else { GUILayout.Label(this.GetListTitleContent(), GUILayout.ExpandWidth(true), GUILayout.MinWidth(30)); } EditorGUILayout.Space(); if (GUILayout.Button(new GUIContent("", CFEditorStyles.Inst.createNewTex, "Add new element..."), CFEditorStyles.Inst.iconButtonStyle, GUILayout.Width(BUTTON_WIDTH))) { this.OnNewElemClicked(); } EditorGUILayout.EndHorizontal(); // Draw elements... if (this.isFoldedOut) { if (this.elemInspList.Count == 0) { CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); EditorGUILayout.LabelField("List is empty.", CFEditorStyles.Inst.centeredTextTranspBG); CFGUI.EndIndentedVertical(); } else { CFGUI.BeginIndentedVertical(); for (int i = 0; i < this.elemInspList.Count; ++i) { if (!this.elemInspList[i].DrawGUI()) { break; } } CFGUI.EndIndentedVertical(); } } EditorGUILayout.EndVertical(); }
// ------------------ 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); } }
// ------------------ 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.BeginIndentedSection(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); } }
// --------------------- private void DrawBasicGUI(TouchGestureThresholds target) { //MultiTouchGestureThresholds multiTarget = (target as MultiTouchGestureThresholds); float tapMoveThreshCm = target.tapMoveThreshCm, tapPosThreshCm = target.tapPosThreshCm, dragThreshCm = target.dragThreshCm, scrollThreshCm = target.scrollThreshCm, scrollMagnetFactor = target.scrollMagnetFactor, swipeSegLenCm = target.swipeSegLenCm, swipeJoystickRadCm = target.swipeJoystickRadCm, //dragJoyDeadZone = target.dragJoyDeadZone, tapMaxDur = target.tapMaxDur, multiTapMaxTimeGap = target.multiTapMaxTimeGap, //longTapMinTime = target.longTapMinTime, longTapMaxDuration = target.longTapMaxDuration, longPressMinTime = target.longPressMinTime; // GUI... tapMoveThreshCm = CFGUI.FloatField(new GUIContent("Static Thresh. (cm)", "Static touch threshold - maximal allowed movement distance for touch to be counted as a static tap."), tapMoveThreshCm, 0.01f, 1.0f, LABEL_WIDTH); dragThreshCm = CFGUI.FloatField(new GUIContent("Swipe Thresh (cm)", "Minimal swipe distance in centimeters to activate that gesture. This value should be grater then the Static Threshold!"), dragThreshCm, 0.01f, 5.0f, LABEL_WIDTH); EditorGUILayout.Space(); scrollThreshCm = CFGUI.FloatField(new GUIContent("Scroll Step (cm)", "Swipe distance in centimeters for one scroll step"), scrollThreshCm, 0.01f, 5.0f, LABEL_WIDTH); scrollMagnetFactor = CFGUI.Slider(new GUIContent("Scroll Magnet", "Scroll magnet factor."), scrollMagnetFactor, 0, 0.5f, LABEL_WIDTH); EditorGUILayout.Space(); swipeSegLenCm = CFGUI.FloatField(new GUIContent("Swipe Segment Len. (cm)", "Swipe segment length in centimeters used to determinate changing direction of a single swipe."), swipeSegLenCm, 0.1f, 10.0f, LABEL_WIDTH); swipeJoystickRadCm = CFGUI.FloatField(new GUIContent("Swipe Joy Rad (cm)", "Swipe joystick radius in centimeters."), swipeJoystickRadCm, 0.1f, 10.0f, LABEL_WIDTH); EditorGUILayout.Space(); tapPosThreshCm = CFGUI.FloatField(new GUIContent("Max Tap Dist. (cm)", "Maximal allowed distance between consecutive taps."), tapPosThreshCm, 0.1f, 10.0f, LABEL_WIDTH); tapMaxDur = CFGUI.FloatFieldEx(new GUIContent("Tap Max. Duration", "Maximal allowed tap touch duration in milliseconds."), tapMaxDur, 0.02f, 1.0f, 1000, true, LABEL_WIDTH); multiTapMaxTimeGap = CFGUI.FloatFieldEx(new GUIContent("Tap Max. Gap", "Maximal allowed time \'gap\' between consecutive taps."), multiTapMaxTimeGap, 0.02f, 2.0f, 1000, true, LABEL_WIDTH); longPressMinTime = CFGUI.FloatFieldEx(new GUIContent("Long Press Min Time", "Minimal \'hold\' touch duration in milliseconds."), longPressMinTime, 0.02f, 1000f, 1000, true, LABEL_WIDTH); longTapMaxDuration = CFGUI.FloatFieldEx(new GUIContent("Long Tap Max Duration", "Maximal duration of a long tap in milliseconds."), longTapMaxDuration, 0.02f, 1000f, 1000, true, LABEL_WIDTH); // Register Undo... if ((tapMoveThreshCm != target.tapMoveThreshCm) || (tapPosThreshCm != target.tapPosThreshCm) || (dragThreshCm != target.dragThreshCm) || (scrollThreshCm != target.scrollThreshCm) || (scrollMagnetFactor != target.scrollMagnetFactor) || (swipeSegLenCm != target.swipeSegLenCm) || (swipeJoystickRadCm != target.swipeJoystickRadCm) || (tapMaxDur != target.tapMaxDur) || (multiTapMaxTimeGap != target.multiTapMaxTimeGap) || //(longTapMinTime != target.longTapMinTime) || (longTapMaxDuration != target.longTapMaxDuration) || (longPressMinTime != target.longPressMinTime)) // (chargeMinTime != target.chargeMinTime) || // (repeatDelay != target.repeatDelay) || // (repeatInterval != target.repeatInterval) || // (velSustainTime != target.velSustainTime)) { CFGUI.CreateUndo("Touch Gesture Thresholds modification", this.undoObject); target.tapMoveThreshCm = tapMoveThreshCm; target.tapPosThreshCm = tapPosThreshCm; target.dragThreshCm = dragThreshCm; target.scrollThreshCm = scrollThreshCm; target.scrollMagnetFactor = scrollMagnetFactor; target.swipeSegLenCm = swipeSegLenCm; target.swipeJoystickRadCm = swipeJoystickRadCm; target.tapMaxDur = tapMaxDur; target.multiTapMaxTimeGap = multiTapMaxTimeGap; target.longTapMaxDuration = longTapMaxDuration; target.longPressMinTime = longPressMinTime; CFGUI.EndUndo(this.undoObject); } }
// ----------------------- protected void DrawAnalogConfigGUI(AnalogConfig target) { float analogDeadZone = target.analogDeadZone, analogEndZone = target.analogEndZone, analogRangeStartValue = target.analogRangeStartValue, digitalEnterThresh = target.digitalEnterThresh, digitalLeaveThresh = target.digitalLeaveThresh; //digitalMagnet = target.digitalMagnetStrength; bool useRamp = target.useRamp; AnimationCurve ramp = target.ramp; CFGUI.MinMaxSlider(new GUIContent("Analog range", "Analog deadzone and end-zone."), ref analogDeadZone, ref analogEndZone, 0, 1, 100); //GUILayout.MinWidth(30)); useRamp = EditorGUILayout.ToggleLeft(new GUIContent("Use Ramp", "Use custom ramp for this joystick."), useRamp, GUILayout.ExpandWidth(true)); if (useRamp) { ramp = EditorGUILayout.CurveField(new GUIContent("Ramp", "Ramp curve."), target.ramp, GUILayout.ExpandWidth(true)); } else { analogRangeStartValue = CFGUI.Slider(new GUIContent("Start Value", "Analog Range Start Value.\n\n" + "If raw analog value is below the Deadzone, returned value equals zero." + " Otherwise, returned value will be interpolated between this value (at analog deadzone) and 1.0 (analog endzone).\n\n" + "Default value is zero."), analogRangeStartValue, 0, 1, 100); } if (this.drawDigitalSection) { CFGUI.MinMaxSlider(new GUIContent("Digital Thresholds", "Max value is the digital \"enter threshold\" and minimal value is the \"Leave Threshold\""), ref digitalLeaveThresh, ref digitalEnterThresh, 0.01f, 0.99f, 100); } if ((useRamp != target.useRamp) || (ramp != target.ramp) || //(circularClamp != target.circularClamp) || (analogDeadZone != target.analogDeadZone) || (analogRangeStartValue != target.analogRangeStartValue) || (analogEndZone != target.analogEndZone) || (digitalEnterThresh != target.digitalEnterThresh) || (digitalLeaveThresh != target.digitalLeaveThresh)) //((joyConfig != null) && (digitalFreeDirChangeZone != joyConfig.digitalFreeDirChangeZone))) //(digitalMagnet != target.digitalMagnetStrength) ) { CFGUI.CreateUndo("Analog Config modification", this.undoObject); target.analogDeadZone = analogDeadZone; target.analogEndZone = analogEndZone; target.analogRangeStartValue = analogRangeStartValue; target.digitalLeaveThresh = digitalLeaveThresh; target.digitalEnterThresh = digitalEnterThresh; //target.digitalMagnetStrength= digitalMagnet; target.useRamp = useRamp; target.ramp = ramp; // if (joyConfig != null) // joyConfig.digitalFreeDirChangeZone = digitalFreeDirChangeZone; CFGUI.EndUndo(this.undoObject); } }
// --------------- 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); } }
// --------------------- private void DrawMultiTouchGUI(MultiTouchGestureThresholds target) { float pinchDistThreshCm = target.pinchDistThreshCm, pinchAnalogRangeCm = target.pinchAnalogRangeCm, //pinchAnalogDeadzone = target.pinchAnalogDeadzone, pinchDeltaRangeCm = target.pinchDeltaRangeCm, pinchDigitalThreshCm = target.pinchDigitalThreshCm, twistMinDistCm = target.twistMinDistCm, twistAngleThresh = target.twistAngleThresh, twistAnalogRange = target.twistAnalogRange, //twistAnalogDeadzone = target.twistAnalogDeadzone, twistDeltaRange = target.twistDeltaRange, twistDigitalThresh = target.twistDigitalThresh, pinchScrollMagnet = target.pinchScrollMagnet, pinchScrollStepCm = target.pinchScrollStepCm, twistScrollMagnet = target.twistScrollMagnet, twistScrollStep = target.twistScrollStep, multiFingerTapMaxFingerDistCm = target.multiFingerTapMaxFingerDistCm; // GUI... pinchDistThreshCm = CFGUI.FloatField(new GUIContent("Pinch Thresh (cm)", "Pinch distance threshold in centimeters."), pinchDistThreshCm, 0.01f, 5.0f, LABEL_WIDTH); pinchAnalogRangeCm = CFGUI.FloatField(new GUIContent("Pinch Analog Range (cm)", "Pinch distance analog range in centimeters. This is used when binding pinch state to analog axes."), pinchAnalogRangeCm, 0.1f, 10.0f, LABEL_WIDTH); pinchDeltaRangeCm = CFGUI.FloatField(new GUIContent("Pinch Delta Range (cm)", "Pinch distance delta range in centimeters. This is used when binding pinch state to analog axes."), pinchDeltaRangeCm, 0.1f, 10.0f, LABEL_WIDTH); pinchDigitalThreshCm = CFGUI.FloatField(new GUIContent("Pinch Digital Thresh (cm)", "Pinch distance threshold to detect digital states of pinch or spread."), pinchDigitalThreshCm, 0.1f, 5.0f, LABEL_WIDTH); pinchScrollStepCm = CFGUI.FloatField(new GUIContent("Pinch Scroll Step (cm)", "Pinch scroll step in centimeters."), pinchScrollStepCm, 0.1f, 5.0f, LABEL_WIDTH); pinchScrollMagnet = CFGUI.FloatField(new GUIContent("Pinch Scroll Magnet", "Pinch scroll magnet strength."), pinchScrollMagnet, 0, 1, LABEL_WIDTH); EditorGUILayout.Space(); twistMinDistCm = CFGUI.FloatField(new GUIContent("Twist Min. Dist (cm)", "Minimal safe finger distance for twist gesture in centimeters."), twistMinDistCm, 0.01f, 5.0f, LABEL_WIDTH); twistAngleThresh = CFGUI.FloatField(new GUIContent("Twist Thresh (deg)", "Twist threshold in degrees."), twistAngleThresh, 0.01f, 180f, LABEL_WIDTH); twistAnalogRange = CFGUI.FloatField(new GUIContent("Twist Analog Range (deg)", "Twist analog range in degrees. This is used when binding twist state to analog axis."), twistAnalogRange, 1, 360, LABEL_WIDTH); twistDeltaRange = CFGUI.FloatField(new GUIContent("Twist Delta Range (deg)", "Twist angle range in degrees. This is used when binding twist tate to analog axes."), twistDeltaRange, 0.1f, 360.0f, LABEL_WIDTH); twistDigitalThresh = CFGUI.FloatField(new GUIContent("Twist Digital Thresh (deg)", "Twist angle threshold to detect digital states of twist right or left."), twistDigitalThresh, 1f, 180, LABEL_WIDTH); twistScrollStep = CFGUI.FloatField(new GUIContent("Twist Scroll Step (deg)", "Twist scroll step in degrees."), twistScrollStep, 1, 180, LABEL_WIDTH); twistScrollMagnet = CFGUI.FloatField(new GUIContent("Twist Scroll Magnet", "Twsit scroll magnet strength."), twistScrollMagnet, 0, 1, LABEL_WIDTH); EditorGUILayout.Space(); multiFingerTapMaxFingerDistCm = CFGUI.FloatField(new GUIContent("Multi-finger max tap dist (cm)", "Maximal allowed distance between two or more fingers forming a multi-finger when detecting taps."), multiFingerTapMaxFingerDistCm, 0.01f, 5.0f, LABEL_WIDTH); // Register Undo... if ((pinchDistThreshCm != target.pinchDistThreshCm) || (pinchAnalogRangeCm != target.pinchAnalogRangeCm) || //(pinchAnalogDeadzone != target.pinchAnalogDeadzone) || (pinchDeltaRangeCm != target.pinchDeltaRangeCm) || (pinchDigitalThreshCm != target.pinchDigitalThreshCm) || (twistMinDistCm != target.twistMinDistCm) || (twistAngleThresh != target.twistAngleThresh) || (twistAnalogRange != target.twistAnalogRange) || //(twistAnalogDeadzone != target.twistAnalogDeadzone) || (twistDeltaRange != target.twistDeltaRange) || (twistDigitalThresh != target.twistDigitalThresh) || (pinchScrollMagnet != target.pinchScrollMagnet) || (pinchScrollStepCm != target.pinchScrollStepCm) || (twistScrollMagnet != target.twistScrollMagnet) || (twistScrollStep != target.twistScrollStep) || (multiFingerTapMaxFingerDistCm != target.multiFingerTapMaxFingerDistCm)) { CFGUI.CreateUndo("Touch Gesture Thresholds modification", this.undoObject); target.pinchDistThreshCm = pinchDistThreshCm; target.pinchAnalogRangeCm = pinchAnalogRangeCm; //target.pinchAnalogDeadzone = pinchAnalogDeadzone; target.pinchDeltaRangeCm = pinchDeltaRangeCm; target.pinchDigitalThreshCm = pinchDigitalThreshCm; target.twistMinDistCm = twistMinDistCm; target.twistAngleThresh = twistAngleThresh; target.twistAnalogRange = twistAnalogRange; //target.twistAnalogDeadzone = twistAnalogDeadzone; target.twistDeltaRange = twistDeltaRange; target.twistDigitalThresh = twistDigitalThresh; target.multiFingerTapMaxFingerDistCm = multiFingerTapMaxFingerDistCm; target.pinchScrollMagnet = pinchScrollMagnet; target.pinchScrollStepCm = pinchScrollStepCm; target.twistScrollMagnet = twistScrollMagnet; target.twistScrollStep = twistScrollStep; CFGUI.EndUndo(this.undoObject); } }
// ------------------- public void DrawConfigGUI(ControlFreak2.SuperTouchZone.MultiFingerTouchConfig config) { //if (!CFGUI.BoldFoldout(this.configTitleContent, ref this.configFoldedOut)) // return; InspectorUtils.BeginIndentedSection(this.configTitleContent); //CFGUI.BeginIndentedVerticalCFEditorStyles.Inst.boldText); bool driveOtherControl = config.driveOtherControl; //swipeToDrive = config.swipeToDrive; //useSwipeJoystick = config.useSwipeJoystick; TouchControl //controlToDrive = config.controlToDrive; controlToDriveOnRawPress = config.controlToDriveOnRawPress, controlToDriveOnNormalPress = config.controlToDriveOnNormalPress, controlToDriveOnLongPress = config.controlToDriveOnLongPress, controlToDriveOnNormalPressSwipe = config.controlToDriveOnNormalPressSwipe, controlToDriveOnNormalPressSwipeU = config.controlToDriveOnNormalPressSwipeU, controlToDriveOnNormalPressSwipeR = config.controlToDriveOnNormalPressSwipeR, controlToDriveOnNormalPressSwipeD = config.controlToDriveOnNormalPressSwipeD, controlToDriveOnNormalPressSwipeL = config.controlToDriveOnNormalPressSwipeL, controlToDriveOnLongPressSwipe = config.controlToDriveOnLongPressSwipe, controlToDriveOnLongPressSwipeU = config.controlToDriveOnLongPressSwipeU, controlToDriveOnLongPressSwipeR = config.controlToDriveOnLongPressSwipeR, controlToDriveOnLongPressSwipeD = config.controlToDriveOnLongPressSwipeD, controlToDriveOnLongPressSwipeL = config.controlToDriveOnLongPressSwipeL; //InspectorUtils.BeginIndentedSection(GUIContent.none); //this.configTitleContent); //CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); this.touchGestureConfigInsp.DrawGUI(config.touchConfig); EditorGUILayout.Space(); //useSwipeJoystick = EditorGUILayout.ToggleLeft(new GUIContent("Use Swipe Joystick", "When enabled, this option gives access to virtual joystick controlled by swiping."), // useSwipeJoystick); //if (useSwipeJoystick) this.swipeJoyConfigInsp.DrawGUI(config.swipeJoyConfig); EditorGUILayout.Space(); driveOtherControl = EditorGUILayout.ToggleLeft(new GUIContent(" Drive other control", "Use this multi-finger touch to drive other touch control, like joystick or even other touch zone!"), driveOtherControl, CFEditorStyles.Inst.boldText); if (driveOtherControl) { CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); //swipeToDrive = EditorGUILayout.ToggleLeft(new GUIContent("Swipe to drive", "Swipe first to drive other control. This option is useful for joysticks, as it allows to detect many static gestures such as tap without activating the joystick."), // swipeToDrive); controlToDriveOnRawPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Raw Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnRawPress, typeof(TouchControl), 150); if (controlToDriveOnRawPress == null) { controlToDriveOnNormalPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Normal Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPress, typeof(TouchControl), 150); if (config.touchConfig.detectLongPress) { controlToDriveOnLongPress = (TouchControl)CFGUI.ObjectField(new GUIContent("On Long Press", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPress, typeof(TouchControl), 150); } controlToDriveOnNormalPressSwipe = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe in Any dir. (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPressSwipe, typeof(TouchControl), 150); if (controlToDriveOnNormalPressSwipe == null) { controlToDriveOnNormalPressSwipeU = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Up (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPressSwipeU, typeof(TouchControl), 150); controlToDriveOnNormalPressSwipeR = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Right (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPressSwipeR, typeof(TouchControl), 150); controlToDriveOnNormalPressSwipeD = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Down (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPressSwipeD, typeof(TouchControl), 150); controlToDriveOnNormalPressSwipeL = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Left (Normal Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnNormalPressSwipeL, typeof(TouchControl), 150); } if (config.touchConfig.detectLongPress) { controlToDriveOnLongPressSwipe = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe in Any dir. (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPressSwipe, typeof(TouchControl), 120); if (controlToDriveOnLongPressSwipe == null) { controlToDriveOnLongPressSwipeU = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Up (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPressSwipeU, typeof(TouchControl), 120); controlToDriveOnLongPressSwipeR = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Right (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPressSwipeR, typeof(TouchControl), 120); controlToDriveOnLongPressSwipeD = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Down (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPressSwipeD, typeof(TouchControl), 120); controlToDriveOnLongPressSwipeL = (TouchControl)CFGUI.ObjectField(new GUIContent("On Swipe Left (Long Press)", "Touch Control to drive with this multi-finger touch.\n\nTIP: It's a good idea to enable \'Can\'t be touched directly\' option on driven control."), controlToDriveOnLongPressSwipeL, typeof(TouchControl), 120); } } } CFGUI.EndIndentedVertical(); } //EditorGUILayout.Space(); InspectorUtils.EndIndentedSection(); // Register Undo... if ((driveOtherControl != config.driveOtherControl) || //(swipeToDrive != config.swipeToDrive) || //(controlToDrive != config.controlToDrive) ) (controlToDriveOnRawPress != config.controlToDriveOnRawPress) || (controlToDriveOnNormalPress != config.controlToDriveOnNormalPress) || (controlToDriveOnLongPress != config.controlToDriveOnLongPress) || (controlToDriveOnNormalPressSwipe != config.controlToDriveOnNormalPressSwipe) || (controlToDriveOnNormalPressSwipeU != config.controlToDriveOnNormalPressSwipeU) || (controlToDriveOnNormalPressSwipeR != config.controlToDriveOnNormalPressSwipeR) || (controlToDriveOnNormalPressSwipeD != config.controlToDriveOnNormalPressSwipeD) || (controlToDriveOnNormalPressSwipeL != config.controlToDriveOnNormalPressSwipeL) || (controlToDriveOnLongPressSwipe != config.controlToDriveOnLongPressSwipe) || (controlToDriveOnLongPressSwipeU != config.controlToDriveOnLongPressSwipeU) || (controlToDriveOnLongPressSwipeR != config.controlToDriveOnLongPressSwipeR) || (controlToDriveOnLongPressSwipeD != config.controlToDriveOnLongPressSwipeD) || (controlToDriveOnLongPressSwipeL != config.controlToDriveOnLongPressSwipeL) ) //|| (useSwipeJoystick != config.useSwipeJoystick)) { CFGUI.CreateUndo("Multi-finger touch config mod.", this.touchZone); config.driveOtherControl = driveOtherControl; //config.swipeToDrive = swipeToDrive; //config.controlToDrive = controlToDrive; //config.useSwipeJoystick = useSwipeJoystick; config.controlToDriveOnRawPress = controlToDriveOnRawPress; config.controlToDriveOnNormalPress = controlToDriveOnNormalPress; config.controlToDriveOnLongPress = controlToDriveOnLongPress; config.controlToDriveOnNormalPressSwipe = controlToDriveOnNormalPressSwipe; config.controlToDriveOnNormalPressSwipeU = controlToDriveOnNormalPressSwipeU; config.controlToDriveOnNormalPressSwipeR = controlToDriveOnNormalPressSwipeR; config.controlToDriveOnNormalPressSwipeD = controlToDriveOnNormalPressSwipeD; config.controlToDriveOnNormalPressSwipeL = controlToDriveOnNormalPressSwipeL; config.controlToDriveOnLongPressSwipe = controlToDriveOnLongPressSwipe; config.controlToDriveOnLongPressSwipeU = controlToDriveOnLongPressSwipeU; config.controlToDriveOnLongPressSwipeR = controlToDriveOnLongPressSwipeR; config.controlToDriveOnLongPressSwipeD = controlToDriveOnLongPressSwipeD; config.controlToDriveOnLongPressSwipeL = controlToDriveOnLongPressSwipeL; CFGUI.EndUndo(this.touchZone); } }
// --------------- public 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); }
// ------------------ public void Draw(DirectionBinding bind, InputRig rig) { bool bindingEnabled = bind.enabled, bindDiagonals = bind.bindDiagonals; DirectionBinding.BindMode bindMode = bind.bindMode; EditorGUILayout.BeginVertical(); if (bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30))) { CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); if (this.customPreGUI != null) { this.customPreGUI(); } bindMode = (DirectionBinding.BindMode)CFGUI.EnumPopup(new GUIContent("Bind mode"), bindMode, 70); bindDiagonals = EditorGUILayout.ToggleLeft(new GUIContent("Bind diagonals", "Bind diagonal directions separately. When turned off, diagonal directions are translated into combinations of main directions."), bindDiagonals, GUILayout.MinWidth(30)); EditorGUILayout.Space(); this.dirN.Draw(bind.dirBindingN, rig); this.dirAny.Draw(bind.dirBindingAny, rig); this.dirU.Draw(bind.dirBindingU, rig); if (bindDiagonals) { this.dirUR.Draw(bind.dirBindingUR, rig); } this.dirR.Draw(bind.dirBindingR, rig); if (bindDiagonals) { this.dirDR.Draw(bind.dirBindingDR, rig); } this.dirD.Draw(bind.dirBindingD, rig); if (bindDiagonals) { this.dirDL.Draw(bind.dirBindingDL, rig); } this.dirL.Draw(bind.dirBindingL, rig); if (bindDiagonals) { this.dirUL.Draw(bind.dirBindingUL, rig); } CFGUI.EndIndentedVertical(); GUILayout.Space(InputBindingGUIUtils.VERT_MARGIN); } EditorGUILayout.EndVertical(); if ((bindingEnabled != bind.enabled) || (bindMode != bind.bindMode) || (bindDiagonals != bind.bindDiagonals)) { CFGUI.CreateUndo("Direction Binding modification.", this.undoObject); bind.enabled = bindingEnabled; bind.bindDiagonals = bindDiagonals; bind.bindMode = bindMode; CFGUI.EndUndo(this.undoObject); } }
// --------------------- public void 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); } }
//private float buttonHeight = 40; // --------------------- protected void DrawJoystickConfigGUI(JoystickConfig target) { bool blockX = target.blockX, blockY = target.blockY, perAxisDeadzones = target.perAxisDeadzones; JoystickConfig.ClampMode clampMode = target.clampMode; //circularClamp = target.circularClamp; JoystickConfig.StickMode stickMode = target.stickMode; DirectionState.OriginalDirResetMode originalDirResetMode = target.originalDirResetMode; JoystickConfig.DigitalDetectionMode digitalDetectionMode = target.digitalDetectionMode; float angularMagnet = target.angularMagnet; stickMode = (JoystickConfig.StickMode)CFGUI.EnumPopup(new GUIContent("Mode", "Joystick mode"), stickMode, 120); // GUILayout.MinWidth(30)); clampMode = (JoystickConfig.ClampMode)CFGUI.EnumPopup(new GUIContent("Vector Range", "Vector Range Mode"), clampMode, 120); //GUILayout.MinWidth(30)); digitalDetectionMode = (JoystickConfig.DigitalDetectionMode)CFGUI.EnumPopup(new GUIContent("Digi. Detect. Mode", "Digital Detection Mode"), digitalDetectionMode, 120); angularMagnet = CFGUI.Slider(new GUIContent("Digi. Angular Magnet", "Angular Magnet Strength used when changing digital direction. Higher value will make changing direction harder, which is recommended for Touch Digital Detection Mode."), angularMagnet, 0f, 1f, 100); if (stickMode == JoystickConfig.StickMode.Analog) { perAxisDeadzones = EditorGUILayout.ToggleLeft(new GUIContent("Per-Axis Analog Range", "Per-Axis deadzone, endzone and ramp transformations."), perAxisDeadzones, GUILayout.MinWidth(30)); } blockX = EditorGUILayout.ToggleLeft(new GUIContent("Block X"), blockX, GUILayout.MinWidth(30)); blockY = EditorGUILayout.ToggleLeft(new GUIContent("Block Y"), blockY, GUILayout.MinWidth(30)); originalDirResetMode = (DirectionState.OriginalDirResetMode)CFGUI.EnumPopup(new GUIContent("Dir. Reset Mode", "Original Direction Reset Mode - choose when original stick direction will be reset. This option is used mainly by the Direction Binding..."), originalDirResetMode, 120); // GUILayout.MinWidth(30)); if ((blockX != target.blockX) || (blockY != target.blockY) || (perAxisDeadzones != target.perAxisDeadzones) || (clampMode != target.clampMode) || (originalDirResetMode != target.originalDirResetMode) || (digitalDetectionMode != target.digitalDetectionMode) || (stickMode != target.stickMode) || (angularMagnet != target.angularMagnet)) { CFGUI.CreateUndo("Joy Config modification", this.undoObject); target.perAxisDeadzones = perAxisDeadzones; target.blockX = blockX; target.blockY = blockY; //target.circularClamp = circularClamp; target.clampMode = clampMode; target.stickMode = stickMode; target.originalDirResetMode = originalDirResetMode; target.angularMagnet = angularMagnet; target.digitalDetectionMode = digitalDetectionMode; CFGUI.EndUndo(this.undoObject); } }
// ------------------ public void Draw(AxisBinding bind, InputRig rig) { bool bindingEnabled = bind.enabled; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)); if (bindingEnabled) { if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add target"), CFEditorStyles.Inst.iconButtonStyle)) //, GUILayout.Width(20), GUILayout.Height(20))) { CFGUI.CreateUndo("Add new target to Analog Binding.", this.undoObject); bind.AddTarget(); CFGUI.EndUndo(this.undoObject); } if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove target"), CFEditorStyles.Inst.iconButtonStyle)) //, GUILayout.Width(20), GUILayout.Height(20))) { CFGUI.CreateUndo("Remove target from Analog Binding.", this.undoObject); bind.RemoveLastTarget(); CFGUI.EndUndo(this.undoObject); } } EditorGUILayout.EndHorizontal(); if (bindingEnabled) { CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); if (this.customExtraGUI != null) { this.customExtraGUI(); } this.PrepareTargetElemListInspectors(bind.targetList.Count); if (bind.targetList.Count == 0) { EditorGUILayout.LabelField("No targets defined...", CFEditorStyles.Inst.centeredTextTranspBG); } else { for (int i = 0; i < bind.targetList.Count; ++i) { this.targetElemInspList[i].DrawGUI(bind.targetList[i], rig, (i == (bind.targetList.Count - 1))); } } CFGUI.EndIndentedVertical(); } EditorGUILayout.EndVertical(); if ((bindingEnabled != bind.enabled) ) { CFGUI.CreateUndo("Analog Axis Binding modification.", this.undoObject); bind.enabled = bindingEnabled; CFGUI.EndUndo(this.undoObject); } }
// --------------- public 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); }
// --------------- 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... bool limitTurnSpeed = c.limitTurnSpeed; float minTurnTime = c.minTurnTime, maxReturnTime = c.maxReturnTime; // digitalThresh = c.digitalThresh; bool physicalMode = c.physicalMode; float physicalMoveRangeCm = c.physicalMoveRangeCm; // const float LABEL_WIDTH = 120; // Steering Wheel specific inspector.... InspectorUtils.BeginIndentedSection(new GUIContent("Steering Wheel Settings")); 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("Min. Turn Time", "Minimal Turn Time in milliseconds - how quick can this wheel move from neutral position to maximal turn angle."), minTurnTime, 0, 5, 1000, true, LABEL_WIDTH); maxReturnTime = CFGUI.FloatFieldEx(new GUIContent("Max. Return Time", "Time in milliseconds needed to return from maximal turn angle to neutral position."), maxReturnTime, 0, 5, 1000, true, LABEL_WIDTH); InspectorUtils.EndIndentedSection(); } physicalMode = EditorGUILayout.ToggleLeft(new GUIContent("Physical 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(); } EditorGUILayout.Space(); this.analogConfigInsp.DrawGUI(c.analogConfig); InspectorUtils.EndIndentedSection(); InspectorUtils.BeginIndentedSection(new GUIContent("Steering Wheel Bindings")); this.pressBindingInsp.Draw(c.pressBinding, 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) || //(digitalThresh != c.digitalThresh) || (physicalMode != c.physicalMode) || (physicalMoveRangeCm != c.physicalMoveRangeCm)) { CFGUI.CreateUndo("CF2 Steering Wheel modification", c); c.limitTurnSpeed = limitTurnSpeed; c.minTurnTime = minTurnTime; c.maxReturnTime = maxReturnTime; //c.digitalThresh = digitalThresh; c.physicalMode = physicalMode; c.physicalMoveRangeCm = physicalMoveRangeCm; CFGUI.EndUndo(c); } // Draw Shared Dynamic Control Params... this.DrawDynamicTouchControlGUI(c); }
// --------------- public override void OnInspectorGUI() { TouchSteeringWheelSpriteAnimator target = this.target as TouchSteeringWheelSpriteAnimator; if ((target == null)) { return; } if (!TouchControlSpriteAnimatorInspector.DrawSourceGUI(target)) { return; } TouchSteeringWheel wheel = target.sourceControl as TouchSteeringWheel; 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")); if ((wheel != null) && (wheel.wheelMode == TouchSteeringWheel.WheelMode.Turn)) { GUI.enabled = false; CFGUI.FloatField(new GUIContent("Rot. range", "Wheel's Rotation Range - in TURN wheel mode it's taken from Wheel."), wheel.maxTurnAngle, 0, 100000, 65); GUI.enabled = true; } else { 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); } }