当前位置:网站首页>【Unity入门计划】基本概念-GameObject&Components
【Unity入门计划】基本概念-GameObject&Components
2022-07-25 07:26:00 【flashinggg】
这篇文章仅仅是简单的介绍游戏对象和组件,之后学习了脚本回来完善更多的内容。
GameObject 游戏对象
- 游戏对象(GameObject)在unity中尤为重要,unity的编程语言C#是面向对象的
- 一个Scene相当于一个或多个游戏对象的容器,一个游戏对象又由不同组件(Component)组成,组件定义游戏对象的功能,因此一个游戏对象又相当于一个容器
Components 组件
在我们创建一个游戏世界时,往世界里添加物体就是添加一个GameObject,而给这些物体赋予灵魂,比如声音、脚本、网格(3D模型)、刚体、生命值等等,就是给这个GameObject添加组件了。
游戏对象和组件的关系
- 通过之前的学习已经可以发现了,游戏对象包含组件
- 新建的游戏对象只是一个拥有组件空间的原始对象,仅仅是一个空对象
- 一个游戏对象是类,而每个组件就是一个类函数
游戏对象的创建
- 在左侧的Hierarchy窗口右键可创建一个GameObject
- 还可以直接ctrl+shift+N快速创建一个空的游戏对象
组件的创建
之前的太空飞船的小游戏案例就已经涉及到了,在Inspector面板的Add Component即可添加各种组件。
变换组件 Transform Component
- 新建的任何一个游戏对象,初始的Inspector面板都会包含一个变换组件,这个组件是unity任何一个游戏对象都必须包含的组件,是最重要的组件之一
- 变换组件定义了Scene视图中游戏对象的位置、旋转和缩放

CamelCase驼峰式命名法
最后记录一个小tips——关于游戏对象的命名。
一般会用驼峰式命名法(Camel-Case),这是编程的一套命名惯例,是指混合使用大小写来构成变量和函数名称的方法,增强程序的可读性。这个方法的驼峰法还分为小驼峰和大驼峰法。
小驼峰法
除第一个单词外其他单词首字母大写,一般在变量的时候用到,例如:int myName
大驼峰法
把第一个单词的首字母也大写了,常用于类名、命名空间等,例如:class DateBase;可观察到,这里初始的游戏对象名称也是用的大驼峰法
边栏推荐
- Robot framework mobile terminal Automation Test ----- 01 environment installation
- Summary of differences between data submission type request payload and form data
- A domestic open source redis visualization tool that is super easy to use, with a high-value UI, which is really fragrant!!
- 华为无线设备配置WAPI-证书安全策略
- Summary of learning notes of deep learning application development (II)
- Boiling short drama Jianghu: nine of the ten production teams are shooting, with a head sharing fund of more than 30million, and users are addicted to paying routines
- How to use kotlin flow in Android projects
- QT learning diary 20 - aircraft war project
- Wechat applet wx.request interface
- [semidrive source code analysis] [drive bringup] 39 - touch panel touch screen debugging
猜你喜欢

Robot Framework移动端自动化测试----01环境安装

cesium简介

【云原生】原来2020.0.X版本开始的OpenFeign底层不再使用Ribbon了

深度学习训练和测试时出现问题:error: the following arguments are required: --dataroot,解决:训练文件的配置方法和测试文件的配置方法

9大最佳工程施工项目管理系统
![[cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x](/img/7e/1d27e3f1856ab8c6cbfc5221c717bb.png)
[cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x

Oracle19 adopts automatic memory management. The AWR report shows that the settings of SGA and PGA are too small?

Boiling short drama Jianghu: nine of the ten production teams are shooting, with a head sharing fund of more than 30million, and users are addicted to paying routines

Meta is in a deep quagmire: advertisers reduce spending and withdraw from the platform

NLP hotspots from ACL 2022 onsite experience
随机推荐
微信小程序wx.request接口
Wechat applet request requests to carry cookies to verify whether it has logged in
Tips - prevent system problems and file loss
What are runtimecompiler and runtimeonly
"Game illustrated book": a memoir dedicated to game players
RPC communication principle and project technology selection
Openatom xuprechain open source biweekly report | 2022.7.11-2022.7.22
scrapy定时爬虫的思路
北京内推 | 微软STCA招聘NLP/IR/DL方向研究型实习生(可远程)
Lidar construction map (overlay grid construction map)
【刷题笔记】搜索插入位置(二分法的活用)
深度学习训练和测试时出现问题:error: the following arguments are required: --dataroot,解决:训练文件的配置方法和测试文件的配置方法
冰冰学习笔记:类与对象(上)
Luo min's backwater battle in qudian
Pads export Gerber file
深度学习之快速实现数据集增强的方法
分布式爬虫中的增量爬虫
【PyTorch】最常见的view的作用
Robot framework mobile terminal Automation Test ----- 01 environment installation
New tea, start "fighting in groups"