unity总结1_skybeauty_新浪博客

Camera mainCamera = GameObject.Find("Main Camera").GetComponent();
Camera uiCamera = GameObject.Find("UICamera").GetComponent();
Vector3 startPos = mainCamera.WorldToScreenPoint(startTarget.transform.position);//先转换到屏幕坐标
Vector3 endPos = endTarget.transform.position;
startPos = uiCamera.ScreenToWorldPoint(startPos);//再转换到对象所在的Camera坐标系
target.transform.position = startPos;
Sequence seq = DOTween.Sequence();
seq.Append(target.transform.DoMove(endPos,1f,false));
seq.SetAutoKill(false);
seq.Play();



Animator animator = this.GetComponent();
RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController;
AnimationClip[] clips = runtimeAnimatorController.animationClips;
AnimationClip clip = null;
if (clips.Length > 0)
{
    for (int i = 0; i < clips.Length; i++)
    {
        AnimationClip temp = clips[i];
        AnimationEvent aniEvent = new AnimationEvent();
        aniEvent.time = clip.length;
        aniEvent.functionName = "ActionEnd";
        clip.AddEvent(aniEvent);
       
    }
}


GameObject obj = new GameObject();
Text testLab = obj.AddComponent();
testLab.font = Font.CreateDynamicFontFromOSFont("Arial",22);
testLab.text = "hello world";
testLab.fontStyle = FontStyle.BoldAndItalic;
testLab.fontSize = 35;
obj.layer = this.gameObject.layer;
obj.transform.SetParent(this.transform,false);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值