unity---克隆/贴图/平移/旋转

克隆#

GameObject clone =Instantiate(gameObject,new Vector3(10,10,10),Quaternion.identity);

Destroy(clone,5);//5秒后自动销毁

image
image

添加图片#

public Texture tex;//存储图片
Renderer ren;
ren =gameObject.GetComponent<Renderer>();
ren.material=null;
ren.material.mainTexture=tex;

image

平移#

    if(Input.GetKey(KeyCode.RightArrow))this.gameObject.transform.Translate(new Vector3(0f,0f,Time.deltaTime*10));
    else if(Input.GetKey(KeyCode.LeftArrow))this.gameObject.transform.Translate(new Vector3(0f,0f,-Time.deltaTime*10));
    else if(Input.GetKey(KeyCode.UpArrow))this.gameObject.transform.Translate(new Vector3(Time.deltaTime*10,0f,0f));
    else if(Input.GetKey(KeyCode.DownArrow))this.gameObject.transform.Translate(new Vector3(-Time.deltaTime*10,0f,0f));

旋转#

obj.transform.Rotate(0f,Time.deltaTime*50,0f);
posted @   lxp_blog  阅读(270)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示
主题色彩