private Vector3[] TravelVectors; //Vectors set in the start below void Start() { //Contoller events for thumbstick InteractionManager.InteractionSourcePressed += OnControllerPressed; InteractionManager.InteractionSourceUpdated += OnSourceUpdated; for (int m = 0; m < numOfVectors; m++) { colorArrayAlpha[m] = 1.0f; } //TriangleList.emitType = TriangleList.EmitType.Beam; TravelVectors = TriangleList.GetVectorList(); numOfVectors = TriangleList.GetVectorCount(); //myarrays = new Vector3[numOfVectors][]; }
public void GenerateMesh() { var mesh = new Mesh(); if (!transform.GetComponent <MeshFilter>()) //If you havent got any meshrenderer or filter { transform.gameObject.AddComponent <MeshFilter>(); } transform.GetComponent <MeshFilter>().mesh = mesh; //create empty color list Color[] colors = new Color[TriangleList.GetVectorCount()]; for (int i = 0; i < TriangleList.GetVectorCount(); i++) { float alpha = waveEmitter.colorArrayAlpha[i]; float maxAlpha = 1f; colors[i] = new Color(0f, 0f, 1f, alpha * maxAlpha); } // mesh.vertices = waveEmitter.GetVectorsListAtIndex(0); mesh.triangles = TriangleList.GetTriangleList(); mesh.colors = colors; mesh.RecalculateNormals(); Color c = transform.GetComponent <MeshRenderer>().material.color; float newAlpha = waveEmitter.colorArrayAlpha[0] * 0.1f; float rimAlpha = waveEmitter.colorArrayAlpha[0] * 0.2f; Color c_base = new Color(newAlpha, newAlpha, newAlpha); float a = waveEmitter.colorArrayAlpha[0]; c.a = waveEmitter.colorArrayAlpha[0]; c.r = 0.09131362f * rimAlpha; c.g = 0.2332605f * rimAlpha; c.b = 0.3396226f * rimAlpha; transform.GetComponent <MeshRenderer>().material.SetColor("_Color", c_base); transform.GetComponent <MeshRenderer>().material.SetColor("_RimColor", c); }
private Vector3[] TravelVectors; //Vectors set in the start below void Start() { //Contoller events for thumbstick #if UNITY_WSA InteractionManager.InteractionSourcePressed += OnControllerPressed; InteractionManager.InteractionSourceUpdated += OnSourceUpdated; #endif for (int m = 0; m < numOfVectors; m++) { colorArrayAlpha[m] = 1.0f; } TravelVectors = TriangleList.GetVectorList(TriangleList.EmitType.Beam); numOfVectors = TriangleList.GetVectorCount(TriangleList.EmitType.Beam); Quaternion rot = gameObject.transform.rotation; for (int i = 0; i < numOfVectors; i++) { TravelVectors[i] = rot * TravelVectors[i]; } }