unity开发⼊门_Unity游戏开发终极⼊门指南
unity开发⼊门
Unity is a great tool for prototyping everything from games, to interactive visualisations. In this article, we run through all you need to know to get started using Unity.
Unity是⼀个很好的⼯具,可⽤于制作从游戏到交互式可视化等所有内容的原型。 在本⽂中,我们遍历了开始使⽤Unity所需的所有知识。
First, a little bit about me: I’m a hobbyist unity developer, 3d modeler and graphic designer who’s worked with Unity and Blender for over 5 years. I’m now a Financial Maths student at University College Dublin, and occasionally I do freelance graphic design, web prototyping, and game prototyping.
⾸先,关于我的⼀些知识:我是⼀个业余爱好者统⼀开发⼈员,3d建模者和图形设计师,与Unity和Blender共同⼯作了5年以上。 我现在是都柏林⼤学⾦融⾦融专业的学⽣,偶尔我从事⾃由图形设计,⽹络原型制作和游戏原型制作。
介绍 (Introduction)
This article is aimed at anyone who has never used Unity before, but has some previous experience programming or in web design / development. By the end of this article, you should have a good general overview of the engine as well as all the necessary functions and code to start making a basic game.
本⽂针对的对象是从未使⽤过Unity的⼈,但是具有⼀定的编程或Web设计/开发经验。 到本⽂结尾,您应该对引擎以及开始制作基本游戏的所有必要功能和代码有⼀个良好的总体了解。
为什么选择Unity? (Why Unity?)
如果你想做游戏 (If you want to make games)
There’s really very few options when it comes to Indie Game development. The three main choices if you want to build games are Unreal, Unity or GameMaker.
关于独⽴游戏开发,实际上只有很少的选择。 如果要构建游戏,三个主要选择是虚幻,Unity或GameMaker。
Unity is probably the least opinionated of the 3 platforms. It gives you a very raw product out of the box, but is highly flexible, well-documented, and highly extensible to build pretty much any genre of g
ame you can think of.
在这3个平台中,Unity的观点最少。 它为您提供了⾮常原始的产品,但具有⾼度的灵活性,良好的⽂档记录和⾼度可扩展性,可以构建您可以想到的⼏乎所有类型的游戏。
There are plenty of highly successful games such as Escape from Tarkov (FPS), Monument Valley (Puzzler), and This War of Mine (Strategy / Survival) all built in Unity.
有很多⾮常成功的游戏,例如Unity中内置的《逃离塔尔科夫(FPS)》,《纪念碑⾕》(Puzzler)和《矿⼭之战》(策略/⽣存)。
In reality the engine you build your first game on is probably not critical, so my advice is just to pick one and go with it.
工程机械专业实际上,您构建第⼀个游戏的引擎可能并不关键,所以我的建议是选择⼀个并继续使⽤。
客户如果您想原型化⽤户体验 (If you want to prototype user experiences)
Since unity is just an engine with a bunch of physics, animation, and real time 3d rendering, it’s also a great space to make fully fledged interactive prototypes for UX studies.
由于unity只是具有⼤量物理,动画和实时3d渲染的引擎,因此它也是为UX研究制作成熟的交互式原型的理想空间。
Unity has full support for VR and AR and hence could be a great tool for exploring architecture, automations and simulations with clients.
Unity全⾯⽀持VR和AR,因此可以成为与客户⼀起探索架构,⾃动化和仿真的绝佳⼯具。
本⽂各节 (Sections to this article)
Why Unity?演讲稿六年级
为什么选择Unity?
Unity Editor Window
Unity编辑器窗⼝
Unity Game Objects
Unity游戏对象
Unity Builtin Components
Unity内置组件
Creating Custom Components
创建⾃定义组件
Structure of a MonoBehaviour
MonoBehaviour的结构
感应洁具Manipulating GameObjects
操纵游戏对象
Raycasting
射线⼴播
Collision detection
碰撞检测
Advanced Features
⾼级功能鱼片的切法
Advice For Newcomers
给新⼈的建议
Nice Resources and Communities
不错的资源和社区
Conclusion
结论
Unity编辑器窗⼝ (Unity editor window)
The editor window is split up into a couple of sections. We will cover this very briefly as we will refer to it constantly throughout the article. If your familiar with this already just skip past!
编辑器窗⼝分为⼏个部分。 我们将在本⽂中简短地介绍这⼀点,因为我们会不断对其进⾏引⽤。 如果您对此已经熟悉,请跳过过去!
Scene View: Allows placement and movement of GameObjects in the Scene
场景视图:允许在场景中放置和移动游戏对象
Game View: Previews how the player will see the scene from the camera
游戏视图:预览玩家如何从摄像机看到场景
Inspector: Provide details on the selected GameObject in the scene.
检查器:提供有关场景中所选GameObject的详细信息。
Assets / Project: All prefabs, textures, models, scripts etc are stored here
资产/项⽬:所有预制件,纹理,模型,脚本等都存储在此处
Hierarchy: Enables nesting and structuring of GameObjects within the scene
层次结构:启⽤场景内GameObject的嵌套和结构化
Now we’re good to start!
现在我们开始吧!
Unity游戏对象 (Unity Game Objects)
什么是游戏对象 (What are GameObjects)
GameObjects are the core building block of everything in the Unity games engine. The name almost gives it away:
GameObjects是Unity游戏引擎中所有内容的核⼼构建块。 这个名字⼏乎给了它:
Anything you place within a scene in Unity must be wrapped in a ‘game object.’
您在Unity场景中放置的所有内容都必须包裹在“游戏对象”中。
If you’ve got a web design background, you can think of GameObjects as being a lot like <div> elements! Extremely boring containers, but are highly extensible to create complex functionality or visuals.
如果您具有⽹页设计背景,则可以认为GameObjects与<div>元素⾮常相似! 容器⾮常⽆聊,但是可以⾼度扩展以创建复杂的功能或视觉效果。
Literally everything from particle effects, cameras, players, UI elements, … (the list goes on) is a GameObject.
从字⾯上看,包括粒⼦效果,相机,播放器,UI元素……(列表不胜枚举)的所有东西都是GameObject。
创建层次结构 (Creating Hierarchy)
Like a <div> in web development, a GameObject is also a container. Just as you nest <div>s to create varied and desirable layouts or abstractions you may wish to do the same with games objects.
就像Web开发中的<div>⼀样,GameObject也是⼀个容器。 正如您嵌套<div>来创建各种所需的布局或抽象⼀样,您可能希望对游戏对象也是如此。
The logic behind nesting game objects is much the same as web development, I’ll give a few examples…
苹果接电话怎么录音
嵌套游戏对象的逻辑与⽹络开发基本相同,我将举⼏个例⼦……
Clutter & Efficiency
混乱与效率
Web Analogy: You’ve got many similar elements which may be dynamically generated on the fly in response to user interaction and want to keep them tidy.
⽹络类⽐:您有许多类似的元素,它们可能会动态⽣成以响应⽤户交互,并希望保持它们整洁。
Unity Translation: Your building a Minecraft clone and you’ve loads of blocks in the scene, you need to add and remove ‘chunks’ of blocks from the scene for performance reasons. Thus having them parented to an empty GameObject for each chunk makes sense, as deleting the chunk parent removes all the children blocks.
Unity Translation:构建Minecraft克隆并且场景中有⼤量块,出于性能原因,您需要从场景中添加和删除块的“块”。因此,让它们为每个块添加⼀个空的GameObject作为⽗项是有意义的,因为删除⽗块会删除所有⼦块。
Positioning
定位
Web Analogy: You want to keep the position of the content contained ‘relative’ to the container and not to the web page.
⽹络类⽐:您想保持包含的内容相对于容器⽽不是⽹页的位置。
Unity Translation: You’ve created a bunch of helper drones which hover around the player. You would really not rather write code to tell them to chase after the player, so instead you instantiate them as children of the player game object.
Unity Translation:您已经创建了⼀辅助玩家,它们徘徊在玩家周围。您实际上并不想编写代码来告诉他们追随玩家,⽽是将它们实例化为玩家游戏对象的⼦代。
Unity内置组件 (Unity Builtin Components)
演员组件模型 (The Actor Component Model)
GameObjects on their own are pretty useless — as we’ve seen they’re pretty much just containers. In order to add functionality to them we have to add components, which are essentially scripts written in either C# or Javascript.
单独的GameObjects毫⽆⽤处-正如我们已经看到的,它们⼏乎只是容器。 为了向它们添加功能,我们必须添加组件,这些组件本质上是⽤C#或Javascript编写的脚本。
Unity works off an Actor Component model, put simply the GameObjects are the actors and the Components are your scripts.
Unity采⽤Actor Component模型,简单地说GameObjects是actor,⽽Components是您的脚本。
If you’ve written any web apps before you’ll be familiar with the idea of creating small reusable components such as buttons, form elements, flexible layouts that have various different directives and customisable properties. Then assembling these small components into larger web pages.
如果您已经编写了任何Web应⽤程序,那么您将熟悉创建⼩型可重⽤组件(例如按钮,表单元素,具有各种不同指令和可⾃定义属性的灵活布局)的想法。 然后将这些⼩的组件组装成较⼤的⽹页。
The big advantage of this approach is the level of reusability and clearly defined communication channels between elements. Likewise in game development, we want to minimise the risk of unintended side effects. Small bugs tend to spiral out of control if you’re not careful, and are extremely difficult to debug. Thus creating small, robust and reusable components is critical.
这种⽅法的最⼤优势是可重⽤性级别以及元素之间明确定义的通信渠道。 同样,在游戏开发中,我们希望将意外副作⽤的风险降⾄最低。如果您不⼩⼼,⼩错误往往会失控,并且极难调试。 因此,创建⼩型,坚固且可重复使⽤的组件⾄关重要。
关键的内置组件 (Key Built-in Components)
I think it’s time for a few examples of the built in components provided by the Unity Games engine.
我想是时候来看看Unity Games引擎提供的内置组件的⼀些⽰例了。
MeshFilter: Allows you to assign materials to a 3D mesh to a GameObject
MeshFilter:允许您将材质分配给3D⽹格,然后分配给GameObject
MeshRender: Allows you to assign materials to a 3D Mesh
MeshRender:允许您将材质分配给3D⽹格
[Box | Mesh]Collider: Enables detection of GameObject during collisions
[箱| Mesh] Collider:可在碰撞期间检测GameObject
Rigidbody: Enables realistic physic simulation to act on GameObjects with 3d Meshes and will be trigger detection events on box colliders
刚体:使逼真的物理模拟能够对具有3d⽹格的GameObject起作⽤,并将触发盒对撞机上的检测事件
Light: Illuminates portions of your scene
光线:照亮场景的⼀部分
Camera: Defines the player viewport to be attached to a GameObject
摄影机:定义要附加到GameObject的玩家视⼝
Various UI Canvas Components for displaying GUIs
⽤于显⽰GUI的各种UI画布组件
There are loads more, but these are the main ones you’ll need to get familiar with. One tip is that you can access all the docs for these through the unity manual and scripting reference offline wherever you are:
还有更多的负载,但是这些是您需要熟悉的主要负载。 ⼀个提⽰是,⽆论您⾝在何处,都可以通过统⼀⼿册和脚本参考脱机访问这些⽂档的所有⽂档:
创建⾃定义组件 (Creating Custom Components)
The builtin components control physics and visuals primarily, but to really make a game, you’re going to need to accept user input and manipulate those standard components as well as the GameObjects themselves.
内置组件主要控制物理和视觉效果,但是要真正制作游戏,您将需要接受⽤户输⼊并操纵这些标准组件以及GameObjects本⾝。
To start creating components, go into the desired GameObject > Add Component > type the name of your new
component in the search bar > new script (c#).
要开始创建组件,请进⼊所需的GameObject>添加组件>在搜索栏中>新脚本(c#)输⼊新组件的名称。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论