public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Material barMaterial) { if (barRef == null) { return; } GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation); bar.transform.parent = ListOfGroups[zIndex].transform; //Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z); // Debug.Log("Yes I am calling -----"); Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0); bar.transform.localPosition = pos; bar.transform.localScale = bar.transform.localScale * graphScaleFactor; BarProperty barProperty = bar.GetComponent <BarProperty>(); SetBarProperties(barProperty); if (barMaterial != null) { barProperty.SetBarMat(barMaterial); } barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor); float yscale = (yValue - ymin) * scaleFactor; bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z); ListOfGroups[zIndex].ListOfBar.Add(bar); }
//Animation All Together public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor) { if (barRef == null) { return; } GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation); //bar.transform.parent = ListOfGroups[zIndex].transform; bar.transform.SetParent(ListOfGroups[zIndex].transform); //Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z); // Debug.Log("Yes I am calling -----"); Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0); bar.transform.localPosition = pos; bar.transform.localScale = bar.transform.localScale * graphScaleFactor; BarProperty barProperty = bar.GetComponent <BarProperty>(); SetBarProperties(barProperty); barProperty.SetBarColor(barColor); barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor); /*travando fator de escala da barra * if (float.IsInfinity(scaleFactor)) * { * scaleFactor = 1.5f; * } * if(Math.Round(scaleFactor,1) <= 0.33) * { * scaleFactor = 0.6f; * } */ float yscale = (yValue - ymin) * scaleFactor; //retornando NaN quando escala e infinita if (float.IsNaN(yscale)) { //Debug.Log("caiu no Is Nan"); scaleFactor = 1; ymin = int.Parse(yValue.ToString()) - 5; yscale = (yValue - ymin) * scaleFactor; } else if (scaleFactor > 9) { //scaleFactor = 1; ? //yscale = (yValue - ymin) * scaleFactor; } else if (yscale > 10) { // yscale = yscale / 2; ? } //Debug.Log("yValue " + yValue.ToString() + " ymin: " + ymin + " scalefactor: " + scaleFactor + " yscale: " + yscale); bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z); ///Acontecendo algo aqui em cima ListOfGroups[zIndex].ListOfBar.Add(bar); }