欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

untiy实现文本滚动

发布时间:2024/1/8 编程问答 54 豆豆
生活随笔 收集整理的这篇文章主要介绍了 untiy实现文本滚动 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

关键代码(初学)

if (Isplayers){if (speed != 0 && anxia == false){//将文本框的自适应高度 赋值给 txtheighttxtheight = rec.rect.height;//播放完毕,则初始化文本位置 if (rec.anchoredPosition.y > txtheight / 2 + maskRec.rect.height / 2){rec.anchoredPosition = new Vector2(0, -rec.rect.height / 2 - maskRec.rect.height / 2);}//文本随时间滚动播放localY = transform.localPosition.y + speed * Time.deltaTime;transform.localPosition = new Vector3(localX, localY, localZ);if (rec.anchoredPosition.y < -(rec.rect.height / 2 + (maskRec.rect.height / 2))){rec.anchoredPosition = new Vector2(0, -rec.rect.height / 2 - maskRec.rect.height / 2);}}

总结

以上是生活随笔为你收集整理的untiy实现文本滚动的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。