Exemplo n.º 1
0
        // Needs to be called once waypoints and decoder are assigned, to setup or refresh path data.
        internal void FinalizePath(bool isClosedPath, AxisConstraint lockPositionAxes, Vector3 currTargetVal)
        {
            // Rebuild path to lock eventual axes
            if (lockPositionAxes != AxisConstraint.None) {
                bool lockX = ((lockPositionAxes & AxisConstraint.X) == AxisConstraint.X);
                bool lockY = ((lockPositionAxes & AxisConstraint.Y) == AxisConstraint.Y);
                bool lockZ = ((lockPositionAxes & AxisConstraint.Z) == AxisConstraint.Z);
                for (int i = 0; i < wps.Length; ++i) {
                    Vector3 pt = wps[i];
                    wps[i] = new Vector3(
                        lockX ? currTargetVal.x : pt.x,
                        lockY ? currTargetVal.y : pt.y,
                        lockZ ? currTargetVal.z : pt.z
                    );
                }
            }

            _decoder.FinalizePath(this, wps, isClosedPath);
            isFinalized = true;
        }
        /// <summary>
        /// ProjectHandlebarGivenConstraint internal function to account for axis constraint
        /// </summary>
        /// <param name="constraint">Enum value describing the axis to which the rotation is constrained/param>
        /// <param name="handlebarRotation">A Vector3 describing the rotation of the line connecting the inputSources</param>
        /// <param name="manipulationRoot">Transform of gameObject to be two hand manipulated</param>
        /// <returns>a Vector3 describing handlebar after constraint is applied</returns>
        private Vector3 ProjectHandlebarGivenConstraint(AxisConstraint constraint, Vector3 handlebarRotation, Transform manipulationRoot)
        {
            Vector3 result = handlebarRotation;

            switch (constraint)
            {
            case AxisConstraint.XAxisOnly:
                result.x = 0;
                break;

            case AxisConstraint.YAxisOnly:
                result.y = 0;
                break;

            case AxisConstraint.ZAxisOnly:
                result.z = 0;
                break;
            }
            return(CameraCache.Main.transform.TransformDirection(result));
        }
Exemplo n.º 3
0
        // Token: 0x060001FB RID: 507 RVA: 0x0000B844 File Offset: 0x00009A44
        public override void SetChangeValue(TweenerCore <Vector3, Vector3, VectorOptions> t)
        {
            AxisConstraint axisConstraint = t.plugOptions.axisConstraint;

            if (axisConstraint == AxisConstraint.X)
            {
                t.changeValue = new Vector3(t.endValue.x - t.startValue.x, 0f, 0f);
                return;
            }
            if (axisConstraint == AxisConstraint.Y)
            {
                t.changeValue = new Vector3(0f, t.endValue.y - t.startValue.y, 0f);
                return;
            }
            if (axisConstraint != AxisConstraint.Z)
            {
                t.changeValue = t.endValue - t.startValue;
                return;
            }
            t.changeValue = new Vector3(0f, 0f, t.endValue.z - t.startValue.z);
        }
Exemplo n.º 4
0
        // Needs to be called once waypoints and decoder are assigned, to setup or refresh path data.
        internal void FinalizePath(bool isClosedPath, AxisConstraint lockPositionAxes, Vector3 currTargetVal)
        {
            // Rebuild path to lock eventual axes
            if (lockPositionAxes != AxisConstraint.None)
            {
                bool lockX = ((lockPositionAxes & AxisConstraint.X) == AxisConstraint.X);
                bool lockY = ((lockPositionAxes & AxisConstraint.Y) == AxisConstraint.Y);
                bool lockZ = ((lockPositionAxes & AxisConstraint.Z) == AxisConstraint.Z);
                for (int i = 0; i < wps.Length; ++i)
                {
                    Vector3 pt = wps[i];
                    wps[i] = new Vector3(
                        lockX ? currTargetVal.x : pt.x,
                        lockY ? currTargetVal.y : pt.y,
                        lockZ ? currTargetVal.z : pt.z
                        );
                }
            }

            _decoder.FinalizePath(this, wps, isClosedPath);
        }
Exemplo n.º 5
0
        public override void SetFrom(TweenerCore <Vector3, Vector3, VectorOptions> t, bool isRelative)
        {
            Vector3 endValue = t.endValue;

            t.endValue   = t.getter();
            t.startValue = (isRelative ? (t.endValue + endValue) : endValue);
            Vector3        pNewValue      = t.endValue;
            AxisConstraint axisConstraint = t.plugOptions.axisConstraint;

            switch (axisConstraint)
            {
            case AxisConstraint.X:
                pNewValue.x = t.startValue.x;
                goto IL_A0;

            case (AxisConstraint)3:
                break;

            case AxisConstraint.Y:
                pNewValue.y = t.startValue.y;
                goto IL_A0;

            default:
                if (axisConstraint == AxisConstraint.Z)
                {
                    pNewValue.z = t.startValue.z;
                    goto IL_A0;
                }
                break;
            }
            pNewValue = t.startValue;
IL_A0:
            if (t.plugOptions.snapping)
            {
                pNewValue.x = (float)Math.Round((double)pNewValue.x);
                pNewValue.y = (float)Math.Round((double)pNewValue.y);
                pNewValue.z = (float)Math.Round((double)pNewValue.z);
            }
            t.setter(pNewValue);
        }
Exemplo n.º 6
0
        // Token: 0x060001F8 RID: 504 RVA: 0x0000B724 File Offset: 0x00009924
        public override void SetFrom(TweenerCore <Vector3, Vector3, VectorOptions> t, bool isRelative)
        {
            Vector3 endValue = t.endValue;

            t.endValue   = t.getter();
            t.startValue = (isRelative ? (t.endValue + endValue) : endValue);
            Vector3        vector         = t.endValue;
            AxisConstraint axisConstraint = t.plugOptions.axisConstraint;

            if (axisConstraint != AxisConstraint.X)
            {
                if (axisConstraint != AxisConstraint.Y)
                {
                    if (axisConstraint != AxisConstraint.Z)
                    {
                        vector = t.startValue;
                    }
                    else
                    {
                        vector.z = t.startValue.z;
                    }
                }
                else
                {
                    vector.y = t.startValue.y;
                }
            }
            else
            {
                vector.x = t.startValue.x;
            }
            if (t.plugOptions.snapping)
            {
                vector.x = (float)Math.Round((double)vector.x);
                vector.y = (float)Math.Round((double)vector.y);
                vector.z = (float)Math.Round((double)vector.z);
            }
            t.setter(vector);
        }
Exemplo n.º 7
0
 protected override void JsonTo(IJsonNode json)
 {
     if (json.Contains("beginRotate"))
     {
         BeginRotate = JTweenUtils.JsonToVector3(json.GetNode("beginRotate"));
     }
     // end if
     if (json.Contains("towards"))
     {
         m_towards = JTweenUtils.JsonToVector3(json.GetNode("towards"));
     }
     // end if
     if (json.Contains("axis"))
     {
         m_axisConstraint = (AxisConstraint)(int)json.GetInt("axis");
     }
     // end if
     if (json.Contains("up"))
     {
         m_up = JTweenUtils.JsonToVector3(json.GetNode("up"));
     }
     // end if
     Restore();
 }
Exemplo n.º 8
0
 protected override void JsonTo(JsonData json)
 {
     if (json.Contains("beginRotate"))
     {
         BeginRotate = JTweenUtils.JsonToVector3(json["beginRotate"]);
     }
     // end if
     if (json.Contains("towards"))
     {
         m_towards = JTweenUtils.JsonToVector3(json["towards"]);
     }
     // end if
     if (json.Contains("axis"))
     {
         m_axisConstraint = (AxisConstraint)(int)json["axis"];
     }
     // end if
     if (json.Contains("up"))
     {
         m_up = JTweenUtils.JsonToVector3(json["up"]);
     }
     // end if
     Restore();
 }
 public static Tweener SetOptions(this TweenerCore <Vector3, Vector3, VectorOptions> t, bool snapping) => default;                                                                   // 0x004D7B80-0x004D7BA0
 public static Tweener SetOptions(this TweenerCore <Vector3, Vector3, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false /* Metadata: 0x0060FA31 */) => default; // 0x004D7D90-0x004D7DB0
Exemplo n.º 10
0
 /// <summary>
 /// Initializes twohand system with controller/hand source info:
 /// the Dictionary collection already filled with controller/hand info,
 /// and the Transform of the GameObject to be manipulated.
 /// </summary>
 /// <param name="handsPressedMap">Dictionary listing inputSourceStates</param>
 /// <param name="manipulationRoot">Transform of gameObject to be two hand manipulated</param>
 public void Setup(Dictionary <uint, Vector3> handsPressedMap, Transform manipulationRoot)
 {
     currentRotationConstraint = rotationConstraint;
     previousHandlebarRotation = GetHandlebarDirection(handsPressedMap, manipulationRoot);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
 /// The new axes will appear after any that were previously defined.
 /// </summary>
 /// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
 /// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
 public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range <int> rangeBoth, int midBoth, AxisConstraint constraint = null)
 => def.AddXYPair(nameFormat, pDir, rangeBoth, midBoth, rangeBoth, midBoth, constraint);
Exemplo n.º 12
0
 /// <summary>
 /// Adds an axis to the receiver <see cref="ControllerDefinition"/>, and returns it.
 /// The new axis will appear after any that were previously defined.
 /// </summary>
 /// <param name="constraint">pass only for one axis in a pair, by convention the X axis</param>
 /// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
 public static ControllerDefinition AddAxis(this ControllerDefinition def, string name, Range <int> range, int mid, bool isReversed = false, AxisConstraint constraint = null)
 {
     def.Axes.Add(name, new AxisSpec(range, mid, isReversed, constraint));
     return(def);
 }
Exemplo n.º 13
0
        /// <summary>Tweens a Rigidbody's rotation so that it will look towards the given position.
        /// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
        /// <param name="towards">The position to look at</param><param name="duration">The duration of the tween</param>
        /// <param name="axisConstraint">Eventual axis constraint for the rotation</param>
        /// <param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
        public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
        {
#if COMPATIBLE
            TweenerCore<QuaternionWrapper, Vector3Wrapper, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.MoveRotation(x), towards, duration)
#else
            TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration)
#endif
                .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);
            t.plugOptions.axisConstraint = axisConstraint;
            t.plugOptions.up = (up == null) ? Vector3.up : (Vector3)up;
            return t;
        }
Exemplo n.º 14
0
        public static TweenerCore <Vector3, Vector3, VectorOptions> ToAxis(DOGetter <Vector3> getter, DOSetter <Vector3> setter, float endValue, float duration, AxisConstraint axisConstraint = AxisConstraint.X)
        {
            TweenerCore <Vector3, Vector3, VectorOptions> tweenerCore = DOTween.ApplyTo <Vector3, Vector3, VectorOptions>(getter, setter, new Vector3(endValue, endValue, endValue), duration, null);

            tweenerCore.plugOptions.axisConstraint = axisConstraint;
            return(tweenerCore);
        }
Exemplo n.º 15
0
        public override void Reset()
        {
            base.Reset();

            gameObject = null;

            duration = new FsmFloat {
                UseVariable = false
            };
            setSpeedBased = new FsmBool {
                UseVariable = false, Value = false
            };
            pathType   = PathType.Linear;
            pathMode   = PathMode.Full3D;
            resolution = new FsmInt {
                UseVariable = false, Value = 10
            };
            gizmoColor = new FsmColor {
                UseVariable = false
            };

            closePath = new FsmBool {
                UseVariable = false, Value = false
            };
            lockPosition = AxisConstraint.None;
            lockRotation = AxisConstraint.None;

            lookAt         = LookAt.nothing;
            lookAtPosition = new FsmVector3 {
                UseVariable = false, Value = Vector3.zero
            };
            lookAtTarget = new FsmGameObject {
                UseVariable = false, Value = null
            };
            lookAhead = new FsmFloat {
                UseVariable = false, Value = 0
            };

            forwardDirection = new FsmVector3 {
                UseVariable = false, Value = Vector3.forward
            };
            up = new FsmVector3 {
                UseVariable = false, Value = Vector3.up
            };

            startEvent        = null;
            finishEvent       = null;
            finishImmediately = new FsmBool {
                UseVariable = false, Value = false
            };

            startDelay = new FsmFloat {
                Value = 0
            };
            easeType = Ease.Linear;

            loops = new FsmInt {
                Value = 0
            };
            loopType = LoopType.Restart;

            autoKillOnCompletion = new FsmBool {
                Value = true
            };
            recyclable = new FsmBool {
                Value = false
            };

            updateType          = UpdateType.Normal;
            isIndependentUpdate = new FsmBool {
                Value = false
            };

            debugThis = new FsmBool {
                Value = false
            };
        }
Exemplo n.º 16
0
 public void Reset()
 {
     axisConstraint = AxisConstraint.None;
     snapping       = false;
 }
Exemplo n.º 17
0
        public static Tweener DOLookAt(this Transform target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3?up = null)
        {
            TweenerCore <Quaternion, Vector3, QuaternionOptions> tweenerCore = DOTween.To(() => target.rotation, delegate(Quaternion x)
            {
                target.rotation = x;
            }, towards, duration).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);

            tweenerCore.plugOptions.axisConstraint = axisConstraint;
            tweenerCore.plugOptions.up             = ((!up.HasValue) ? Vector3.up : up.Value);
            return(tweenerCore);
        }
Exemplo n.º 18
0
 protected PenAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel)
 {
     this.viewModel        = viewModel;
     this.pathEditorTarget = pathEditorTarget;
     this.axisConstraint   = new AxisConstraint();
 }
        // Token: 0x06000194 RID: 404 RVA: 0x00008900 File Offset: 0x00006B00
        public override void EvaluateAndApply(Vector3ArrayOptions options, Tween t, bool isRelative, DOGetter <Vector3> getter, DOSetter <Vector3> setter, float elapsed, Vector3[] startValue, Vector3[] changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice)
        {
            Vector3 vector = Vector3.zero;

            if (t.loopType == LoopType.Incremental)
            {
                int num = t.isComplete ? (t.completedLoops - 1) : t.completedLoops;
                if (num > 0)
                {
                    int num2 = startValue.Length - 1;
                    vector = (startValue[num2] + changeValue[num2] - startValue[0]) * (float)num;
                }
            }
            if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental)
            {
                int num3 = ((t.loopType == LoopType.Incremental) ? t.loops : 1) * (t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops);
                if (num3 > 0)
                {
                    int num4 = startValue.Length - 1;
                    vector += (startValue[num4] + changeValue[num4] - startValue[0]) * (float)num3;
                }
            }
            int   num5 = 0;
            float num6 = 0f;
            float num7 = 0f;
            int   num8 = options.durations.Length;
            float num9 = 0f;

            for (int i = 0; i < num8; i++)
            {
                num7  = options.durations[i];
                num9 += num7;
                if (elapsed <= num9)
                {
                    num5 = i;
                    num6 = elapsed - num6;
                    break;
                }
                num6 += num7;
            }
            float          num10          = EaseManager.Evaluate(t.easeType, t.customEase, num6, num7, t.easeOvershootOrAmplitude, t.easePeriod);
            AxisConstraint axisConstraint = options.axisConstraint;
            Vector3        vector2;

            if (axisConstraint == AxisConstraint.X)
            {
                vector2   = getter();
                vector2.x = startValue[num5].x + vector.x + changeValue[num5].x * num10;
                if (options.snapping)
                {
                    vector2.x = (float)Math.Round((double)vector2.x);
                }
                setter(vector2);
                return;
            }
            if (axisConstraint == AxisConstraint.Y)
            {
                vector2   = getter();
                vector2.y = startValue[num5].y + vector.y + changeValue[num5].y * num10;
                if (options.snapping)
                {
                    vector2.y = (float)Math.Round((double)vector2.y);
                }
                setter(vector2);
                return;
            }
            if (axisConstraint != AxisConstraint.Z)
            {
                vector2.x = startValue[num5].x + vector.x + changeValue[num5].x * num10;
                vector2.y = startValue[num5].y + vector.y + changeValue[num5].y * num10;
                vector2.z = startValue[num5].z + vector.z + changeValue[num5].z * num10;
                if (options.snapping)
                {
                    vector2.x = (float)Math.Round((double)vector2.x);
                    vector2.y = (float)Math.Round((double)vector2.y);
                    vector2.z = (float)Math.Round((double)vector2.z);
                }
                setter(vector2);
                return;
            }
            vector2   = getter();
            vector2.z = startValue[num5].z + vector.z + changeValue[num5].z * num10;
            if (options.snapping)
            {
                vector2.z = (float)Math.Round((double)vector2.z);
            }
            setter(vector2);
        }
Exemplo n.º 20
0
 public static Tweener DOLookAt(Transform target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null, float delay = 0, System.Action doComplete = null)
 {
     Tweener tweener = target.DOLookAt(towards, duration, axisConstraint, up);
     SetTweenerComplete(tweener, delay, doComplete);
     return tweener;
 }
Exemplo n.º 21
0
    void Start()
    {
        Vector3[] path = new[] {
            new Vector3(0, 1, 0),
            new Vector3(1, 2, 0),
            new Vector3(2, 1, 0),
            new Vector3(2, 0, 0)
        };

        TweenParams tp = new TweenParams()
                         .SetEase(ease)
                         .SetLoops(-1, loopType);

        AxisConstraint lockRotation = lockRotation0 | lockRotation1;

        // Relative VS non relative
        controller = targets[0].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
                     .SetOptions(closePaths, lockPosition, lockRotation)
                     .SetLookAt(0.1f, forward)
                     .SetAs(tp)
                     .SetRelative()
                     .Pause();
        targets[1].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[1])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetLookAt(targets[2], forward)
        .SetAs(tp)
        .Pause();

        // Linear VS curved
        targets[2].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetLookAt(new Vector3(3, 0, 0), forward)
        .SetAs(tp)
        .SetRelative()
        .Pause();
        targets[3].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetLookAt(0.1f, forward)
        .SetAs(tp)
        .SetRelative()
        .Pause();

        // Linear VS curved no lookAt
        targets[4].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetAs(tp)
        .SetRelative()
        .Pause();
        targets[5].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetAs(tp)
        .SetRelative()
        .Pause();

        // Linear VS curved top-down
        path = new[] {
            new Vector3(0, 0, 1),
            new Vector3(1, 0, 2),
            new Vector3(2, 0, 1),
            new Vector3(2, 0, 0)
        };
        targets[6].DOPath(path, 3, PathType.CatmullRom, pathMode, pathResolution, pathsColors[0])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetLookAt(0.1f, forward)
        .SetAs(tp)
        .SetRelative()
        .Pause();
        targets[7].DOPath(path, 3, PathType.Linear, pathMode, pathResolution, pathsColors[1])
        .SetOptions(closePaths, lockPosition, lockRotation)
        .SetLookAt(0.1f, forward)
        .SetAs(tp)
        .SetRelative()
        .Pause();
    }
Exemplo n.º 22
0
 public Tweener DOLookAt(int charIndex, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None,
                         Vector3?up = null)
 {
     return(MonitorTransformTween(GetProxyTransform(charIndex).DOLookAt(towards, duration, axisConstraint, up)));
 }
Exemplo n.º 23
0
        public override void Reset()
        {
            base.Reset();

            gameObject = null;

            target = null;

            duration = new FsmFloat {
                UseVariable = false
            };
            setSpeedBased = new FsmBool {
                UseVariable = false, Value = false
            };
            axisConstraint = AxisConstraint.None;
            up             = new FsmVector3 {
                UseVariable = false, Value = Vector3.up
            };

            setRelative = new FsmBool {
                UseVariable = false, Value = false
            };

            playInReverse = new FsmBool {
                UseVariable = false, Value = false
            };
            setReverseRelative = new FsmBool {
                UseVariable = false, Value = false
            };

            startEvent        = null;
            finishEvent       = null;
            finishImmediately = new FsmBool {
                UseVariable = false, Value = false
            };

            stringAsId = new FsmString {
                UseVariable = false
            };
            tagAsId = new FsmString {
                UseVariable = false
            };

            startDelay = new FsmFloat {
                Value = 0
            };

            selectedEase = DOTweenActionsEnums.SelectedEase.EaseType;
            easeType     = Ease.Linear;

            loops = new FsmInt {
                Value = 0
            };
            loopType = LoopType.Restart;

            autoKillOnCompletion = new FsmBool {
                Value = true
            };
            recyclable = new FsmBool {
                Value = false
            };

            updateType          = UpdateType.Normal;
            isIndependentUpdate = new FsmBool {
                Value = false
            };

            debugThis = new FsmBool {
                Value = false
            };
        }
        public float[]        durations; // Duration of each segment

        public void Reset()
        {
            axisConstraint = AxisConstraint.None;
            snapping       = false;
            durations      = null;
        }
Exemplo n.º 25
0
        public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3?up = default(Vector3?))
        {
            TweenerCore <Quaternion, Vector3, QuaternionOptions> tweenerCore = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);

            tweenerCore.plugOptions.axisConstraint = axisConstraint;
            tweenerCore.plugOptions.up             = (up.HasValue ? up.Value : Vector3.up);
            return(tweenerCore);
        }
 public static TweenerCore <Vector3, Path, PathOptions> SetOptions(this TweenerCore <Vector3, Path, PathOptions> t, AxisConstraint lockPosition, AxisConstraint lockRotation = AxisConstraint.None)
 {
     return(t.SetOptions(false, lockPosition, lockRotation));
 }
Exemplo n.º 27
0
        /// <summary>Options for Vector3Array tweens</summary>
        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
        public static Tweener SetOptions(this TweenerCore <Vector3, Vector3[], Vector3ArrayOptions> t, AxisConstraint axisConstraint, bool snapping = false)
        {
            if (t == null || !t.active)
            {
                return(t);
            }

            t.plugOptions.axisConstraint = axisConstraint;
            t.plugOptions.snapping       = snapping;
            return(t);
        }
 public static Tweener SetOptions(this TweenerCore <Vector4, Vector4, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false)
 {
     if ((t != null) && t.active)
     {
         t.plugOptions.axisConstraint = axisConstraint;
         t.plugOptions.snapping       = snapping;
     }
     return(t);
 }
Exemplo n.º 29
0
        /// <summary>
        /// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
        /// The new axes will appear after any that were previously defined.
        /// </summary>
        /// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
        /// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
        public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range <int> rangeX, int midX, Range <int> rangeY, int midY, AxisConstraint constraint = null)
        {
            var yAxisName       = string.Format(nameFormat, "Y");
            var finalConstraint = constraint ?? new NoOpAxisConstraint(yAxisName);

            return(def.AddAxis(string.Format(nameFormat, "X"), rangeX, midX, ((byte)pDir & 2) != 0, finalConstraint)
                   .AddAxis(yAxisName, rangeY, midY, ((byte)pDir & 1) != 0));
        }
 public static TweenerCore <Vector3, Path, PathOptions> SetOptions(this TweenerCore <Vector3, Path, PathOptions> t, bool closePath, AxisConstraint lockPosition = AxisConstraint.None, AxisConstraint lockRotation = AxisConstraint.None)
 {
     if ((t != null) && t.active)
     {
         t.plugOptions.isClosedPath     = closePath;
         t.plugOptions.lockPositionAxis = lockPosition;
         t.plugOptions.lockRotationAxis = lockRotation;
     }
     return(t);
 }
Exemplo n.º 31
0
 /// <summary>Tweens a Transform's rotation so that it will look towards the given position.
 /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="towards">The position to look at</param><param name="duration">The duration of the tween</param>
 /// <param name="axisConstraint">Eventual axis constraint for the rotation</param>
 /// <param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
 public static Tweener DOLookAt(this Transform target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
 {
     TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, towards, duration)
         .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);
     t.plugOptions.axisConstraint = axisConstraint;
     t.plugOptions.up = (up == null) ? Vector3.up : (Vector3)up;
     return t;
 }
Exemplo n.º 32
0
        public Vector3        up;             // Used by SpecialStartupMode SetLookAt, accessed by shortcuts and Modules

        public void Reset()
        {
            rotateMode     = RotateMode.Fast;
            axisConstraint = AxisConstraint.None;
            up             = Vector3.zero;
        }
Exemplo n.º 33
0
        /// <summary>Tweens a Rigidbody's rotation so that it will look towards the given position.
        /// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary>
        /// <param name="towards">The position to look at</param><param name="duration">The duration of the tween</param>
        /// <param name="axisConstraint">Eventual axis constraint for the rotation</param>
        /// <param name="up">The vector that defines in which direction up is (default: Vector3.up)</param>
        public static TweenerCore <Quaternion, Vector3, QuaternionOptions> DOLookAt(this Rigidbody target,
                                                                                    Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3?up = null)
        {
            TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween
                                                                     .To(() => target.rotation, target.MoveRotation, towards, duration)
                                                                     .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt);

            t.plugOptions.axisConstraint = axisConstraint;
            t.plugOptions.up             = (up == null) ? Vector3.up : (Vector3)up;
            return(t);
        }
Exemplo n.º 34
0
 /// <summary>
 /// TwoHandRotateLogic Constructor
 /// </summary>
 /// <param name="constrainRotation">Enum describing to which axis the rotation is constrained</param>
 public TwoHandRotateLogic(AxisConstraint constrainRotation)
 {
     rotationConstraint = constrainRotation;
 }