29607人加入学习
(126人评价)
Unity API常用方法和类详细讲解(基于Unity5.6)
价格 免费
承诺服务
Cube.AddComponent<Rigibody>;

可以将代码中的物体赋予相应的脚本

[展开全文]

如何给游戏物体通过代码添加组件(通过代码添加)

关键字为:AddComponent

用法:实例名.AddComponent<组件名>;

GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		go.AddComponent<Rigidbody>();//可以为组件
		go.AddComponent<TimeCeShi>();//可以为自定义的脚本

 

[展开全文]

1、如何给游戏物体通过代码添加组件

通过AddComponent<>添加组件

给物体添加脚本

 

[展开全文]

如何给游戏物体通过代码添加组件

  AddComponet<>

GameObject.CreatePrimitive(PrimitiveType.Plane);

GameObject go=GameObject.CreatPrimitive(PrimitiveType.Cube);

go.AddComponent<Rigidbody>();给Cube添加刚体

go.AddComponent<API01EventFunction>();

给Cube添加

[展开全文]

给游戏物体,代码添加组件。

GameObject go = new GameObject();

go.addComponent<组件>;

[展开全文]

008-如何给游戏物体通过代码添加组件

  1. XXX.AddComponment<添加的组件名或脚本名>();

例如:

GameObject go=GameObject.CreatPrimitive(PrimitiveType.Cube);
go.AddComponent(Rigidbody);

 

[展开全文]

FlexdUpdate  每秒(60)就60次

OnTrigger  触发器

OnCollision  碰撞器

OnMouse XX  输入事件 鼠标操作有关的事件

Scene rendering  场景渲染有关的

Delteime  延迟事件

deltatime 每一帧的时间间隔

FrameCount 帧数

 

游戏运行一共占用时间【

time

timeSinceleveILoad

fixedTime】

【realtimeSinceStartup 暂停还会记时】

【timeScale  时间比例】

Vector3三位矢量

forward前进

 

构造方法

Instantiate   实例化

CreatePrimitive   创造基本元素

添加组件

AddComponent

[展开全文]

代码为游戏物体(GameObject) AddComponent

gameobject.AddComponent

[展开全文]

给物体添加组件:GameObject.addComponent<Rigidbody>();

[展开全文]

授课教师

SiKi学院老师

课程特色

图文(1)
下载资料(2)
视频(71)