Removes all points from the TrailRenderer. Useful for restarting a trail from a new position.
#pragma strict private var tr: TrailRenderer; function Start() { tr = GetComponent.<TrailRenderer>(); tr.material = new Material(Shader.Find("Sprites/Default")); } function Update() { tr.transform.position = new Vector3(Mathf.Sin(Time.time * 1.51f) * 7.0f, Mathf.Cos(Time.time * 1.27f) * 4.0f, 0.0f); } function OnGUI() { if (GUI.Button(new Rect(25, 25, 200, 30), "Clear")) tr.Clear(); }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { private TrailRenderer tr;
void Start() { tr = GetComponent<TrailRenderer>(); tr.material = new Material(Shader.Find("Sprites/Default")); }
void Update() { tr.transform.position = new Vector3(Mathf.Sin(Time.time * 1.51f) * 7.0f, Mathf.Cos(Time.time * 1.27f) * 4.0f, 0.0f); }
void OnGUI() { if (GUI.Button(new Rect(25, 25, 200, 30), "Clear")) tr.Clear(); } }