Beispiel #1
0
    /// <summary>
    /// Returns a Tween instance that is configured to animate a Transform along a spline path
    /// </summary>
    /// <param name="component">The component whose position will be animated along the path</param>
    /// <param name="path">The Spline path to follow</param>
    /// <param name="orientToPath">If set to TRUE, the object will be oriented to match the path's direction</param>
    public static Tween <float> TweenPath(this Component component, IPathIterator path, bool orientToPath)
    {
        if (component == null)
        {
            throw new ArgumentNullException("component");
        }

        return(TweenTransformExtensions.TweenPath(component.transform, path));
    }
Beispiel #2
0
    /// <summary>
    /// Returns a Tween instance that is configured to animate a Transform along a spline path
    /// </summary>
    /// <param name="transform">The Transfrom whose position will be animated along the path</param>
    /// <param name="path">The Spline path to follow</param>
    /// <param name="orientToPath">If set to TRUE, the object will be oriented to match the path's direction</param>
    public static Tween <float> TweenPath(this Transform transform, IPathIterator path, bool orientToPath)
    {
        if (transform == null)
        {
            throw new ArgumentNullException("transform");
        }

        if (path == null)
        {
            throw new ArgumentNullException("path");
        }

        // Declared here so that it can be referenced in the anonymous function assigned in OnExecute()
        Tween <float> tween = null;

        tween = Tween <float> .Obtain()
                .SetStartValue(0f)
                .SetEndValue(1f)
                .SetEasing(TweenEasingFunctions.Linear)
                .OnExecute((time) =>
        {
            transform.position = path.GetPosition(time);

            if (orientToPath)
            {
                var direction = path.GetTangent(time);
                if (tween.PlayDirection == TweenDirection.Forward)
                {
                    transform.forward = direction;
                }
                else
                {
                    transform.forward = -direction;
                }
            }
        });

        return(tween);
    }
Beispiel #3
0
 public PrettyPathPainter(string path_provided, IPathIterator pathIterator)
 {
     _path_provided = path_provided;
     _path_iterator = pathIterator;
 }
Beispiel #4
0
 public PrettyPathPainter(string path_provided,IPathIterator pathIterator)
 {
     _path_provided = path_provided;
     _path_iterator = pathIterator;
 }
Beispiel #5
0
 /// <summary>
 /// Returns a Tween instance that is configured to animate a Transform along a spline path
 /// </summary>
 /// <param name="transform">The Transfrom whose position will be animated along the path</param>
 /// <param name="path">The Spline path to follow</param>
 public static Tween <float> TweenPath(this Transform transform, IPathIterator path)
 {
     return(TweenPath(transform, path, true));
 }
Beispiel #6
0
 /// <summary>
 /// Returns a Tween instance that is configured to animate a Transform along a spline path
 /// </summary>
 /// <param name="component">The component whose position will be animated along the path</param>
 /// <param name="path">The Spline path to follow</param>
 public static Tween <float> TweenPath(this Component component, IPathIterator path)
 {
     return(TweenPath(component, path, true));
 }