unity 字幕滚动
生活随笔
收集整理的這篇文章主要介紹了
unity 字幕滚动
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class TextSpeed : MonoBehaviour
{private float speed = 100;public RectTransform maskRec;//text 父物體public RectTransform rec;//textfloat localX;float localY;float localZ;float txtWidth;// Start is called before the first frame updatevoid Start(){localY = transform.localPosition.y;localZ = transform.localPosition.z;//Debug.LogError(maskRec.rect.width);if (maskRec!=null)rec.anchoredPosition = new Vector2(maskRec.rect.width, 0);}// Update is called once per framevoid Update(){if (speed != 0){if (rec != null)txtWidth = rec.rect.width;if (rec.anchoredPosition.x < -txtWidth){rec.anchoredPosition = new Vector2(maskRec.rect.width, 0);}localX = transform.localPosition.x - speed * Time.deltaTime;transform.localPosition = new Vector3(localX, localY, localZ);}}
}
總結
以上是生活随笔為你收集整理的unity 字幕滚动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xmind可以画流程图吗_xmind8可
- 下一篇: 无线Mesh网络的优点总结