コード例 #1
0
        /// <summary>
        /// Shake by amount units over T seconds.
        /// </summary>
        /// <param name="tx">
        /// A <see cref="Transform"/>
        /// </param>
        /// <param name="amount">
        /// A <see cref="System.Single"/> Maximum amount of shake, in world space.
        /// </param>
        /// <param name="T"> Shake for this amount of seconds.
        /// A <see cref="System.Single"/>
        /// </param>
        public static void Shake(this Transform tx, float amount, float T)
        {
            var startPosition = tx.position;

            UniExtender.Instance.StartCoroutine(UniExtender.Step(T, delegate(float P) {
                tx.position = startPosition + (Random.onUnitSphere * amount * (1 - P));
            }));
        }
コード例 #2
0
        /// <summary>
        /// Shiver an object by amount degrees over T seconds.
        /// </summary>
        /// <param name="tx">
        /// A <see cref="Transform"/>
        /// </param>
        /// <param name="amount">
        /// A <see cref="System.Single"/> Maximum amount of shiver, in degrees.
        /// </param>
        /// <param name="T">
        /// A <see cref="System.Single"/> Shiver for this amount of seconds.
        /// </param>
        public static void Shiver(this Transform tx, float amount, float T)
        {
            var startRotation = tx.eulerAngles;

            UniExtender.Instance.StartCoroutine(UniExtender.Step(T, delegate(float P) {
                tx.eulerAngles = startRotation + (Random.onUnitSphere * amount * (1 - P));
            }));
        }
コード例 #3
0
        /// <summary>
        /// Smoothly change a camera's FOV from current to target FOV over T seconds.
        /// </summary>
        /// <param name="camera">
        /// A <see cref="Camera"/>
        /// </param>
        /// <param name="FOV">
        /// A <see cref="System.Single"/> The target FOV
        /// </param>
        /// <param name="T">
        /// A <see cref="System.Single"/> The time in seconds taken to reach the target.
        /// </param>
        public static void Zoom(this Camera camera, float FOV, float T)
        {
            var startFOV = camera.fieldOfView;

            UniExtender.Instance.StartCoroutine(UniExtender.Step(T, delegate(float P) {
                camera.fieldOfView = Mathf.Lerp(startFOV, FOV, P);
            }));
        }