您的位置:首页 > 移动开发 > Unity3D

unity总结1

2016-05-26 20:27 411 查看

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);

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: