using System.Collections; using System.Collections.Generic; using UnityEngine; public class Testing : MonoBehaviour { public Material transparentMat; public Material boneMaterial; private GameObject obj; private float t; private int counter; // Start is called before the first frame update void Start() { obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.GetComponent().material = transparentMat; LineRenderer lr = obj.AddComponent(); lr.positionCount = 2; lr.material = boneMaterial; Color line = new Color(1, 1, 1, 0); lr.startColor = line; lr.endColor = line; lr.startWidth = 0.3f; lr.endWidth = 0.3f; lr.SetPosition(0, obj.transform.position); lr.SetPosition(1, new Vector3(1,1,1)); } // Update is called once per frame void Update() { if (t >= 1) { Destroy(obj); return; } t += Time.deltaTime / 2; Color newColor = new Color(1, 1, 1, Mathf.Lerp(0, 1, t)); obj.GetComponent().material.color = newColor; obj.GetComponent().startColor = newColor; obj.GetComponent().endColor = newColor; } }