// Token: 0x06004982 RID: 18818 RVA: 0x001192B4 File Offset: 0x001174B4 private void Update() { float deltaTime = base.UpdateRealTimeDelta(); if (this.mPressed) { global::SpringPosition component = base.GetComponent <global::SpringPosition>(); if (component != null) { component.enabled = false; } this.mScroll = 0f; } else { this.mMomentum += this.scale * (this.mScroll * 20f); this.mScroll = global::NGUIMath.SpringLerp(this.mScroll, 0f, 20f, deltaTime); if (this.mMomentum.magnitude > 0.01f) { this.mTrans.localPosition += global::NGUIMath.SpringDampen(ref this.mMomentum, 9f, deltaTime); this.mBounds = global::NGUIMath.CalculateAbsoluteWidgetBounds(this.rootForBounds); if (!this.ConstrainToBounds(this.dragEffect == global::UIDragObject.DragEffect.None)) { global::SpringPosition component2 = base.GetComponent <global::SpringPosition>(); if (component2 != null) { component2.enabled = false; } } return; } this.mScroll = 0f; } global::NGUIMath.SpringDampen(ref this.mMomentum, 9f, deltaTime); }
// Token: 0x06004E02 RID: 19970 RVA: 0x001377D8 File Offset: 0x001359D8 public bool ConstrainTargetToBounds(Transform target, ref global::AABBox targetBounds, bool immediate) { Vector3 vector = this.CalculateConstrainOffset(targetBounds.min, targetBounds.max); if (vector.magnitude > 0f) { if (immediate) { target.localPosition += vector; targetBounds.center += vector; global::SpringPosition component = target.GetComponent <global::SpringPosition>(); if (component != null) { component.enabled = false; } } else { global::SpringPosition springPosition = global::SpringPosition.Begin(target.gameObject, target.localPosition + vector, 13f); springPosition.ignoreTimeScale = true; springPosition.worldSpace = false; } return(true); } return(false); }
// Token: 0x06004970 RID: 18800 RVA: 0x00118AC0 File Offset: 0x00116CC0 private void LateUpdate() { float deltaTime = base.UpdateRealTimeDelta(); if (this.target == null) { return; } if (this.mPressed) { global::SpringPosition component = this.target.GetComponent <global::SpringPosition>(); if (component != null) { component.enabled = false; } this.mScroll = 0f; } else { this.mMomentum += this.scale * (-this.mScroll * 0.05f); this.mScroll = global::NGUIMath.SpringLerp(this.mScroll, 0f, 20f, deltaTime); if (this.mMomentum.magnitude > 0.0001f) { if (this.mPanel == null) { this.FindPanel(); } if (this.mPanel != null) { this.target.position += global::NGUIMath.SpringDampen(ref this.mMomentum, 9f, deltaTime); if (this.restrictWithinPanel && this.mPanel.clipping != global::UIDrawCall.Clipping.None) { this.mBounds = global::NGUIMath.CalculateRelativeWidgetBounds(this.mPanel.cachedTransform, this.target); if (!this.mPanel.ConstrainTargetToBounds(this.target, ref this.mBounds, this.dragEffect == global::UIDragObject.DragEffect.None)) { global::SpringPosition component2 = this.target.GetComponent <global::SpringPosition>(); if (component2 != null) { component2.enabled = false; } } } return; } } else { this.mScroll = 0f; } } global::NGUIMath.SpringDampen(ref this.mMomentum, 9f, deltaTime); }
// Token: 0x06004BBF RID: 19391 RVA: 0x00127EE4 File Offset: 0x001260E4 public static global::SpringPosition Begin(GameObject go, Vector3 pos, float strength) { global::SpringPosition springPosition = go.GetComponent <global::SpringPosition>(); if (springPosition == null) { springPosition = go.AddComponent <global::SpringPosition>(); } springPosition.target = pos; springPosition.strength = strength; if (!springPosition.enabled) { springPosition.mThreshold = 0f; springPosition.enabled = true; } return(springPosition); }
// Token: 0x0600497F RID: 18815 RVA: 0x001190E8 File Offset: 0x001172E8 public void Press(bool isPressed) { if (this.rootForBounds != null) { this.mPressed = isPressed; if (isPressed) { this.mBounds = global::NGUIMath.CalculateAbsoluteWidgetBounds(this.rootForBounds); this.mMomentum = Vector2.zero; this.mScroll = 0f; global::SpringPosition component = base.GetComponent <global::SpringPosition>(); if (component != null) { component.enabled = false; } } else if (this.dragEffect == global::UIDragObject.DragEffect.MomentumAndSpring) { this.ConstrainToBounds(false); } } }
// Token: 0x0600497E RID: 18814 RVA: 0x0011904C File Offset: 0x0011724C public bool ConstrainToBounds(bool immediate) { if (this.mTrans != null && this.rootForBounds != null) { Vector3 vector = this.CalculateConstrainOffset(); if (vector.magnitude > 0f) { if (immediate) { this.mTrans.position -= vector; } else { global::SpringPosition springPosition = global::SpringPosition.Begin(base.gameObject, this.mTrans.position - vector, 13f); springPosition.ignoreTimeScale = true; springPosition.worldSpace = true; } return(true); } } return(false); }
// Token: 0x0600496E RID: 18798 RVA: 0x001185A8 File Offset: 0x001167A8 private void OnPress(bool pressed) { if (base.enabled && base.gameObject.activeInHierarchy && this.target != null) { this.mPressed = pressed; if (pressed) { if ((this.restrictWithinPanel || this.restrictToScreen) && this.mPanel == null) { this.FindPanel(); } if (this.restrictWithinPanel) { this.mBounds = global::NGUIMath.CalculateRelativeWidgetBounds(this.mPanel.cachedTransform, this.target); } if (this.restrictToScreen) { global::UICamera uicamera = global::UICamera.FindCameraForLayer(base.gameObject.layer); Rect rect = global::UIDragObject.screenBorder.Add(uicamera.camera.pixelRect); this.mBounds = global::AABBox.CenterAndSize(rect.center, new Vector3(rect.width, rect.height, 0f)); } this.mMomentum = Vector3.zero; this.mScroll = 0f; global::SpringPosition component = this.target.GetComponent <global::SpringPosition>(); if (component != null) { component.enabled = false; } this.mLastPos = global::UICamera.lastHit.point; Transform transform = global::UICamera.currentCamera.transform; this.mPlane = new Plane(((!(this.mPanel != null)) ? transform.rotation : this.mPanel.cachedTransform.rotation) * Vector3.back, this.mLastPos); } else if (this.restrictWithinPanel && this.mPanel.clipping != global::UIDrawCall.Clipping.None && this.dragEffect == global::UIDragObject.DragEffect.MomentumAndSpring) { this.mPanel.ConstrainTargetToBounds(this.target, ref this.mBounds, false); } } }