예제 #1
0
        // Use this for initialization
        void Start()
        {
            // Create the line mesh
            if (numPoints < 2)
            {
                numPoints = 2;
            }
            vertices  = new Vector3[numPoints];
            startTime = Time.time;
            lr        = transform.GetComponent <LineRenderer2> ();
            if (lr == null)
            {
                lr = gameObject.AddComponent <LineRenderer2> ();
            }
            lr.SetVertexBufferSize(vertices.Length);
            lr.SetVertexCount(vertices.Length);
            lr.useWorldSpace = false;
            lr.SetWidth(lineWidth, lineWidth);
            if (!reuseMaterial)
            {
                lineMaterial = Instantiate(lineMaterial);
            }
            lineMaterial.color = color;
            lr.material        = lineMaterial;      // needs to instantiate to preserve individual color so can't use sharedMaterial
            lr.SetColors(color, color);

            vertices = new Vector3[numPoints];
            for (int s = 0; s < numPoints; s++)
            {
                float   t         = (float)s / (numPoints - 1);
                float   elevation = Mathf.Sin(t * Mathf.PI) * arcElevation;
                Vector3 sPos;
                if (earthInvertedMode)
                {
                    sPos = Vector3.Lerp(start, end, t).normalized * 0.5f * (1.0f - elevation);
                }
                else
                {
                    sPos = Vector3.Lerp(start, end, t).normalized * 0.5f * (1.0f + elevation);
                }
                vertices [s] = sPos;
                lr.SetPosition(s, sPos);
            }
            startAutoFadeTime = float.MaxValue;
            colorTransparent  = new Color(color.r, color.g, color.b, 0);

            if (duration == 0)
            {
                lr.Update();
                UpdateLine();
            }
        }