public void ResetPosition() { for (int i = 0, imax = transform.childCount; i < imax; ++i) { Transform t = transform.GetChild(i); Vector3 pos = t.localPosition; float depth = pos.z; float time = (1.0f / imax) * i + m_CurValue; if (time >= 1) { time = time - 1; } float value = AnimationCurve.Evaluate(time); float verValue = VerAnimationCurve.Evaluate(time); pos = new Vector3(value * HorRadius, verValue * VerRadius, depth); t.localPosition = pos; //Debug.Log(pos + " Name>>" + t.name + " time>>" + time + " m_CurValue>>" + m_CurValue); if (Application.isPlaying) { RegGridCell cell = t.gameObject.GetComponent <RegGridCell>(); if (cell != null) { //float lastValue = cell.Value; cell.Value = (float)System.Math.Round(time, 2); onCenter?.Invoke(cell, cell.Value == 0); } } } }
protected void Init() { int maxCount = transform.childCount; Interval = 1.0f / maxCount; for (int i = 0; i < maxCount; i++) { var t = transform.GetChild(i); RegGridCell cell = t.gameObject.GetComponent <RegGridCell>(); if (cell == null) { cell = t.gameObject.AddComponent <RegGridCell>(); } cell.SetData(Interval * i, this); } }