zoukankan      html  css  js  c++  java
  • UGUI Text文字左右循环运动

    using UnityEngine;
    using System.Collections;
    
    public class MoveTarget : MonoBehaviour
    {
        public GameObject _target1;//左侧目标位置
        public GameObject _target2;//右侧目标位置
        bool _check = true;
        bool _check2 = true;
        void Start()
        {
            StartCoroutine(IE_MoveToLeft());
        }
    
        IEnumerator IE_MoveToLeft()
        {
            while (_check)
            {
                transform.localPosition=Vector2.MoveTowards(transform.localPosition,_target1.transform.localPosition,Time.deltaTime*50f);
               // transform.Translate(Vector3.left, Space.Self);
                if (Mathf.Abs(_target1.transform.localPosition.x - transform.localPosition.x) < 0.2f)
                {
                    _check = false;
                    _check2 = true;
                    StartCoroutine(IE_MoveToRight());
                }
                yield return null;
            }
        }
    
        IEnumerator IE_MoveToRight()
        {
            while (_check2)
            {
                transform.localPosition = Vector2.MoveTowards(transform.localPosition, _target2.transform.localPosition, Time.deltaTime * 50f);
                // transform.Translate(Vector3.left, Space.Self);
                if (Mathf.Abs(_target2.transform.localPosition.x - transform.localPosition.x) < 0.2f)
                {
                    _check2 = false;
                    _check = true;
                    StartCoroutine(IE_MoveToLeft());
                }
                yield return null;
            }
        }
    }
  • 相关阅读:
    HPA
    docker 入门
    idea手动保存文本
    mac下安装配置sql plus
    oracle序列
    oracle存储过程
    Java正则表达式
    expect命令
    关于OneDrive/GoogleDrive推送的定价方案征询
    存储设备故障已修复,及对用户的补偿措施
  • 原文地址:https://www.cnblogs.com/Cocomo/p/7196163.html
Copyright © 2011-2022 走看看