包含5節(jié)視頻教程
本系列包含Unity3D介紹、Unity3D導(dǎo)出人物、Unity3D導(dǎo)出場景、Unity3D導(dǎo)出動作、游戲測試最終完成一個簡單的游戲。是一套非常完整的Unity3D游戲制作教程。
|
The Transform Component determines the actual Position, Rotation, and Scale of all objects in the scene. Every object has a Transform. 變換組件決定了場景中所有物體的方位,旋轉(zhuǎn)和縮放。每個物體都有一個變換組件。
Properties 屬性
All properties of a Transform are measured relative to the Transform's parent. If the Transform has no parent, the properties are measured relative to World Space. 變換組件的所有屬性都是相對其父物體進(jìn)行衡量的,如果此物體沒有父物體,這些屬性則相對于世界坐標(biāo)進(jìn)行計算。 Using Transforms 使用變換組件Transforms are always manipulated in 3D space using X, Y, and Z axes. In Unity, these axes are represented by the colors red, green, and blue respectively. Remember: XYZ = RGB. 變換組件在三維空間中始終使用X,Y,Z軸進(jìn)行操作,在Unity中,這些坐標(biāo)軸分別被標(biāo)注為紅,綠,藍(lán)三種顏色,牢記:XYZ=RGB
Transform Components can be directly manipulated using the Scene View or the Inspector. The Inspector will list the properties stated above for easy editing. You can also modify Transforms in your Scene by interacting with them, using the Move, Rotate, and Scale tools. These tools are located in the upper left-hand corner of the Unity Editor. 變換組件可以在Scene視圖或監(jiān)視窗中即時的進(jìn)行操作,在監(jiān)視窗上會列出它的屬性并且可以簡單的進(jìn)行編輯,你也可以通過使用移動,旋轉(zhuǎn)和縮放工具來修改場景中物體的變換屬性,這些工具在Unity編輯器的坐上角位置可以找到。
The tools will be usable on any object in your scene. Click on the object, and you will see the tool gizmo appear around it. Depending on the current tool, the gizmo will look slightly different. Clicking the object will also cause the Transform component to become visible in the Inspector. If the Inspector does not display the Transform component or its properties, then you do not have an object highlighted in the Scene View. 這些工具可以用于你場景中的任何物體,在物體上單擊,你將會看到當(dāng)前選中的工具的線框顯示在物體周圍,這些線框看起來各不相同,點(diǎn)擊物體也會使變換組件的屬性顯示在監(jiān)視窗中,如果如果監(jiān)視窗中沒有顯示任何變換組件或?qū)傩,那么此時場景中沒有高亮的物體(沒有被選中的物體)。
這三種線框可以直接在Scene視圖中進(jìn)行操作。 To manipulate the Transform, click and drag on one of the 3 gizmo axes, you'll notice its color changes. As you drag the mouse, you will see the object translate, rotate, or scale along the axis. When you release the mouse button, you'll notice that the axis remains selected. You can click the middle mouse button and drag the mouse to manipulate the Transform along the selected axis. To access all 3 axes at once click and drag the center point of all 3 gizmos. 若想操作變換屬性,只需在三個線框坐標(biāo)軸上點(diǎn)擊并拖動,你會發(fā)現(xiàn)被點(diǎn)擊的軸顏色改變了,當(dāng)你用鼠標(biāo)拖動時,你會看到物體會沿著這些軸移動,旋轉(zhuǎn)或縮放。當(dāng)你釋放鼠標(biāo)按鍵時,你會發(fā)現(xiàn)坐標(biāo)軸仍處于選中狀態(tài),你可以點(diǎn)擊鼠標(biāo)中鍵并拖動來操作物體沿著選中坐標(biāo)軸的變換,如果想同時操作三個坐標(biāo)軸,那么就點(diǎn)擊并拖動三個坐標(biāo)軸線框的中點(diǎn)。
Parenting 父子化Parenting is one of the most important concepts to understand when using Unity. When a GameObject is a Parent of another GameObject, the Child GameObject will move, rotate, and scale exactly as its Parent does. Just like your arms are attached to your body, when you turn your body, your arms move because they're attached. Any object can have multiple children, but only one parent. 在Unity中父子化是一個非常重要的概念。當(dāng)一個游戲?qū)ο笫橇硪粋游戲?qū)ο蟮母肝矬w時,其子游戲?qū)ο髸S著它移動、旋轉(zhuǎn)和縮放,就像你的胳膊屬于你的身體,當(dāng)你旋轉(zhuǎn)身體時,你的胳膊也會跟著旋轉(zhuǎn)一樣。任何物體都可以有多個子物體,但只能有一個父物體。 You can create a Parent by dragging any GameObject in the Hierarchy View onto another. This will create a Parent-Child relationship between the two GameObjects. 你可以通過在層級視窗中把一個物體拖放到另一個物體之上來創(chuàng)建父物體,這將創(chuàng)建一個父子關(guān)系關(guān)聯(lián)這兩個游戲?qū)ο蟆?/p>
In the above example, we say that the arms are parented to the body, and the hands are parented to the arms. The scenes you make in Unity will contain collections of these Transform hierarchies. The topmost parent object is called the Root object. When you move, scale, or rotate a parent, all the changes in its Transform are applied to its children as well. 在上面的例子中,我們說胳膊的父物體是身體,手的父物體是胳膊,你在Unity中的場景會包含這些變換層級的集合,最外層的父物體對象被稱作根對象,當(dāng)你移動、縮放或旋轉(zhuǎn)一個父物體,所有的變換也會應(yīng)用于其子物體。 It is worth pointing out that the Transform values in the Inspector of any Child GameObject are displayed relative to the Parent's Transform values. These are also called the Local Coordinates. Through scripting, you can access the Global Coordinates as well as the Local Coordinates. 由此可見監(jiān)視窗中任意一個子物體所顯示的值都是相對于其父物體的,這也稱作局部坐標(biāo)系,通過編寫腳本,你可以像使用局部坐標(biāo)系一樣使用世界坐標(biāo)系。 You can build compound objects by parenting multiple separate objects together, like the skeletal structure of a human ragdoll. You can also create small yet effective objects with single parents. For example, if you have a horror game that takes place at night, you can create an effective atmosphere with a flashlight. To create this object, you would parent a spotlight Transform to the flashlight Transform. Then, any alteration of the flashlight Transform will affect the spotlight, creating a convincing flashlight effect. 你可以通過子化多個獨(dú)立的對象來建立符合對象,例如人體骨骼結(jié)構(gòu)玩偶,你也可以使用單層父物體來創(chuàng)建小而有效的對象,例如,你想做一個夜晚時分的恐怖游戲,你可以使用閃光燈來創(chuàng)造一個很好的氣氛,創(chuàng)建這個對象時,你可以用一個聚光燈作為閃光燈的子物體,然后任何對于閃光燈的改動都會影響到聚光燈,制作出一個逼真的閃光燈。 Importance of Scale 縮放的重點(diǎn)內(nèi)容The scale of the Transform determines the difference between the size of your mesh in your modeling application, and the size of your mesh in Unity. The mesh's size in Unity (and therefore the Transform's scale) is very important, especially during physics simulation. There are 3 factors that can determine the Scale of your object: 縮放變換決定了你的網(wǎng)格在建模應(yīng)用程序和Unity之間的尺寸差異,網(wǎng)格的尺寸(取決于變換縮放)在Unity中十分的重要,特別是在物理仿真時。我們有三個系數(shù)來控制物體的縮放:
Ideally, you should not adjust the Scale of your object in the Transform Component. The best option is to create your models at real-life scale, so you won't have to change your Transform's scale. The second-best option is to adjust the scale at which your mesh is imported in the Import Settings for your individual mesh. Certain optimizations occur based on the import size, and instantiating an object that has an adjusted scale value can decrease performance. For more information, read through the Rigidbody component's section on optimizing scale. 理論上,你可以無需調(diào)整物體變換組件中的縮放參數(shù),最好的選擇是在創(chuàng)建模型時使用顯示比例縮放,這樣你就可以不用調(diào)整變換縮放,第二種選擇是在導(dǎo)入設(shè)置中調(diào)整每個網(wǎng)格的縮放比例。某些優(yōu)化是基于導(dǎo)入尺寸的,假如一個對象進(jìn)行縮放調(diào)整時會降低一些性能。想要了解更多信息,閱讀剛體組件的最佳化縮放一節(jié)。 Hints 提示
贊0 踩0 |
未知用戶
2005-2024 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2024 ZhuFeng Community All Rights Reserved
VIP