start() {
/*
//访问位置
this.node.x
this.node.y
//设置位置
this.node.setPosition(1,2)
this.node.setPosition(v2(1,2))
//旋转
this.node.rotate
//缩放
this.node.scale
//颜色
this.node.color = Color.RED
*/
//节点开关
this.node.active = true
//组件开关
this.enabled = true
//获取组件
let sprite = this.getComponent(MeshRenderer)
sprite.enabled = true
//在子物体获取组件
this.getComponentInChildren(MeshRenderer)
//创建节点
let nnt = new Node("xx")
//添加组件
nnt.addComponent(Sprite)
}
该文详细介绍了在Unity3D中对节点的操作,包括获取和设置位置(x,y坐标及Vector2)、旋转、缩放以及颜色设置。此外,还涉及节点的启用与禁用、组件的管理,如开启关闭组件、获取特定组件(如MeshRenderer),以及在子物体中查找组件。最后,文章演示了如何创建新节点和向节点添加组件的过程。
976





