Ejemplo n.º 1
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenMesh Begin(GameObject go, float duration, List <Vector3> vertexFrom, List <Vector3> vertexTo)
    {
        TweenMesh comp = UITweener.Begin <TweenMesh>(go, duration);

        comp.meshFilter = go.GetComponent <MeshFilter>();

        if (comp.meshFilter == null)
        {
            return(null);
        }
        if (vertexFrom.Count != vertexTo.Count)
        {
            return(null);
        }
        if (vertexFrom.Count != comp.meshFilter.mesh.vertexCount)
        {
            return(null);
        }

        comp.from   = vertexFrom;
        comp.to     = vertexTo;
        comp.buffer = new Vector3[vertexFrom.Count];

        if (duration <= 0f || comp.from.Count == 0)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 2
0
    void UpdatePolygon()
    {
        if (this.numPoints != this.genPoints || this.isPolygon != this.genPolygon)
        {
            // generate points
            this.genPoints = this.numPoints;

//          Debug.Log (this.numPoints+","+this.genPoints+","+this.isPolygon+","+this.genPolygon);
            this.Clear();
            if (this.isPolygon)
            {
                // generate mesh
                if (this.meshFilter == null)
                {
                    this.meshFilter = this.AddMesh();
                }
                this.genPolygon = true;
            }
            else
            {
                // generate line renderer
                if (this.linkWithCenter == true)
                {
                    for (int a = 0, d = points.Count; a < d; a++)
                    {
                        AddLine(this.offset, points [a]);
                    }
                }
                else
                {
                    for (int a = 0, b = points.Count - 1, d = points.Count; a < d; a++, b++)
                    {
                        if (b >= d)
                        {
                            b = 0;
                        }
                        AddLine(points [a], points [b]);
                    }
                }
            }
        }
        else
        {
            // update it

            if (this.isPolygon)
            {
                if (this.meshFilter != null)
                {
                    List <Vector3> begin = new List <Vector3> (this.meshFilter.mesh.vertices);
                    this.meshVertices [0] = offset;
                    for (int i = 0; i < points.Count; i++)
                    {
                        this.meshVertices [i + 1] = points [i];
                    }
                    List <Vector3> end = new List <Vector3> (this.meshVertices);
                    TweenMesh      tm  = TweenMesh.Begin(this.meshFilter.gameObject, this.duration, begin, end);
                    tm.method = UITweener.Method.EaseOut;
                }
            }
            else
            {
            }
        }
    }