unity ui 概述_通过此概述了解Unity 2D和Platformer基础知识

unity ui 概述

If you're shopping around for a 2D game engine, you've undoubtedly come across Unity. Dipping your toe into Unity's editor can be overwhelming if you haven't had a good overview of where all of the tools live, particularly if it's also your first time using C# to write scripts.

如果您正在逛逛2D游戏引擎,那么您无疑会遇到Unity 。 如果您对所有工具的用途都没有很好的了解,那么将脚趾浸入Unity的编辑器中可能会感到不知所措,尤其是这也是您第一次使用C#编写脚本时。

In this article, I'll give you a tour of Unity's 2D features with an overview of what tools you'll need to create a platformer - or any kind of 2D game - and where to find them in the editor!

在本文中,我将向您介绍Unity的2D功能,并概述创建平台游戏或任何类型的2D游戏所需的工具以及在编辑器中的查找位置!

If you're considering Unity among other 2D game engines, take a look at this article for some options.

如果您正在考虑在其他2D游戏引擎中使用Unity,请查看本文中的一些选项。

And if you'd prefer a visual tour of Unity, check out this video instead (28 minute watch):

而且,如果您希望对Unity进行视觉浏览,请观看以下视频(观看28分钟):

In this overview, we'll be using the Warped City Unity Assets Pack by Ansimuz.

在此概述中,我们将使用AnsimuzWarped City Unity Assets Pack

总览 (Overview)

On first glance, Unity's editor will look familiar if you've used another "all-in-one" game engine, but if it's your initial entrée into game development, it might be overwhelming.  Moreover, if you don't already have some experience working in C#, I highly recommend doing some tutorials using Microsoft's .NET or similar.  Unity has a relatively steep learning curve, and if you can come to it with some basic proficiency with C#, you'll have an easier onboarding experience.

乍一看,如果您使用了另一个“多合一”游戏引擎,Unity的编辑器就会看起来很熟悉,但是如果您是初次进入游戏开发领域,那么它可能会令人不知所措。 此外,如果您还没有使用C#的经验,我强烈建议您使用Microsoft的.NET或类似版本进行一些教程。 Unity的学习曲线相对较陡,如果您对C#有一定的基本了解,那么您将获得更轻松的入门经验。

A lot of your time will be spent in the hierarchy (1), which allows you to keep track of all of your game objects in a given "scene," which is a specific portion of your game (like your "Start" menu or a particular game world in your platformer).  With it, you can nest objects under others, manage your cameras and canvasses, and navigate through all of the game objects you've created.

您的很多时间都花在了层次结构(1)上,这使您可以在给定的“场景”中跟踪所有游戏对象,“场景”是游戏的特定部分(例如“开始”菜单或平台游戏中的特定游戏世界)。 借助它,您可以将对象嵌套在其他对象之下,管理相机和画布,以及浏览所有已创建的游戏对象。

You'll want to keep organized in your project tab (2), which acts as a file system that you can structure as you see fit.  One best practice, for example, is to collect all of your assets in one folder, animations in another, scripts in yet another, and so forth.  You can also click over to the console tab if you've instructed Unity to log stuff under circumstances that you dictate.

您需要在项目选项卡(2)中保持井井有条,该选项卡充当文件系统,您可以根据需要进行构建。 例如,一种最佳实践是将所有资产收集在一个文件夹中,将动画收集在另一个文件夹中,将脚本收集在另一个文件夹中,依此类推。 如果已指示Unity在您指定的情况下记录内容,则也可以单击“控制台”选项卡。

When clicking on a game object, either in the hierarchy or project tab, you'll be greeted with more details in the inspector (3).  These details will depend on what kind of object you've clicked, and what you've attached to that game object.  If you've created an empty game object, for example, there won't be much there.  But if you've made a player character that has a a sprite attached, along with an animation controller, rigidbody2d to manage physics, collider2d to manage collisions, and a script to manage user input and interactivity, all of these will appear in the inspector for you to tinker with.

在层次结构或项目选项卡中单击游戏对象时,将在检查器中看到更多详细信息(3)。 这些详细信息将取决于您单击了哪种对象以及您对该游戏对象附加的对象。 例如,如果您创建了一个空的游戏对象,那里将没有太多。 但是,如果您制作了一个附加了精灵的播放器角色,一个动画控制器,用于管理物理的“刚体2d”,用于管理碰撞的“ collider2d”以及用于管理用户输入和交互性的脚本,则所有这些都将显示在检查器中,用于你去修补。

The rest of the real estate within the editor is taken up by the scene itself (4), which is where you'll build your game world, drop in objects and triggers, and go about your game designing.  You can click over to the game tab to see what your game actually looks like when played (and play it by hitting the "play" button), or check out the Asset Store from the safety of your Unity client.

编辑器中的其余空间由场景本身(4)占用,您可以在其中构建游戏世界,放置对象和触发器,并进行游戏设计。 您可以单击到游戏选项卡,以查看玩游戏时的实际外观(并通过单击“播放”按钮来玩游戏),或者从Unity客户端的安全性中签出Asset Store。

在哪里可以找到动画师之类的东西 (Where to Find Things Like the Animator)

If you've read any of my writing about game engines, you've heard me whinge about Unity's 2D support being shoehorned into a 3D environment, and about how difficult it can be to locate the tools you need to get your work done.

如果您读过我有关游戏引擎的任何文章 ,您就会听到我对Unity的2D支持陷入3D环境中以及如何找到完成工作所需的工具有多困难的抱怨。

Let's just say that some things are difficult to accomplish in Unity compared to other 2D game engines, but they're all still possible.  If you're attempting to access the animator, for example, you'll need to select the Window > Animation > Animator, which is different from the location of the animations that you'll painstakingly create and save in your project tab.

我们只能说,与其他2D游戏引擎相比,在Unity中有些事情很难完成,但它们仍然可以实现。 例如,如果尝试访问动画师,则需要选择“窗口”>“动画”>“动画师”,这您要精心创建并保存在项目选项卡中的动画的位置不同

Similarly, if you want to access Physics 2D settings, by all means, click on Edit > Project Settings, which are different from your personal preferences, located under Edit > Preferences.  And if you're looking to tinker with builds, you'll want to go to File > Build Settings.

同样,如果您想访问Physics 2D设置,请务必单击“编辑”>“项目设置”,该设置与您的个人首选项不同 ,位于“编辑”>“首选项”下。 而且,如果您想修改构建,则需要转到“文件”>“构建设置”。

Similarly, if you just want to create a plain ol' game object, head to GameObject > Create Empty (or 2D Object if you know what you're looking for).  If, conversely, you're trying to add a rigidbody to an existing game object, you'll need to go to Component > Physics 2D > Rigidbody 2D (or click "Add Component" in the inspector when you have the game object selected in the hierarchy).

同样,如果您只想创建一个普通的游戏对象,请转到“游戏对象”>“创建空对象”(如果知道要查找的内容,则为2D对象)。 相反,如果您想向现有游戏对象添加刚体,则需要转到“组件”>“物理2D”>“刚体2D”(或在检查器中选择“添加组件”时,在层次结构)。

I think it's clear by this point that finding the things that you'll need to get your work done can be complicated, nested as they are within different menus.  It doesn't help that some of the tools themselves, such as the animator, are clunky compared to their counterparts in other 2D game engines, but once you get a handle on how they work, you'll find them to be perfectly serviceable.

我认为到这一点很明显,找到完成工作所需的东西可能很复杂,因为它们位于不同的菜单中。 与其他2D游戏引擎中的某些工具相比,某些工具本身(例如动画器)笨拙,这无济于事,但是一旦掌握了它们的工作原理,便会发现它们可完美使用。

Visual Studio和C脚本 (Visual Studio and C Scripting)

Unity supports C# for writing scripts, and you can pair it with Visual Studio for a relatively painless integrated development environment.

Unity支持C#编写脚本,您可以将其与Visual Studio配对以实现相对轻松的集成开发环境。

Scripts are easily accessible through the editor, and you'll have to attach them to your game objects to make your game do pretty much anything.  One fun feature is to declare a public variable in a script - say, an integer called "jumpSpeed" - and then attach that script to a game object in the inspector.  You'll see that variable exposed in the Unity editor, and can change it on the fly while your game is running to see how your changes work in action.

脚本可以通过编辑器轻松访问,并且您必须将它们附加到游戏对象上,以使您的游戏几乎可以执行任何操作。 一个有趣的功能是在脚本中声明一个公共变量(例如,称为“ jumpSpeed”的整数),然后将该脚本附加到检查器中的游戏对象。 您将在Unity编辑器中看到该变量,并且可以在游戏运行时即时对其进行更改,以查看所做更改的作用。

预制件 (Prefabs)

Finally, Unity leverages the use of what they call "prefabs" to streamline your workflow.  In essence, a prefab is a type of reusable object that you've created so that you can drop it in your game world again and again without the need for repeat customization.

最后,Unity利用他们所谓的“预制件”来简化您的工作流程。 本质上,预制是您创建的一种可重复使用的对象,因此您可以一次又一次地将其放到游戏世界中,而无需重复自定义。

Let's say that you create a monster in your top-down 2D adventure game as an empty game object, then attach a sprite, rigidbody2d, collider2d, animations, and a controller script.  You can drag that monster into your project tab to make it a prefab, which allows you to use it again and again in your game world without having to go through the whole process every time.

假设您在自上而下的2D冒险游戏中创建了一个怪物作为空游戏对象,然后附加了一个精灵,僵尸2d,碰撞器2d,动画和控制器脚本。 您可以将该怪物拖到项目选项卡中以使其成为预制件,从而使您可以在游戏世界中一次又一次地使用它,而不必每次都经过整个过程。

Unity has several more features that support 2D game development, some of which I cover in the video above, and it would do to watch a few tutorials on specific aspects of the editor if you're considering using it for your next game.  I'd particularly recommend brushing up on C# before tackling the editor itself, as doing so will provide for a more gentle learning curve.

Unity还有更多支持2D游戏开发的功能,我在上面的视频中介绍了其中一些功能,如果您考虑将其用于下一款游戏,那么它将观看一些有关编辑器特定方面的教程。 我特别建议在处理编辑器本身之前先复习C#,因为这样做可以提供更平缓的学习曲线。

Hope this overview is helpful for your next game!

希望本概述对您的下一个游戏有所帮助!

If you enjoyed this article, please consider checking out my games and books, subscribing to my YouTube channel, or joining the Entromancy Discord.

如果您喜欢这篇文章,请考虑查看我的游戏和书籍订阅我的YouTube频道加入Entromancy Discord

M. S. Farzan, Ph.D. has written and worked for high-profile video game companies and editorial websites such as Electronic Arts, Perfect World Entertainment, Modus Games, and MMORPG.com, and has served as the Community Manager for games like Dungeons & Dragons Neverwinter and Mass Effect: Andromeda. He is the Creative Director and Lead Game Designer of Entromancy: A Cyberpunk Fantasy RPG and author of The Nightpath Trilogy. Find M. S. Farzan on Twitter @sominator.

法赞(MS Farzan)博士 他曾为知名的视频游戏公司和编辑网站(例如,Electronic Arts,Perfect World Entertainment,Modus Games和MMORPG.com)撰写和工作,并曾担任《龙与地下城:龙骨无双》和《 质量效应:仙女座》等游戏的社区经理。 。 他是《 Entronancy:Cyber​​punk Fantasy RPG》的创意总监和首席游戏设计师,并且是《 The Nightpath Trilogy》的作者。 在Twitter @sominator上找到MS Farzan

翻译自: https://www.freecodecamp.org/news/take-a-tour-of-unity-2d/

unity ui 概述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值