// -------------------- void FixedUpdate() { if (this.targetTransform == null) { return; } Vector3 pos = this.targetTransform.position + this.targetOfs; if ((this.cam != null) && cam.orthographic) { cam.orthographicSize = CFUtils.SmoothTowards(this.cam.orthographicSize, Mathf.Lerp(this.orthoZoomInSize, this.orthoZoomOutSize, this.camZoomFactor), this.smoothingTime, CFUtils.realDeltaTimeClamped, 0.0001f); } else { pos -= (this.transform.forward * (this.camZoomFactor * this.perspZoomOutOffset)); } if (this.smoothingTime > 0.001f) { pos = Vector3.SmoothDamp(this.transform.position, pos, ref this.smoothPosVel, this.smoothingTime); } this.transform.position = pos; }
// -------------- public Vector2 AnimateDirToAnalogVec(Vector2 curVec, Dir targetDir) { float digiToAnalogSpeed = ((targetDir == Dir.N) ? this.digitalToAnalogReleaseSpeed : this.digitalToAnalogPressSpeed); return(CFUtils.SmoothTowardsVec2(curVec, CFUtils.DirToVector(targetDir, (this.clampMode == ClampMode.Circle)), (digiToAnalogSpeed * DIGITAL_TO_ANALOG_SMOOTHING_TIME), Time.unscaledTime, 0.0001f)); }
// ------------------ public void SetDir(Dir dir, OriginalDirResetMode resetMode) { this.dirCur = dir; // Detect original dir change... if (this.dirCur != this.dirPrev) { if (this.dirCur == Dir.N) { this.dirOriginalCur = Dir.N; } else if (this.dirPrev == Dir.N) { this.dirOriginalCur = this.dirCur; } else if ((resetMode != OriginalDirResetMode.OnNeutral) && (Mathf.Abs(CFUtils.DirDeltaAngle(this.dirOriginalPrev, this.dirCur)) >= ( (resetMode == OriginalDirResetMode.On90) ? 90 : (resetMode == OriginalDirResetMode.On135) ? 135 : 180))) { this.dirOriginalCur = this.dirCur; } } }
//abstract protected GUIContent GetTitle(); // -------------------- public void Init(TouchControlPanel panel, System.Action onCreationCallback) { this.panel = panel; this.onCreationCallback = onCreationCallback; this.emulateTouchPressure = true; this.canvas = (Canvas)CFUtils.GetComponentHereOrInParent(this.panel, typeof(Canvas)); this.controlName = "NewControl"; this.dynamicMode = ControlMode.Static; this.regionRect = RegionRectPreset.LeftHalf; this.controlShape = TouchControl.Shape.Circle; this.staticAnchor = ControlAnchorPoint.BottomRight; this.controlSize = 0.15f; this.controlDepth = Mathf.Lerp(DEPTH_MIN, DEPTH_MAX, 0.25f); this.regionDepth = Mathf.Lerp(DEPTH_MIN, DEPTH_MAX, 0.70f); // Restore params... if (mStoredParamsSaved) { this.controlSize = mStoredControlSize; this.staticAnchor = mStoredStaticAnchor; this.controlDepth = mStoredControlDepth; this.regionDepth = mStoredRegionDepth; this.controlShape = mStoredControlShape; } }
// -------------------- protected void InternalUpdate() { this.posPrevRaw = this.posCurRaw; this.posPrevSmooth = this.posCurSmooth; this.pressPrev = this.pressCur; this.extremeDistPrevSq = this.extremeDistCurSq; this.extremeDistPerAxisPrev = this.extremeDistPerAxisCur; // Process collected 'events'... // Release... if ((this.pollReleased && (this.prepollState == true))) { this.posCurRaw = this.pollReleasePos; this.posCurSmooth = this.posCurRaw; this.OnRelease(this.pollReleasePos, this.pollReleasedAsCancel); this.pollReleased = false; this.prepollState = this.pressCur; if (this.pollStartedPress) { this.pollPressStartDelay += CFUtils.realDeltaTime; // add this frame's deltaTime to cached press event (?) } } // Press... else if ((this.pollStartedPress && (this.prepollState == false))) // || (!this.pressCur && this.pollCurState)) { this.OnPress(this.pollPressStartPos, this.pollCurPos, this.pollPressStartDelay, this.pollStartedByMouse, this.pollStartPressureSensitive, this.pollStartPressure); this.pollStartedPress = false; this.prepollState = this.pressCur; } else { this.posCurRaw = this.pollCurPos; this.posCurSmooth = CFUtils.SmoothTowardsVec2(this.posCurSmooth, this.posCurRaw, this.smoothingTime, CFUtils.realDeltaTime, 0); this.pressureCur = this.pollCurPressure; } // Check movement... if (this.pressCur) { this.CheckMovement(false); } }
// ----------------------- //! Get curent transformed vector in given clamp mode. // ----------------------- public Vector2 GetVectorEx(bool squareMode) { if ((this.config.clampMode == JoystickConfig.ClampMode.Square) == squareMode) { return(this.GetVector()); } else { return(squareMode ? CFUtils.CircularToSquareJoystickVec(this.GetVector()) : CFUtils.SquareToCircularJoystickVec(this.GetVector())); } }
//! \cond // ---------------- public void ApplyUnclampedVec(Vector2 v) //, JoystickConfig.ClampMode sourceClampMode) { if (this.config.clampMode == JoystickConfig.ClampMode.Circle) { v = CFUtils.ClampInsideUnitCircle(v); } else { v = CFUtils.ClampInsideUnitSquare(v); } this.nextFramePos.x = CFUtils.ApplyDeltaInput(this.nextFramePos.x, v.x); this.nextFramePos.y = CFUtils.ApplyDeltaInput(this.nextFramePos.y, v.y); }
// ----------------- static public Component GetComponentFromSelection(System.Type compType) { Transform[] sel = Selection.transforms; for (int i = 0; i < sel.Length; ++i) { Component c = CFUtils.GetComponentHereOrInParent(sel[i], compType); if (c != null) { return(c); } } return(null); }
// ------------------- public void ApplyClampedVec(Vector2 v, JoystickConfig.ClampMode clampMode) { if (clampMode != this.config.clampMode) { if (this.config.clampMode == JoystickConfig.ClampMode.Circle) { v = CFUtils.SquareToCircularJoystickVec(v); } else { v = CFUtils.CircularToSquareJoystickVec(v); } } this.nextFramePos.x = CFUtils.ApplyDeltaInput(this.nextFramePos.x, v.x); this.nextFramePos.y = CFUtils.ApplyDeltaInput(this.nextFramePos.y, v.y); }
// -------------------- protected void UpdateSpriteAnimation(bool skipAnim) { this.spriteAnimElapsed += CFUtils.realDeltaTimeClamped; if (this.curSprite.oneShotState && (this.spriteAnimElapsed >= this.curSprite.duration)) { this.BeginSpriteAnim((this.nextSprite != null) ? this.nextSprite : this.spriteNeutral, skipAnim, true); } this.animColorCur = Color.Lerp(this.animColorStart, this.curSprite.color, this.GetAnimLerpFactor(skipAnim ? 0 : (this.curSprite.colorTransitionFactor * this.curSprite.baseTransitionTime))); // Scale alpha... this.animColorCur = CFUtils.ScaleColorAlpha(this.animColorCur, this.sourceControl.GetAlpha()); // Animate transforms... if (!CFUtils.editorStopped && !this.IsIllegallyAttachedToSource()) { this.animOffsetCur = Vector2.Lerp(this.animOffsetStart, this.curSprite.offset, this.GetAnimLerpFactor(skipAnim ? 0 : (this.curSprite.offsetTransitionFactor * this.curSprite.baseTransitionTime))); this.animScaleCur = Vector2.Lerp(this.animScaleStart, Vector2.one * this.curSprite.scale, this.GetAnimLerpFactor(skipAnim ? 0 : (this.curSprite.scaleTransitionFactor * this.curSprite.baseTransitionTime))); this.animRotationCur = Mathf.LerpAngle(this.animRotationStart, this.curSprite.rotation, this.GetAnimLerpFactor(skipAnim ? 0 : (this.curSprite.rotationTransitionFactor * this.curSprite.baseTransitionTime))); } this.ApplySpriteAnimation(); }
// ------------------ public void Update() { // Combine digital and analog input... Dir digiInputDir = CFUtils.DigitalToDir(this.nextFrameDigiU, this.nextFrameDigiR, this.nextFrameDigiD, this.nextFrameDigiL); this.digiInputAnalogVecCur = this.config.AnimateDirToAnalogVec(this.digiInputAnalogVecCur, digiInputDir); this.posRaw.x = CFUtils.ApplyDeltaInput(this.nextFramePos.x, this.digiInputAnalogVecCur.x); this.posRaw.y = CFUtils.ApplyDeltaInput(this.nextFramePos.y, this.digiInputAnalogVecCur.y); this.nextFramePos = Vector2.zero; this.nextFrameDigiU = false; this.nextFrameDigiR = false; this.nextFrameDigiD = false; this.nextFrameDigiL = false; // Process input... if (this.config.blockX) { this.posRaw.x = 0; } if (this.config.blockY) { this.posRaw.y = 0; } Vector2 unclampedPos = this.posRaw; this.posRaw = this.config.ClampNormalizedPos(this.posRaw); float tiltRaw = this.posRaw.magnitude; float angleRaw = this.safeAngle; if (this.posRaw.sqrMagnitude < MIN_SAFE_TILT_SQ) { tiltRaw = 0; this.tilt = 0; } else { this.normDir = this.posRaw.normalized; this.tilt = tiltRaw; angleRaw = Mathf.Atan2(this.normDir.x, this.normDir.y) * Mathf.Rad2Deg; angleRaw = CFUtils.NormalizeAnglePositive(angleRaw); } // Get digital state... Dir curDir4 = this.GetDir4(), curDir8 = this.GetDir8(); float dist4 = tiltRaw, dist8 = tiltRaw; // Use different tilt calculation mode... if (this.config.digitalDetectionMode == JoystickConfig.DigitalDetectionMode.Touch) { dist4 = Mathf.Max(Mathf.Abs(unclampedPos.x), Mathf.Abs(unclampedPos.y)); dist8 = dist4; dist8 = Mathf.Max(dist8, Mathf.Abs(((CFUtils.OneOverSqrtOf2 * unclampedPos.x) + (CFUtils.OneOverSqrtOf2 * unclampedPos.y)))); dist8 = Mathf.Max(dist8, Mathf.Abs(((CFUtils.OneOverSqrtOf2 * unclampedPos.x) - (CFUtils.OneOverSqrtOf2 * unclampedPos.y)))); } if (tiltRaw < 0.001f) { this.dirLastNonNeutral4 = this.dirLastNonNeutral8 = Dir.N; } curDir4 = (dist4 > this.config.digitalEnterThresh) ? CFUtils.DirFromAngleEx(angleRaw, false, this.dirLastNonNeutral4, this.config.angularMagnet) : (dist4 > this.config.digitalLeaveThresh) ? curDir4 : Dir.N; curDir8 = (dist8 > this.config.digitalEnterThresh) ? CFUtils.DirFromAngleEx(angleRaw, true, this.dirLastNonNeutral8, this.config.angularMagnet) : (dist8 > this.config.digitalLeaveThresh) ? curDir8 : Dir.N; if (curDir4 != Dir.N) { this.dirLastNonNeutral4 = curDir4; } if (curDir8 != Dir.N) { this.dirLastNonNeutral8 = curDir8; } this.dirState.BeginFrame(); this.dirState4.BeginFrame(); this.dirState8.BeginFrame(); this.dirState4.SetDir(curDir4, this.config.originalDirResetMode); this.dirState8.SetDir(curDir8, this.config.originalDirResetMode); this.dirState.SetDir((this.config.stickMode == JoystickConfig.StickMode.Digital4) ? this.GetDir4() : this.GetDir8(), this.config.originalDirResetMode); switch (this.config.stickMode) { case JoystickConfig.StickMode.Analog: this.angle = angleRaw; if (this.config.perAxisDeadzones) { this.pos.x = this.config.GetAnalogVal(this.posRaw.x); this.pos.y = this.config.GetAnalogVal(this.posRaw.y); this.tilt = this.pos.magnitude; } else { this.tilt = this.config.GetAnalogVal(tiltRaw); this.pos = this.normDir * this.tilt; if (this.config.clampMode == JoystickConfig.ClampMode.Square) { this.pos = CFUtils.CircularToSquareJoystickVec(this.pos); } } break; case JoystickConfig.StickMode.Digital4: case JoystickConfig.StickMode.Digital8: this.pos = CFUtils.DirToVector(this.GetDir(), (this.config.clampMode == JoystickConfig.ClampMode.Circle)); this.angle = CFUtils.DirToAngle(this.GetDir()); this.tilt = (this.GetDir() == Dir.N) ? 0 : 1; if (this.GetDir() != Dir.N) { this.normDir = this.pos.normalized; } break; } this.safeAngle = this.angle; }
// ------------------ public Vector2 ClampNormalizedPos(Vector2 np) { return((this.clampMode == ClampMode.Circle) ? CFUtils.ClampInsideUnitCircle(np) : CFUtils.ClampPerAxisInsideUnitSquare(np)); //CFUtils.ClampInsideUnitSquare(np)); }
// ----------------------- protected Vector2 GetControlOffset() { if (this.canvas == null) { return(Vector2.zero); } List <TouchControl> controlList = this.panel.rig.GetTouchControls(); //Rect canvasRect = ((RectTransform)this.canvas.transform).rect; Rect panelRect = ((RectTransform)this.panel.transform).rect; float controlRad = this.GetControlSize() / 2.0f; float separation = Mathf.Min(panelRect.width, panelRect.height) * 0.01f; Vector2 anchorPos = Vector2.one * (controlRad + separation); Bounds worldBounds = CFUtils.GetWorldAABB(this.canvas.transform.localToWorldMatrix, BottomLeftToAnchorRelativeLocal(anchorPos), new Vector3(controlRad * 2, controlRad * 2, 0)); float worldControlRad = Mathf.Max(worldBounds.size.x, worldBounds.size.y) * 0.5f; Vector2 bestPos = anchorPos; float bestDist = 100; // closest distance to other controls bool bestPosFound = false; int ringCount = Mathf.Max(1, Mathf.CeilToInt((panelRect.width - separation) / ((controlRad * 2.0f) + separation)), //Factor)), Mathf.CeilToInt((panelRect.height - separation) / ((controlRad * 2.0f) + separation))); //Factor))); for (int ri = 0; ri < ringCount; ++ri) { float ringRad = separation + ((float)ri * ((controlRad * 2.0f) + separation)); //Factor); float controlArcAngle = GetArcAngle(ringRad, controlRad) * Mathf.Rad2Deg; int stepCount = (ringRad < 0.0001f) ? 1 : Mathf.Max(1, Mathf.CeilToInt(90 / controlArcAngle)); //float angleInc = controlArcAngle; //float angleOfs = ((90 - ((float)stepCount * angleInc)) * 0.5f) + (angleInc * 0.5f); if (stepCount <= 1) { // angleInc =0; // angleOfs = 0; } for (int si = 0; si < stepCount; ++si) { //float orbitAngle = (angleOfs + ((float)si * angleInc)) ; float orbitAngle = (stepCount < 2) ? 45 : (((float)(si) + 0) * (90.0f / (float)(stepCount - 1))); Vector2 pos = anchorPos + ((new Vector2(Mathf.Cos(orbitAngle * Mathf.Deg2Rad), Mathf.Sin(orbitAngle * Mathf.Deg2Rad))) * ringRad); //* separationFactor; if ((pos.x > panelRect.width) || (pos.y > panelRect.height)) { continue; } Vector2 worldPos = this.BottomLeftToAnchorRelativeWorldPos(pos); // this.canvas.transform.localToWorldMatrix.MultiplyPoint3x4((Vector3)pos); if (controlList.Count == 0) { break; } bool controlTested = false; float closestControlDist = -100000; Vector2 closestControlPos = Vector2.zero; for (int ci = 0; ci < controlList.Count; ++ci) { TouchControl c = controlList[ci]; if ((c is DynamicRegion) || CFUtils.IsStretchyRectTransform(c.transform)) { continue; } Bounds controlBounds = c.GetWorldSpaceAABB(); Vector2 testControlCen = controlBounds.center; Vector2 testControlSize = controlBounds.size; float testControlRad = Mathf.Max(testControlSize.x, testControlSize.y) / 2.0f; float curDist = (testControlCen - worldPos).magnitude - (testControlRad); if (!controlTested || ((curDist < closestControlDist))) { controlTested = true; closestControlDist = curDist; closestControlPos = pos; } } if (!controlTested) { } else { if (closestControlDist >= worldControlRad) { return(this.BottomLeftToAnchorRelativePos(closestControlPos)); } if (closestControlDist > 0) //-(worldControlRad * 0.5f)) { return(this.BottomLeftToAnchorRelativePos(closestControlPos)); } if (!bestPosFound || (closestControlDist > bestDist)) { bestPosFound = true; bestDist = closestControlDist; bestPos = closestControlPos; } } } } // If the control is almost fully covered by other controls, place it at default position... if (bestDist < -(worldControlRad * 0.9f)) { bestPos = anchorPos; } else { //Debug.Log("GetOffs : returning best IMPERFECTn pos : dist : " + bestDist + " pos: " + bestPos +" rad: " + controlRad + " worldRad: " + worldControlRad + " ctrlNear: " + ((bestControlNear==null)? "NULL" : bestControlNear.name) + "ctrlRad:" + bestControlRad); } return(this.BottomLeftToAnchorRelativePos(bestPos)); }
public void PopulateFromHashtable(System.Collections.Hashtable hash) { this.Label = CFUtils.GetHashValueAsNonNullString(hash, "Label"); }
// ------------------------ static public void CreateContextMenuForMousePositionBinding(Object panelOrRig, System.Action onRefreshCallback = null) { InputRig rig = (panelOrRig as InputRig); TouchControlPanel panel = (panelOrRig as TouchControlPanel); //bool displayPanelName = false; if (panel != null) { rig = panel.rig; } else if (rig != null) { // Auto Select panel... panel = TouchControlWizardUtils.GetRigPanel(rig); //displayPanelName = true; } else { return; } List <TouchControl> controlList = rig.GetTouchControls(); GenericMenu menu = new GenericMenu(); string commandName = ("Mouse Position "); menu.AddDisabledItem(new GUIContent("Actions for : " + commandName)); menu.AddSeparator(""); UniversalBindingAssignment.AddBindingContainerToMenu(menu, rig, onRefreshCallback, BindingDescription.BindingType.MousePos, commandName, "Bind to Input Rig/", rig); menu.AddSeparator(""); if (panel == null) { menu.AddDisabledItem(new GUIContent("Add a Touch Control Panel to this rig to create and bind commands to Touch Controls!")); } else { UniversalBindingAssignment.AddControlListBindingsToMenu(menu, controlList, onRefreshCallback, BindingDescription.BindingType.MousePos, commandName, "Bind to Touch Controls/"); menu.AddSeparator(""); int mouseTargetMaxId = CFUtils.GetEnumMaxValue(typeof(SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget)); for (int i = 1; i <= 2; ++i) { for (int j = 1; j <= mouseTargetMaxId; ++j) { SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget mouseTarget = (SuperTouchZoneCreationWizard.BindingSetup.MouseBindingTarget)j; WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone with " + commandName + "bound to [" + ((i == 1) ? "Single-finger" : "Two-finger") + mouseTarget.ToString() + "]...", panel, typeof(SuperTouchZoneCreationWizard), SuperTouchZoneCreationWizard.BindingSetup.MousePos(i, mouseTarget), onRefreshCallback); } } menu.AddSeparator("Create a Super Touch Zone/"); WizardMenuItem.AddToMenu(menu, "Create a Super Touch Zone/Super Touch Zone...", panel, typeof(SuperTouchZoneCreationWizard), null, onRefreshCallback); } menu.ShowAsContext(); }
// --------------- public float AnimateDigitalToAnalog(float curVal, float targetVal, bool pressed) { return(CFUtils.SmoothTowards(curVal, targetVal, (pressed ? this.digitalToAnalogPressSpeed : this.digitalToAnalogReleaseSpeed) * DIGITAL_TO_ANALOG_SMOOTHING_TIME, CFUtils.realDeltaTime, 0.001f)); }
// ----------------- override protected void CheckMovement(bool itsFinalUpdate) { base.CheckMovement(itsFinalUpdate); if ((this.thresh == null) || (this.config == null)) { return; } if (!this.PressedRaw()) { this.cleanPressCur = false; this.holdPressCur = false; } else { // Detect long-press... bool longPressStillPossible = false; if (this.holdPressCur) { // End long-press on move? if (this.config.endLongPressWhenMoved && (this.nonStaticFlag || this.Moved(this.thresh.tapMoveThreshPxSq))) { this.holdPressCur = false; } // End long-press on swipe? else if (this.config.endLongPressWhenSwiped && this.Swiped()) { this.holdPressCur = false; } else { // TODO check for long tap } } else if (this.config.detectLongPress) { if (!this.nonStaticFlag && !this.Moved(this.thresh.tapMoveThreshPxSq)) { if (this.elapsedSincePress > this.thresh.longPressMinTime) { this.holdPressCur = true; } else { longPressStillPossible = true; } } } // Detect normal press... if (this.cleanPressCur) { } else if (!this.holdPressCur && !longPressStillPossible && !this.IsPotentialTap()) { this.cleanPressCur = true; } } // Calculate scroll vector... Vector2 dragVecCur = this.GetSwipeVecRaw(); if (this.scrollConstraint != TouchGestureConfig.DirConstraint.None) { if (this.scrollConstraint == TouchGestureConfig.DirConstraint.Auto) { if (Mathf.Abs(dragVecCur.x) > this.thresh.scrollThreshPx) { this.scrollConstraint = TouchGestureConfig.DirConstraint.Horizontal; } if ((Mathf.Abs(dragVecCur.y) > this.thresh.scrollThreshPx) && (Mathf.Abs(dragVecCur.y) > Mathf.Abs(dragVecCur.x))) { this.scrollConstraint = TouchGestureConfig.DirConstraint.Vertical; } } if (this.scrollConstraint == TouchGestureConfig.DirConstraint.Horizontal) { dragVecCur.y = 0; } else if (this.scrollConstraint == TouchGestureConfig.DirConstraint.Vertical) { dragVecCur.x = 0; } } for (int axisi = 0; axisi < 2; ++axisi) { this.scrollVecCur[axisi] = CFUtils.GetScrollValue(dragVecCur[axisi], (int)this.scrollVecCur[axisi], this.thresh.scrollThreshPx, this.thresh.scrollMagnetFactor); } // Determinate swipe constraint... this.constrainedVecCur = this.GetSwipeVecSmooth(); if (this.swipeConstraint != TouchGestureConfig.DirConstraint.None) { if (this.swipeConstraint == TouchGestureConfig.DirConstraint.Auto) { if (Mathf.Abs(this.extremeDistPerAxisCur.x) > this.thresh.dragThreshPx) { this.swipeConstraint = TouchGestureConfig.DirConstraint.Horizontal; } if ((Mathf.Abs(this.extremeDistPerAxisCur.y) > this.thresh.dragThreshPx) && (Mathf.Abs(this.extremeDistPerAxisCur.y) > Mathf.Abs(this.extremeDistPerAxisCur.x))) { this.swipeConstraint = TouchGestureConfig.DirConstraint.Vertical; } } if (this.swipeConstraint == TouchGestureConfig.DirConstraint.Horizontal) { this.constrainedVecCur.y = 0; } else if (this.swipeConstraint == TouchGestureConfig.DirConstraint.Vertical) { this.constrainedVecCur.x = 0; } else { this.constrainedVecCur = Vector2.zero; } } // Swipe check... if (!this.moved && !this.blockDrag) { if ((this.constrainedVecCur.sqrMagnitude > this.thresh.dragThreshPxSq)) { this.OnSwipeStart(); } } // Swipe direction... Vector2 swipeSegVec = (this.posCurSmooth - this.segmentOrigin); if (this.swipeDirConstraint != TouchGestureConfig.DirConstraint.None) { if (this.swipeDirConstraint == TouchGestureConfig.DirConstraint.Auto) { if (Mathf.Abs(swipeSegVec.x) > this.thresh.swipeSegLenPx) { this.swipeDirConstraint = TouchGestureConfig.DirConstraint.Horizontal; } if ((Mathf.Abs(swipeSegVec.y) > this.thresh.swipeSegLenPx) && (Mathf.Abs(swipeSegVec.y) > Mathf.Abs(swipeSegVec.x))) { this.swipeDirConstraint = TouchGestureConfig.DirConstraint.Vertical; } } if (this.swipeDirConstraint == TouchGestureConfig.DirConstraint.Horizontal) { swipeSegVec.y = 0; } else if (this.swipeDirConstraint == TouchGestureConfig.DirConstraint.Vertical) { swipeSegVec.x = 0; } else { swipeSegVec = Vector2.zero; } } float swipeSegVecLenSq = swipeSegVec.sqrMagnitude; if (swipeSegVecLenSq > this.thresh.swipeSegLenPxSq) { swipeSegVec.Normalize(); this.swipeDirState4.SetDir(CFUtils.VecToDir(swipeSegVec, this.swipeDirState4.GetCur(), 0.1f, false), config.swipeOriginalDirResetMode); this.swipeDirState8.SetDir(CFUtils.VecToDir(swipeSegVec, this.swipeDirState8.GetCur(), 0.1f, true), config.swipeOriginalDirResetMode); this.swipeDirState.SetDir(((config.dirMode == TouchGestureConfig.DirMode.EightWay) ? this.swipeDirState8 : this.swipeDirState4).GetCur(), config.swipeOriginalDirResetMode); this.segmentOrigin = this.posCurSmooth; } }
public void PopulateFromHashtable(Hashtable hash) { this.tinyurl = CFUtils.GetHashValueAsNonNullString(hash, "tinyurl"); }