void init() { StartPos = Vector3.zero; EndPos = Vector3.up * 10; Vector3 diffvector = EndPos - StartPos; Vector3 diff = diffvector / MaxNodeNum; StripLength = diffvector.magnitude; //Debug.Log(StripLength); Vector3 lastpos = StartPos; nodes = new List <StripNode>(); float l = (EndPos - StartPos).magnitude; float diffl = l / (float)(MaxNodeNum - 1); for (int i = 0; i < MaxNodeNum; i++)//分10段,有11个节点 { StripNode tempnode = new StripNode(); tempnode.gameObject = StripUtils.CreatStripNode(i.ToString()); tempnode.Pos = lastpos; lastpos += diff; tempnode.Width = StripUtils.GetWidth(i * diffl, l); nodes.Add(tempnode); } }
// Update is called once per frame IEnumerator myUpdate() { while (x < 1.1f) { this.transform.position = mylerp(Vector3.zero, tarpos, StripUtils.getInterpolation(x)); Debug.Log(x); Debug.Log(StripUtils.getInterpolation(x)); x += 0.01f; yield return(new WaitForSeconds(1)); } }
private IEnumerator BackToOrigin() { float curtime = 0.0f; float springinput = 0.0f; Vector3 tmpPos = this.pos; //while (Vector3.Distance(this.oriPos,this.pos) >= backDelta) while (springinput < 1 && curtime < coroutineBreakTime) { curtime += Time.deltaTime; float w = StripUtils.getInterpolation(springinput); this.Pos = StripUtils.mylerp(tmpPos, this.oriPos, w); springinput += 0.009f; yield return(new WaitForEndOfFrame()); } this.pos = this.oriPos; }