Ejemplo n.º 1
0
 public SparkyInfo(SparkyInfo src)
 {
     this.width        = src.width;
     this.taper        = src.taper;
     this.trailColor   = src.trailColor;
     this.lineMaterial = src.lineMaterial;
 }
Ejemplo n.º 2
0
    // Copy the instance values into the line renderer.
    //
    // TODO: we can probably just create the line renderer here.
    //
    public static LineRenderer InitLineRenderer(GameObject onObj, SparkyInfo info)
    {
        LineRenderer lr = onObj.AddComponent <LineRenderer> ();

        if (lr == null)
        {
            Debug.LogError("LineRenderer already exists on SparkyKit object: " + onObj.name);
            lr = onObj.GetComponent <LineRenderer> ();
        }

        lr.positionCount = 2;
        lr.colorGradient = info.trailColor;

        if (info.lineMaterial == null)
        {
            Debug.LogError("No material provided for SparkyKit object: " + onObj);
        }
        else
        {
            lr.material = new Material(info.lineMaterial);
        }

        lr.startWidth = info.width;
        lr.endWidth   = info.width;

        // TODO: These are backwards.  Fix it!
        if (info.taper > 0)
        {
            lr.startWidth = lr.endWidth * (1f - info.taper);
        }
        else if (info.taper < 0)
        {
            lr.endWidth = lr.startWidth * (1f + info.taper);
        }

        return(lr);
    }