字幕列表 影片播放
The Inspector panel in Unity
檢視(Inspector)的主要功能用來 調整物件, 資源和編輯偏好設定
is a panel for adjusting
以物件來說, 檢視裡會有標題欄位
settings for any object,
一個可以設定物件為靜態的勾選框
asset and editor preference.
靜態物件才會被光照貼圖(Lightmapping) 和導航網格(Navigation Mesh)納入運算
For objects, the inspector begins with a title,
再來是標籤(Tag)和圖層(Layer)下拉選單
a check box for you to check if the
標籤允許對單一或多個物件貼標籤 以方便在程式裡呼叫與應用
state of the object will remain static in the game.
而圖層允許你將物件群組化 並規範像是光源或碰撞的規則
This means it's a valid candidate for
在這些屬性底下 是依附在物件上的各種元件
light mapping and navigation mesh baking.
第一個是Transform
And then the tag and layer drop-downs.
物件預設的座標, 旋轉和縮放比例
Tags allow you to assign a tag to
檢視裡的元件可以利用不同方式來調整其欄位
one or many objects in order to address them via code.
你可以在數值上拖曳來進行變動
Whilst layers allow you to group objects
也可以點擊後輸入數值
and apply certain rules to these layers
或是利用右邊的齒輪選項來重置數值
such as lighting or collision rules.
除此之外,在齒輪的左方 有一個藍色書本的按鈕
After these elements the inspector then lists
你可以點選書本 來開啟元件的說明文件
the components attached to an object.
檢視內容會即時顯示選取的資訊
Beginning with the transform,
代表在調整任何資源時 你可以很快速的找到資源並調整
the default position, rotation and scale
由於Unity可以用拖放來設定數值 有時會不小心點到不相干的資源
of your object.
會被切換不相干資源的檢視 而不是你想要檢視的內容
On any component the inspector allows
因此你可以將目前的檢視鎖定 然後完成設定之後再把檢視解鎖
you to adjust fields in various ways.
舉例來說,我要為遊戲的 物件腳本元件指定群組貼圖
You can drag over the values,
但當我點選了第一個貼圖時 我希望檢視的內容停留在遊戲物件
you can click and retype,
而不要切換到材質設定
or your can choose to reset the values using
我可以按住滑鼠左鍵並將貼圖拖過去
the cog icon to the right of the component.
或者可以先點選遊戲物件 然後點選檢視上方的鎖定圖示
In addition to the cog there is also a link
接下來不管我怎麼點選貼圖 檢視裡的內容也不會進行切換
to the reference material on the component
完成之後再按一下鎖定圖示即可解開
and you can get to this by clicking the
檢視就會恢復原來的功能
blue book icon, and this will open the
檢視裡也提供資源的搜尋
documentation page on this component.
例如材質
A context sensitive panel, the inspector changes
當點選著色器(Renderer)指定的貼圖資源 你可以看到資源在專案裡的位置
to whatever you have selected,
該資源也會用黃色外框標記起來 讓你可以快速搜尋到物件的關連資源
meaning that you can adjust any object
在這個範例裡 我們看到一個物件著色器指定了一個材質
and immediately dive in to settings and back.
而在檢視的下方可以預覽材質的設定
Because Unity makes use of dragging and dropping to assign values
我可以直接在檢視裡編輯材質
sometimes you may click on items
其他兩個我沒有選到的物件 因為使用相同的材質所以也跟著改變
that take you to their settings,
所以必須要注意我所調整的材質 是專案內的原始資源
rather than the one you wish to apply them to.
而不是一個實體物件
And for this reason you can lock the inspector
因此當我調整實體物件縮放比例 其他物件的縮放比例則不會變動
in order to work with a particular item
檢視裡的元件可以透過 點選名稱左邊的勾選框來關閉
and then unlock once you are done assigning settings.
同樣的,檢視裡的物件也可以透過 選物件名稱左邊的勾選框來關閉
For example on this game object I have a script component
當物件被關閉時 你會發現他們的名稱在階層裡會變為灰色
to which I must assign an array of textures.
以上是檢視的基本功能說明
But when I select my first texture I want the inspector
to remain on my game object,
rather than showing the texture's settings.
I could simply hold down the mouse
or I can simply select the object
and click on the lock at the top of the inspector.
This way when I select one or many textures
I can then drag and drop without the inspector changing focus.
Once I am done with this I simply click the lock again
and I can then select anything that I need to.
The inspector also offers a way of finding assets used on objects.
For example materials.
When clicking on an asset used within a renderer
you can see that asset highlighted inside the project panel.
It does this by highlighting with a yellow outline.
This helps you easily find the assets that your
game objects depend upon.
In this example we can see an object that has a material
assigned to it's renderer.
This particular material is then previewed
at the bottom of the inspector
and I can adjust that material directly from here.
However, the other two objects that I don't have selected
also use this material, so I must bare in mind that
the actual material I am adjusting
is the original material asset inside the project
and not a particular instance of an object
in the same way that I can adjust the scale of this object
without adjusting any other objects that
also have a scale value.
Components within the inspector can also be disabled
by clicking the checkbox to the left of their name.
And the entire object can be disabled by clicking
the checkbox next to it's name
at the top of the inspector.
When objects are disabled in this way
you'll notice that their name is greyed out
inside the hierarchy panel.
And that's the basics of the inspector in Unity.
