朱峰社區(qū)首頁 朱峰社區(qū)

搜索資源 注冊|登陸

等待

返回 展開菜單
按功能 按軟件

unity3d視頻教程

unity3d視頻教程

包含11節(jié)視頻教程

從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。

關(guān)閉

Unity組件:GameObject 游戲?qū)ο?/h1>

關(guān)注:1885 留言:0 樓主:溪水流長 發(fā)帖時間:15年11月16日

溪水流長

普通會員

溪水流長

社區(qū)新人:1級

關(guān)注2468人

  • 性別

  • 年齡

    21

  • 積分

    1

  • 登陸

    1

  • 發(fā)帖

    1

  • 作品

    1

間隔線

GameObjects are containers for all other Components. All objects in your game are inherently GameObjects.

游戲?qū)ο笫撬衅渌M件的容器。在你的游戲中的所有物體都是游戲?qū)ο蟆?/p>

一個空的游戲?qū)ο? src=

An empty GameObject 一個空的游戲?qū)ο?/p>

Creating GameObjects 創(chuàng)建游戲?qū)ο?/h6>

GameObjects do not add any characteristics to the game by themselves. Rather, they are containers that hold Components, which implement actual functionality. For example, a Light is a Component which is attached to a GameObject.

游戲?qū)ο蟊惶砑拥接螒蛑袝r本身并不包含任何特性(特征,屬性..)。當(dāng)然,它們包含有已經(jīng)被實現(xiàn)的控制組件。例如,一個燈光(Light)就是一個添加到游戲?qū)ο蟮慕M件。

If you want to create a Component from script, you should create and empty GameObject and then add required Component using gameObject.AddComponent(ClassName) function. You can't create Component and then make a reference from object to it.

如果你想使用腳本創(chuàng)建一個組件,你需要創(chuàng)建一個空的游戲?qū)ο笕缓笫褂胓ameObject.AddComponent(ClassName)方法(函數(shù))。你不可以創(chuàng)建一個組件然后通過引用賦予物體。

From scripts, Components can easily communicate with each other through message sending or the GetComponent(TypeName) function. This allows you to write small, reusable scripts that can be attached to multiple GameObjects and reused for different purposes.

使用腳本,組件間可以輕易的通過發(fā)送消息或者使用GetComponent(TypeName)方法相互溝通。

Details 細(xì)節(jié)

Aside from being a container for the components, GameObjects have a Tag, a Layer and a Name.

游戲?qū)ο蟪吮划?dāng)做各個組件的容器外,它還擁有Tag(標(biāo)簽),Layer(層)和Name(名稱)屬性。

Tags are used to quickly find objects, utilizing the Tag name. Layers can be used to cast rays, render, or apply lighting to certain groups of objects only. Tags and Layers can be set with the Tag Manager, found in Edit->Project Settings->Tags.

Tag(標(biāo)簽)用途在于使用標(biāo)簽名來快速尋找物體,層可以用于投射射線,渲染或者對特定的一組物體單獨應(yīng)用光照。標(biāo)簽和層可以通過Tag Manager(標(biāo)簽管理器)進(jìn)行設(shè)置,此選項可以通過 Edit->Project Settings->Tags找到。

Static Checkbox 靜態(tài)復(fù)選框

In Unity, there is a new checkbox in the GameObject called Static. This checkbox is used for:

在Unity中,游戲?qū)ο笥辛艘粋新的選擇框"Static",這個選項的用途在于:

  • preparing static geometry for automatic batching
    為自動烘焙準(zhǔn)備靜態(tài)的幾何體
  • calculating Occlusion Culling
    計算遮擋剔除

calculating Occlusion Culling 計算遮擋剔除

The Static checkbox is used when generating Occlusion data
當(dāng)產(chǎn)生遮擋數(shù)據(jù)時,使用static選項

When generating Occlusion data, marking a GameObject as Static will enable it to cull (or disable) mesh objects that cannot be seen behind the Static object. Therefore, any environmental objects that are not going to be moving around in your scene should be marked as Static.

當(dāng)產(chǎn)生閉塞數(shù)據(jù)時,設(shè)置游戲?qū)ο鬄镾tatic將會剔除(或禁用)網(wǎng)格對象當(dāng)這些部分被靜態(tài)物體擋住而不可見時。因此,在你的場景中的所有不會動的物體都應(yīng)該標(biāo)記為Static。

For more information about how Occlusion Culling works in Unity please read the Occlusion Culling page.

如果想知道更多關(guān)于Unity中Occlusion Culling的信息請參閱 Occlusion Culling頁面。

Hints 提示
  • For more information see the GameObject scripting reference page.
    查看"游戲?qū)ο竽_本參考頁"獲取更多信息
  • More information about how to use layers can be found here.
    更多關(guān)于層的信息可以在"這里"找到
  • More information about how to use tags can be found here.
    更多關(guān)于如何使用標(biāo)簽的信息可以在"這里"找到

贊0 踩0

未知用戶

2005-2024 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2024 ZhuFeng Community All Rights Reserved

VIP

朱峰社區(qū)微信公眾號

回頂部

1.復(fù)制文本發(fā)給您的QQ好友或群、微信等;好友點擊鏈接以后,轉(zhuǎn)發(fā)就成功了。 2.如朋友點擊您的鏈接,您需要需刷新一下才行;同一個好友僅能點擊一次。
購買VIP,觀看所有收費教程。