unity 创建游戏对象_Unity:在运行时使用Prefabs创建游戏对象

unity 创建游戏对象

Now that you have understood some of the basics of working with Unity, and have made a game or two by yourself, let's try and dig in deeper, shall we? After all, we have just scraped the surface of the iceberg that is Unity!

现在您已经了解了使用Unity的一些基础知识,并且自己编写了一个或两个游戏,让我们尝试更深入地研究,对吧? 毕竟,我们只是刮掉了团结的冰山表面!

First of all, it's time to say goodbye to Mr. Star. He's been a good friend of ours for the journey up until now, but for what we have ahead, we need something a bit more complex, and a star drawn hastily in Paint.NET in mere 13 seconds doesn't really fit that description.

首先,是时候向斯塔先生说再见了。 到目前为止,他一直是我们的好朋友,但是对于我们要取得的成就,我们需要更复杂的东西,而在Paint.NET中匆匆绘制的一颗星星在短短的13秒之内并不符合该描述。

So what does fit that description? This, I guess...

那么,什么符合该描述呢? 我猜这...

A cartoon boy Game Object for Unity

Now, we'll be understanding more fundamental concepts related to Unity, more focused on gameObjects and prefabs.

现在,我们将了解与团结更多的基本概念,更侧重于gameObjects预制件

了解预制件和实例化 (Understanding Prefabs and Instantiation)

Okay, so the word Prefab looks a bit scary, doesn't it? Don't worry, it's not, in fact, it's one of game designer's best friends when it comes to creating gameObjects in real-time. So what exactly is a prefab? Well, a prefab is actually a blueprint or a template for a specific gameObject. We know this is kind of confusing to understand at first, so let's take a very basic example.

好的, Prefab这个词看起来有点吓人,不是吗? 不用担心,在实时创建gameObjects时,它并不是游戏设计师最好的朋友之一。 那么什么是预制件呢? 好吧,预制件实际上是特定游戏对象的蓝图或模板。 首先,我们知道这有点令人困惑,所以让我们举一个非常基本的例子。

Imagine we are making a basic space shooter game, and this here, little fellow, is an enemy character.

想象我们正在制作一个基本的太空射击游戏,而这里的小家伙是个敌人。

Enemy cartoon Game Object

Now, if we wanted to build a game scene in Unity with our main character, and an enemy, it would look something like this:

现在,如果我们想在Unity中以我们的主要角色和一个敌人来构建游戏场景,它将看起来像这样:

setup for space shooting game in unity

Sure, this is perfectly fine for when you have one enemy, but what if you wanted a lot of them? Not 2 or 3, assume like 15 or 20. As a beginner learning Unity, you might be thinking something along these lines: Using the same asset, multiple times by creating copies.

当然,当您有一个敌人时,这是完全可以的,但是如果您想要很多敌人怎么办? 假设不是2还是3,则假设是15或20。假设您是

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值