public GameObject[] GetArrows() { if (Data == null || arrowPrefab == null) { return(null); } if (PreviousArrows != null) { foreach (GameObject arrow in PreviousArrows) { Destroy(arrow); } } if (!IsColorLinearlyInterpolated && IsValidIndex(ColorFieldIndex)) { SetColumnRank(ColorFieldIndex); } if (!IsSizeLinearlyInterpolated && IsValidIndex(SizeFieldIndex)) { SetColumnRank(SizeFieldIndex); } LinkedList <GameObject> arrowsList = new LinkedList <GameObject>(); System.Random random = new System.Random(80085); PositionGettingFunction GetPosition = GetPositionGettingFunction(); foreach (float[] point in this.Data) { if (random.NextDouble() > (SampleRatePercent / 100f) + .00001) { continue; } if (!DrillDownValid(GetPosition(point))) { continue; } GameObject arrow = Instantiate(arrowPrefab, transform); arrow.SetActive(false); arrow.GetComponentInChildren <MeshRenderer>().material.color = GetColor(point); arrow.transform.position = GetPosition(point); arrow.transform.localScale = GetScale(point); arrow.transform.rotation = GetRotation(point); arrowsList.AddLast(arrow); } PreviousArrows = arrowsList; GameObject[] arrows = new GameObject[arrowsList.Count]; arrowsList.CopyTo(arrows, 0); return(arrows); }
/// <summary> /// Generates the particles according to the current settings of the PlottableData object. /// Before calling this method, you may want to define what various fields of the given data /// mean by setting XSpatialFieldIndex, ColorFieldIndex, etc. /// </summary> /// <returns> /// An array of particles that may be passed to a particle system and displayed. Returns /// null if data has not been set. /// </returns> public ParticleSystem.Particle[] GetParticles() { if (Data == null) { return(null); } if (!IsColorLinearlyInterpolated && IsValidIndex(ColorFieldIndex)) { SetColumnRank(ColorFieldIndex); } if (!IsSizeLinearlyInterpolated && IsValidIndex(SizeFieldIndex)) { SetColumnRank(SizeFieldIndex); } LinkedList <ParticleSystem.Particle> particlesList = new LinkedList <ParticleSystem.Particle>(); System.Random random = new System.Random(80085); PositionGettingFunction GetPosition = GetPositionGettingFunction(); foreach (float[] point in this.Data) { if (random.NextDouble() > (SampleRatePercent / 100f) + .00001) { continue; } if (!DrillDownValid(GetPosition(point))) { continue; } ParticleSystem.Particle particle = new ParticleSystem.Particle { position = GetPosition(point), startColor = GetColor(point), startSize = GetSize(point) }; particlesList.AddLast(particle); } ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particlesList.Count]; particlesList.CopyTo(particles, 0); return(particles); }