遊戲設計社
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Unity 3D 腳本教學 (十六)

向下

Unity 3D 腳本教學 (十六) Empty Unity 3D 腳本教學 (十六)

發表  aaa1218bbb 周五 11月 25, 2011 2:37 pm

◆ function OnPostprocessAudio (clip:AudioClip):void
描述:
◆ function OnPostprocessGameObjectWithUserProperties (root : GameObject, propNames : string[], values​​ : object[]) : void
描述:在導入文件時,為每個至少附加了一個用戶屬性的遊戲物體調用
propNames是一個string[ ],其中包含了所有找到的屬性的名稱,該值是一個object[ ],包含了所有實際的值,這個可以是Vector4, bool, string, Color, float, int.類型
典型的運用是從存儲在3dmax中的對像中讀取“用戶數據”基於什麼用戶數據被寫入到對象,你可以決定以不同的方式來後處理遊戲物體。下面的列子中,如果用戶數據字符串包含“addboxcollider”添加一個簡單的BoxCollider組件
lass MyPostprocessor ​​extends AssetPostprocessor ​​{
function OnPostprocessGameObjectWithUserProperties (
go : GameObject,
propNames : String[],
values​​ : System.Object[]
)
{
for (var i : int =0; i!= propNames.Length; i++)
{
var propName : String = propNames[i];
var value : Object = values​​[i];
Debug.Log("Propname: "+propName+" value: "+values​​[i]);
if (value.GetType() == String)
{
var s : String = value;
if (s.Contains("addboxcollider")) go.AddComponent(BoxCollider);
}
if (value.GetType() == Vector4)
{
var v : Vector4 = value;
// do something useful.
}
if (value.GetType() == Color)
{
var c : Color = value;
// do something useful.
}
if (value.GetType() == int)
{
var myInt : int = value;
// do something useful.
}
if (value.GetType() == float)
{
var myFloat : float = value;
// do something useful.
}
}
}
}
◆ function OnPostprocessModel (root:GameObject):void
描述:在子類中重載這個函數以便在模型完全導入後獲得通知
在一個預設被生成為遊戲物體層次前,root是導入模型的根物體
class MyModelPostprocessor ​​extends AssetPostprocessor ​​{
function OnPostprocessModel (g : GameObject) {
Apply(g.transform);
}
// 添加網格碰撞器到每個名稱中包含collider的遊戲物體上
function Apply (transform : Transform)
{
if (transform.name.ToLower().Contains("collider"))
{
transform.gameObject.AddComponent(MeshCollider);
}
// 循環
for (var child in transform)
Apply(child);
}
}
◆ function OnPostprocessTexture (texture:Teture2D):void
描述:在子類中重載這個函數以便在紋理被完全導入並被存儲到磁盤上之前獲取一個通知
//後期處理所有放置文件夾
// "invert color" 中的文件,反轉他們的顏色
class InvertColor extends AssetPostprocessor ​​{
// 使用這個初始化
function OnPostprocessTexture (texture : Texture2D) {
// 後期處理只在文件夾
// "invert color" 或它的子文件夾中的文件
// var lowerCaseAssetPath = assetPath.ToLower();
// if (lowerCaseAssetPath.IndexOf ("/invert color/") == -1)
//return;
for (var m=0;m {
var c : Color[] = texture.GetPixels(m);
for (var i=0;i {
c[i].r = 1 - c[i].r;
c[i].g = 1 - c[i].g;
c[i].b = 1 - c[i].b;
}
texture.SetPixels(c, m);
}
// 不需要設置每個mip map 等級圖片的像素你也可以只修改最高mip等級的像素並使用texture.Apply(TRUE);來產生較低mip等級
}
}
◆ function OnPreprocessAudio ():void
描述:
◆ function OnPreprocessModel():void
描述:在子類中重載這個函數以便在模型被導入前獲得一個通知
這個可以讓你為模型的導入設置默認值
class MyMeshPostprocessor ​​extends AssetPostprocessor ​​{
function OnPreprocessModel () {
// 禁用材質生成,如果文件包含@號,表明他是動畫
if (assetPath.Contains("@")) {
var modelImporter : ModelImporter = assetImporter;
modelImporter.generateMaterials = 0;
}
}
}
◆ function OnPostprocessTexture():void
描述:在子類中重載這個函數以便在紋理導入器運行前獲得一個通知,
這個可以讓你導入設置為默認值
class MyTexturePostprocessor ​​extends AssetPostprocessor
{
function OnPreprocessTexture () {
// 自動轉化任何文件名中帶有"_bumpmap"的紋理文件為法線貼圖

if (assetPath.Contains("_bumpmap")) {
var textureImporter : TextureImporter = assetImporter;
textureImporter.convertToNormalmap = true;
}
}
}
BuildPipeline

類方法
◆ static function BuildAssetBundle (mainAsset : Object, assets; Object[].pathName : string,o​​ptions ; BuildAssetBundleOptions = BuildAssetBundleOptions CollectDependencies
BuildAssetBundleOptionsCompleteAssets) : bool
描述:構建資源bundle(Unity Pro only).
創建一個包含assets集合的壓縮Unity3D文件。 AssetBundles可以包含工程文件夾中的任何資源,這可以讓你流式下載任何類型的資源數據,完整設置的預設,紋理,網格,動畫,顯示在工程窗口中的任何類型的資源。 mainAsset 讓你指定一個特定的物體,它可以方便地使用AssetBundle.mainAsset取回。這個壓縮的資源bundle文件將被存儲在pathName.options允許你自動地包含依賴性或者總是包含完整的資源而不僅僅是引用的對象。
參見:AssetBundle 類,WWW.assetBundle.
◆ Static function BuildPlayer (levels : string[],locationPathName : string,target:BuildTarget,
Options : BuildOptions) : string.
描述:構建播放器(Unity Pro only).
/levels/是被包含在構建中的場景,(如果levels 為空,當前打開的場景將被構建)locationPathName 是應用程序將被保存的路徑,target 是將被構建的BuildTarget, options是一些額外的選項,如紋理壓縮,調試信息剝離。
◆ Static function PopAssetDependencies():void
描述:讓你管理不同資源bundle和播放器構建之間的交叉引用和依賴性,
如果一個資源bundles依賴於另一個資源dundles,確保依賴的資源bundles通過
WWW類加載是你的責任。
當你放入資源依賴性時它將共享那個層上的所有資源,放入遞歸地繼承前一個依賴關係,PushAssetDependencies和PopAssetDependencies必須成對出現。
@\lenulten(“Assets/Auto Build Asset Bundles”)
Static function ExportResource(){
//對所有下面的資源bundles文件啟用交叉引用直到//我們調用PopAssetDependencies
QuikPipcliPushAssetDcpenclencies();
Var options=
BuildAssetBundleOptions CollectDependencies]
BuildAssetBundleOptions CompleteAssets;
//所有後續資源共享這個資源bundles中的資源
//它是由你來確保共享的資源bundle
//優先於其他資源加載
Buldpipeline.BuldAssertBundle(
AssetDatabase.LoadMainAssetAtPath(“assets/artwork/lerpzuv.tif”,
null,”Sharde.unity3d”,options);
//通過收入和彈出資源bundle,這個文件
//將共享資源,但是後面的資源bundle將不會共享這個​​資源中的資源
BuildPipeline.PushAssetDependencies();
BuildPipeline.PushAssetBundle(
AssetDatabaseLoadMainAssetAtPath(“Asset Artwork/Lerpztbx'),
Null,”Lerpz.unity3d”,options);
BuildPipeline.PushAssetDependencies();
BuildPipeline.PushAssetDependencies();
BuildPipeline.PushAssetDependencies();
}
參見:PushAssetDependencies,Buid​​AssetBundle.
DragAndDrop

編輯器拖放操作。
注意:這是一個編輯器類,為了使用它你必須放置腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加”using UnityEditor,”。
類變量
◆ Static var activeControlID : int
描述:
◆ Static var objectReferences :Object[]
描述:被拖動的objects的引用。
沒有返回null,如果沒有物體引用可用返回一個空的數組。
參見:paths,PrepareStartDrag,StartDrag,
◆ Static var paths :string[]
描述:被拖放的文件名
沒有返回null。如果沒有路徑可用返回一個空的數組。
參見: objectReferences, PrepareStartDrag,StartDrag,.
◆ Static var visualMode:DragAndDropVisualMode
描述:拖放的視覺標誌
默認為DragAndDropVisualMode Link
function OnGUI ()
{
var eventType = Event.current.type;
if (eventType == EventType.DragUpdated || eventType == EventType.DragPerform)
{
// Show a copy icon on the drag
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (eventType == EventType.DragPerform)
DragAndDrop.AcceptDrag();
Event.current.Use();
}
}
類方法
◆ Static function AcceptDrag() : void
描述:接收拖動操作。
◆ Static function GetGenericData(type : string) : object
描述:
◆ Static function PrepareStartDrag() : void
描述:清除拖放數據。
清楚所有存儲在拖放物體中的數據並準備它,這樣你可以為初始化一個拖動操作寫入它。
參見:StartDrag,paths,objectReferences.
function OnGUI ()
{
if (Event.current.type == EventType.MouseDrag)
{
// 清除拖動數據
DragAndDrop.PrepareStartDrag ();
// 設置我們需要拖動什麼
DragAndDrop.paths = { "/Users/joe/myPath.txt" };
// 開始拖動
DragAndDrop.StartDrag ("Dragging title");
// 確保我們之後沒有人使用這個事件
Event.current.Use();
}
}
◆ Static function SetGenericData(type:string,data:object) : void
描述:
◆ Static function StartDrag(title:string): void
描述:開始拖動操作。
用當前拖動物體狀態初始化一個拖動操作。使用paths和/或objectReferences來設置拖動狀態。
參見:PrepareStartDrag,paths,objectReferences.
function OnGUI ()
{
if (Event.current.type == EventType.MouseDrag)
{
// 清除拖動數據
DragAndDrop.PrepareStartDrag ();
// 設置我們需要拖動什麼
DragAndDrop.paths = { "/Users/joe/myPath.txt" };
// 開始拖動
DragAndDrop.StartDrag ("Dragging title");
// 確保我們之後沒有人使用這個事件
Event.current.Use();
}
}
DrawGizmo
類,繼承自System Attribute
DrawGizmo屬性允許你為任何類型的Compartent提供一個gizmo渲染器。
注意:這是一個編輯器類,為了使用它你必須放置腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加”using UnityEditor”.
目前,z你只能為引擎組件提供gizmo繪製,所有的gizmo繪製方法需要是靜態的,
//如果這個光源沒有被選擇將調用RenderLightGizmo函數
//當拾取時gizmo被繪製
@DrawGizmo (GizmoType.NotSelected | GizmoType.Pickable)
static function RenderLightGizmo (light : Light, gizmoType : GizmoType)
{
var position = light.transform.position;
// 繪製光源圖標
// 在內置的光源Gizmo上面一點)
Gizmos.DrawIcon (position + Vector3.up, "Light Gizmo.tiff");
// 我們選擇了嗎? Draw a solid sphere surrounding the light
if ((gizmoType & GizmoType.SelectedOrChild) != 0)
{
// 使用一個較為明亮的顏色表明這是一個活動對象.
if ((gizmoType & GizmoType.Active) != 0)
Gizmos.color = Color.red;
else
Gizmos.color = Color.red * 0.5;
Gizmos.DrawSphere (position, light.range);
}
}

/// C# 例子
using UnityEditor;
using UnityEngine;
class GizmoTest
{
/// 如果這個光源沒有被選擇調用RenderLightGizmo函數.
/// 當拾取時gizmo被繪製.
[DrawGizmo (GizmoType.NotSelected | GizmoType.Pickable)]
static void RenderLightGizmo (Light light, GizmoType gizmoType)
{
Vector3 position = light.transform.position;
// 繪製光源圖標
// (在內置的光源Gizmo上面一點)
Gizmos.DrawIcon (position + Vector3.up, "Light Gizmo.tiff");
// 我們選擇了嗎?圍繞光源繪製一個球體
if ((gizmoType & GizmoType.SelectedOrChild) != 0)
{
//使用一個較為明亮的顏色表明這是一個活動對象.
if ((gizmoType & GizmoType.Active) != 0)
Gizmos.color = Color.red;

else
Gizmos.color = Color.red * 0.5F;
Gizmos.DrawSphere (position, light.range);
}
}
}

構造函數
◆ Static function DrawGizmo(gizmo: GizmoType): DrawGizmo
描述:定義何時Gizmo應該被調用以便繪製。
參見: GizmoType
◆ Static function DrawGizmo(gizmo: GizmoType,drawnGizmoType:Type):DrawGizmo
描述:同上,drawnGizmoType決定要繪製的Gizmo物體是什麼類型的。
如果drawnGizmoType為null,這個類型將由該函數的第一個參數決定。
Editor
類,繼承自ScriptableObject
一個基類,可以從它派生自定義的編輯器,使用這個給你的物體創建自定義的檢視面板和編輯器。
注意:這是一個編輯器類。為了使用它你必須放置腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加”using UnityEditor,”。
通過使用CustomEditor屬性可以附加Editor到一個自定義的組件。
JavaScript例子:
//這個例子為一個”MyPlayer”物體顯示一個自定義的檢視面板。
它有兩個變量,speed和ammo.
@CustomEditor(MyPlayer)
class MyPlayerEditor extends Editor
{
function OnInspectorGUI()
{
EditorGUILayout.BeginHorizo​​ntal();
EditorGUILayout.PrefixLabel("Speed​​");
target.speed = EditorGUILayout.Slider(target.speed, 0, 100);
EditorGUILayout.EndHorizo​​ntal();
EditorGUILayout.BeginHorizo​​ntal();
EditorGUILayout.PrefixLabel("Ammo");
target.ammo = EditorGUILayout.IntField(target.ammo);
EditorGUILayout.EndHorizo​​ntal();
}
}
變量
◆ Var target:Object
描述:被檢視的對象
消息傳遞
◆ Function OnInspectorGUI():void
描述:實現這個函數來製作一個自定義的檢視面板。
◆ Function OnSceneGUI() : void
描述:在場景視圖中讓編輯器處理一個事件。
在OnSceneGUI中你可以做,例如網格編輯,地形繪製或高級的gizmos,如果調用Eventcurrent,Use(),該事件將被編輯處理並不會被場景視圖使用。
繼承的成員
繼承的變量
name 對象的名稱
hideFlags 該物體是否被隱藏,保存在場景中或被用戶修改
繼承的函數
GetInstanceID 返回該物體的實例ID
繼承的消息傳遞
OnEnable 物體被加載時調用該函數
OnDisable 當可編輯物體超出範圍時調用這個函數
繼承的類函數
CreateInstance 使用className創建一個可編程物體的實例。
operatorbool 這個物體存在嗎
Instannate 克隆original物體並返回這個克隆
Destroy 移除一個遊戲物體,組件或資源
DestroyImmediate 立即銷毀物體obj,強力建議使用Destroy代替
FindObjectsOFType 返回所有類型為type的激活物體
FindObjectOFType 返回第一個類型為type的激活物體
Operator== 比較兩個物體是否相同
Operator! = 比較兩個物體是否不相同
DontDestroyOnLoad 加載新場景時確保物體target不被自動銷毀。
EditorApplication

注意:這是一個編輯器類。為了使用它你必須放置腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加”using UnityEditor,”。
類變量
◆ Static var applicationContentsPath:string
描述:Unity編輯器內容文件的路徑(只讀)
這個內容文件夾包含用來構建播放器的一些內部文件。
◆ Static var applicationPath:string
描述:返回Unity編輯器的路徑(只讀)
參見:applicationContentsPath
◆ Static var currentScene:string
描述:用戶當前打開的場景的路徑(只讀)。
◆ Static var isPaused : bool
描述:編輯器當前暫停?
可編輯地改變暫停狀態,就像按下主工具欄上的Pause按鈕。
參見:isPlaying.
◆ Static var isPlaying : bool
描述:編輯器當前處於播放模式?
isPaying的設置會延遲直到到該幀中所有的腳本代碼已經完成。
◆ Static var isPlayingOrWillChangePlaymode : bool
描述:編輯器當前處於播放模式,或者將切換到播放模式? (只讀)
當編輯器在完成某些任務(例如,在腳本被重編譯之後)後將切換到播放模式時,這個將返回真。
參見:isPlaying,isCompiling.
類方法
◆ Static function Beep():void
描述:播放系統嗶嗶聲
//在鼠標按下事件中播放聲音
Function OnGUI(){
if (Event.current.type == EventType.MouseDrag)
EditorApplication.Bceo();
}
◆ Static function Exit(returnValue:int):void
描述:退出Unity編輯器。
調用這個函數將立即退出,不會詢問保存改變,因此你將丟失數據!
◆ Static function LockReloadAssemblies():void
描述:當不方便的時候阻止部件的加載。
例如,在拖動操作的時候,你也許想阻止部件的重加載以便在拖動過程中不會丟失狀態。
每個LockReloadAssemblies必須與UnLockReloadAssemblies匹配,否則腳本將不會被卸載。 Unity自動在鼠標按下的時候阻止重加載。
參見:EditorApplication. UnLockReloadAssemblies
◆ Static function NewScene():void
描述:創建新的場景。
◆ Static function OpenScene(path:string):bool
描述:打開位於Path的場景。
當前打開的場景不會被保存,使用SaveSceneIfUserWantsTo來做這個。
◆ Static function OpenSceneAdditive(path:string):void
描述:打開位於path的附加場景。
◆ Static function SaveAssets ():void
描述:保存所有還沒有寫到磁盤的可序列化資源(例如,材質)
也確保資源數據庫被寫入。
◆ Static function SaveCurrentSceneIfUserWantsTo():​​bool
描述:詢問用戶是否要保存打開的場景。
你可能想在打開其他場景或創建一個新的場景時調用這個函數。返回真表示你想繼續。返回為假表示用戶要取消這個操作,因此不應該打開其他場景。
◆ Static function SaveScene(path:string):bool
描述:保存場景到path.
◆ Static function Step():voidl
描述:執行單幀步進。
就像你按下了主打工具欄上的Step按鈕。
◆ Static function UnLockReloadAssemblies ():voidl
描述:必須在LockReloadAssemblies之後調用,來重啟用集合的加載。
參見:EditorApplication, LockReloadAssemblies
EditorGUILayout

EditorGUI的自動佈局版本
注意:這是一個編輯器類。為了使用它你必須放置腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加”using UnityEditor,”。
類方法
◆ Static function BeginHorizo​​ntal(params options:GUILayoutOption[]):Rect
◆ Static function BeginHorizo​​ntal(style:GUIStyle, params options:GUILayoutOption[]):Rect
參數
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUIlayout,Width,GUILayout,Height,GUILayout MinWidth,
GUILayout MaxWidth, GUILayout MinHeight, GUILayout MaxHeight
GUILayout ExpandWidth, GUILayout ExpandHeight,
描述:開始一個水平組並獲取它的矩形。
這是GUILayout BeginHorizo​​ntal的擴展,用來製作組合控件。
//組合按鈕
Rect r = EditorGUILayout.BeginHorizo​​ntal ("Button");
if (GUI.Button (r, GUIContent.none))
Debug.Log ("Go here");
GUILayout.Label ("I'm inside the button");
GUILayout.Label ("So am I");
EditorGUILayout.EndHorizo​​ntal ();
◆ Static function BeginScrollView (scrollPosition : Vector2, params options:GUILayoutOption[]):Vector2
◆ Static function BeginScrollView (scrollPosition : Vector2, alwaysShowHorizo​​ntal:bool,alwaysShowVertical:bool, params options:GUILayoutOption[]):Vector2
◆ Static function BeginScrollView (scrollPosition : Vector2, horizo​​ntalScrollbar::GUIStyle,verticalScrollbar:GUIStyle, params options:GUILayoutOption[]):Vector2

static function BeginScrollView (scrollPosition : Vector2, alwaysShowHorizo​​ntal : bool, alwaysShowVertical : bool, horizo​​ntalScrollbar : GUIStyle, verticalScrollbar : GUIStyle, params options : GUILayoutOption[]) : Vector2
參數
scrollPosition 用來顯示的位置
alwaysShowHorizo​​ntal 可選的參數用來總是顯示水平滾動條,如果為黑線留空,它就只在ScrollView中的內容比滾動提高時顯示。
alwaysShowVertical 可選的參數用來總是顯示垂直滾動條,如果為黑線留空,它就只在ScrollView中的內容比滾動提高時顯示。
horizo​​ntalScrollbar 用於水平滾動條的可選GUIStyle,如果不設置,將使用當前GUISkin的horizo​​ntalScrollbar
verticalScrollbar 用於垂直滾動條的可選GUIStyle,如果不設置,將使用當前GUISkin的verticalScrollbar風格。
返回:Vector2,修改過的scrollPosition,回傳這個變量,如下的例子。
描述:開始有個自動佈局滾動條。
這個就像GUILayout BeginScrollView一樣,但是更像應用程序且應該在編輯器中使用。
◆ static function BeginToggleGroup (label : string, toggle : bool) : bool
◆ static function BeginToggleGroup (label : GUIContent, toggle : bool) : bool
參數
label 顯示在開關控件上的標籤
toggle 開關組的啟用狀態
返回bool – 用戶選擇的啟用狀態。
描述:開始一個帶有開關的組,以便一次啟用或禁用其中的所有控件。
參見:EndToggleGroup
// 設置
settingsOn = EditorGUILayout.BeginToggleGroup("Settings", settingsOn);
backgroundColor = EditorGUILayout.ColorField(backgroundColor);
soundOn = EditorGUILayout.Toggle(soundOn, "Turn on sound");
EditorGUILayout.EndToggleGroup();
◆ static function BeginVertical (params options : GUILayoutOption[ ]) : Rect
◆ static function BeginVertical (style : GUIStyle, params options : GUILayoutOption[ ]) :Rect
參數
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定程序的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
描述:開始一個垂直組並獲取它的矩形。
這是GUILayout.BeginVertical的擴展,用來製作組合控件。
// 組合按鈕
Rect r = EditorGUILayout.BeginVertical ("Button");
if (GUI.Button (r, GUIContent.none))
Debug.Log ("Go here");
GUILayout.Label ("I'm inside the button");
GUILayout.Label ("So am I");
EditorGUILayout.EndVertical ();
◆ static function ColorField (value : Color, params options : GUILayoutOption[ ]) : Color
◆ static function ColorField (label : string, value : Color, params options : GUILayoutOption[ ]) : Color
◆ static function ColorField (label : GUIContent, value : Color,
params options : GUILayoutOption[ ]) : Color
參數
Label 顯示在該域前面的可選標籤。
Value 用於編輯​​的顏色
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Color- 用戶選擇的顏色
描述:製作一個用來選擇Color的域
◆ static function EndHorizo​​ntal () : void
描述:關閉一個開始於BeginHorizo​​ntal的組
◆ static function EndScrollView () : void
描述:結束開始於BeginScrollView的滾動視。
◆ static function EndToggleGroup () : void
描述:關閉一個開始於BeginToggleGroup
// Settings
settingsOn = EditorGUILayout.BeginToggleGroup("Settings", settingsOn);
backgroundColor = EditorGUILayout.ColorField(backgroundColor);
soundOn = EditorGUILayout.Toggle(soundOn, "Turn on sound");
EditorGUILayout.EndToggleGroup();
◆ static function EndVertical () : void
描述:關閉一個開始於BeginVertical的組
◆ static function EnumPopup (selected : System.Enum, params options : GUILayoutOption[]) : System.Enum
◆ static function EnumPopup (selected : System.Enum, style : GUIStyle, params options : GUILayoutOption[ ]) : System.Enum
◆ static function EnumPopup (label : string, selected : System.Enum, params options : GUILayoutOption[ ]) : System.Enum
◆ static function EnumPopup (label : string, selected : System.Enum, style : GUIStyle,
params options : GUILayoutOption[ ]) : System.Enum
◆ static function EnumPopup (label : GUIContent, selected : System.Enum, params options : GUILayoutOption[ ]) : System.Enum
◆ static function EnumPopup (label : GUIContent, selected : System.Enum, style : GUIStyle, params options : GUILayoutOption[ ]) : System.Enum
參數
label 該域前面可選的標籤
selected 該域顯示的選項
style 可選的GUIStyle
options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由Sryle定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:floar-被用戶選擇的選項
描述:製作一個彈出式選擇域
使用當前選擇的值作為參數並返回用戶選擇的值。
◆ static function FloatField (value : float, params options : GUILayoutOption[]) : float
◆ static function FloatField (value : float, style : GUIStyle, params options : GUILayoutOption[]) : float
◆ static function FloatField (label : string, value : float, params options : GUILayoutOption[]) : float
◆ static function FloatField (label : string, value : float, style : GUIStyle, params options : GUILayoutOption[]) : float
◆ static function FloatField (label : GUIContent, value : float, params options : GUILayoutOption[]) : float
◆ static function FloatField (label : GUIContent, value : float, style : GUIStyle, params options : GUILayoutOption[]) : float
參數
Label 顯示在浮點域前面的可選標籤。
Value 用於編輯​​的值
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:float – 用戶輸入的值
描述:製作一個文本域以便輸入浮點數。
◆ static function Foldout (foldout : bool, content : string, style : GUIStyle = EditorStyles.foldout) : bool
◆ static function Foldout (foldout : bool, content : GUIContent, style : GUIStyle = EditorStyles.foldout) : bool

參數
Foldout 顯示折疊狀態
Content 顯示的標籤
Style 可選的GUIStyle
返回:bool – 用戶選擇的折疊狀態,如果為真,應該渲染子對象。
描述:製作一個左側帶有折疊箭頭的標籤。
這可以用來創建一個樹或文件夾結構,這裡子對像只在夫展開的時候顯示
◆ static function InspectorTitlebar (foldout : bool, targetObj : Object) : bool
參數
Foldout 折疊狀態用這個箭頭顯示。
targetObj 使用該標題欄的對象(例如組件)
返回:bool – 用戶選擇的折疊狀態
描述:製作一個檢視窗口標題欄
該標題欄有一個折疊箭頭,一個幫助圖標和一個設置菜單,設置菜單依賴於所提供的對象的類型。
◆ static function IntField (value : int, params options : GUILayoutOption[ ]) : int
◆ static function IntField (value : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function IntField (label : string, value : int, params options : GUILayoutOption[ ]) : int
◆ static function IntField (label : string, value : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function IntField (label : GUIContent, value : int, params options : GUILayoutOption[ ]) : int
◆ static function IntField (label : GUIContent, value : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
參數
Label 顯示在該整型域前面的可選標籤。
Value 用於編輯​​的值
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局
屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:int – 用戶輸入的值。
描述:製作一個文本域以便輸入整數。
◆ static function IntPopup (selectedValue : int, displayedOptions : string[ ], optionValues​​ : int[ ], params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (selectedValue : int, displayedOptions : string[ ], optionValues​​ :
int[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (selectedValue : int, displayedOptions : GUIContent[ ], optionValues​​ : int[ ], params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (selectedValue : int, displayedOptions : GUIContent[ ], optionValues​​ : int[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (label : string, selectedValue : int, displayedOptions : string[ ], optionValues​​ : int[ ], params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (label : string, selectedValue : int, displayedOptions : string[ ], optionValues​​ : int[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (label : GUIContent, selectedValue : int, displayedOptions : GUIContent[ ], optionValues​​ : int[ ], params options : GUILayoutOption[ ]) : int
◆ static function IntPopup (label : GUIContent, selectedValue : int, displayedOptions : GUIContent[ ], optionValues​​ : int[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
參數
Label 該域前面可選的標籤。
selectedValue 該域顯示的選項的值
displayedOptions 一個帶有顯示X顯示選項的數組,用戶可以從中選擇。
optionValues​​ 一個為每個選項存儲值得數組。
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:int – 被用戶選擇的選項的值
描述:製作一個整形彈出式選擇域
使用當前選擇的整數作為參數並返回用戶選擇的整數。
◆ static function IntSlider (value : int, leftValue : int, rightValue : int, params options : GUILayoutOption[ ]) : int
◆ static function IntSlider (label : string, value : int, leftValue : int, rightValue : int, params options : GUILayoutOption[ ]) : int
◆ static function IntSlider (label : GUIContent, value : int, leftValue : int, rightValue : int, params options : GUILayoutOption[ ]) : int
參數
Label 該滑桿前面可選的標籤。
Value 滑桿顯示的值。這個決定可拖動滑塊的位置。
leftValue 滑桿左端的值

rightValue 滑桿右端的值
options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:int – 被用戶設置的值
描述:製作一個用戶可以拖動到滑桿可以在min和max之前改變一個整數值。
◆ static function LabelField (label : string, label2 : string, params options : GUILayoutOption[ ]) : void
參數
Label 該域前面的標籤
Label2 顯示在右側的標籤
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
描述:製作一個標籤域(用來顯示只讀信息)
◆ static function LayerField (layer : int, params options : GUILayoutOption[ ]) : int
◆ static function LayerField (layer : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function LayerField (label : string, layer : int, params options : GUILayoutOption[ ]) : int
◆ static function LayerField (label : string, layer : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function LayerField (label : GUIContent, layer : int, params options : GUILayoutOption[ ]) : int
◆ static function LayerField (label : GUIContent, layer : int, style : GUIStyle, params options : GUILayoutOption[ ]) : int
參數
Label 該域前面可選的標籤
Layer 顯示在該域中的層
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:int – 用戶選擇的層

描述:製作一個層選擇域
◆ static function ObjectField (obj : Object, objType : System.Type, params options : GUILayoutOption[ ]) : Object
◆ static function ObjectField (label : string, obj : Object, objType : System.Type, params options : GUILayoutOption[ ]) : Object
◆ static function ObjectField (label : GUIContent, obj : Object, objType : System.Type, params options : GUILayoutOption[ ]) : Object
參數
Label 該域前面可選的標籤
Obj 該域顯示的對象
objType 對象的類型
options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Object – 被用戶設置的對象
描述:製作一個物體放置槽域
◆ static function PasswordField (password : string, params options : GUILayoutOption[ ]) : string
◆ static function PasswordField (password : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function PasswordField (label : string, password : string, params options : GUILayoutOption[ ]) : string
◆ static function PasswordField (label : string, password : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function PasswordField (label : GUIContent, password : string, params options : GUILayoutOption[ ]) : string
◆ static function PasswordField (label : GUIContent, password : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
參數
Label 顯示在該密碼域前面的可選標籤
Password 用於編輯​​的密碼
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外iad佈局屬性
任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight,

GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:string – 用戶輸入的密碼
描述:製作一個用戶可以輸入密碼的文本域
這個就像GUILayoutPasswordField,但是正確的響應所有選擇,在編輯器中,可以有一個可選的標籤在前面。
◆ static function Popup (selectedIndex : int, displayedOptions : string[ ], params options : GUILayoutOption[ ]) : int
◆ static function Popup (selectedIndex : int, displayedOptions : string[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function Popup (selectedIndex : int, displayedOptions : GUIContent[ ], params options : GUILayoutOption[ ]) : int
◆ static function Popup (selectedIndex : int, displayedOptions : GUIContent[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function Popup (label : string, selectedIndex : int, displayedOptions : string[ ], params options : GUILayoutOption[ ]) : int
◆ static function Popup (label : string, selectedIndex : int, displayedOptions : string[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int
◆ static function Popup (label : GUIContent, selectedIndex : int, displayedOptions : GUIContent[], params options : GUILayoutOption[ ]) : int
◆ static function Popup (label : GUIContent, selectedIndex : int, displayedOptions : GUIContent[ ], style : GUIStyle, params options : GUILayoutOption[ ]) : int

參數
Label 該域前面可選的標籤
selectedIndex 該域顯示的選項的索引
displayedOptions 顯示在彈出菜單中的選項數組
style 可選的GUIStyle
options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:int – 被用戶選擇的選項的索引
描述:製作一個通用的彈出式選擇域
使用當前選擇的索引作為參數並返回用戶選擇的索引
◆ static function PrefixLabel (label : string, followingStyle : GUIStyle = "Button") : void
◆ static function PrefixLabel (label : string, followingStyle : GUIStyle, labelStyle : GUIStyle) : void
◆ static function PrefixLabel (label : GUIContent, followingStyle : GUIStyle = "Button") :
void
◆ static function PrefixLabel (label : GUIContent, followingStyle : GUIStyle, labelStyle : GUIStyle) : void
參數
Label 顯示在控件前面的標籤
描述:在一些控件前面製作一個標籤。
GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
◆ static function RectField (value : Rect, params options : GUILayoutOption[ ]) : Rect
◆ static function RectField (label : string, value : Rect, params options : GUILayoutOption[ ]) : Rect
◆ static function RectField (label : GUIContent, value : Rect, params options : GUILayoutOption[ ]) : Rect
參數
Label 顯示在該域上的標籤
Value 用於編輯​​的值
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Rect – 用戶輸入的值
描述:製作一個X,Y,W&H域以便輸入一個Rect。
◆ static function Separator () : void
描述:在前一個控件和後面的控件之前製作一個小的分隔符。
◆ static function Slider (value : float, leftValue : float, rightValue : float, params options : GUILayoutOption[ ]) : float
◆ static function Slider (label : string, value : float, leftValue : float, rightValue : float, params options : GUILayoutOption[ ]) : float
◆ static function Slider (label : GUIContent, value : float, leftValue : float, rightValue : float, params options : GUILayoutOption[ ]) : float
參數
Label 該滑桿前面可選的標籤
Value 滑桿顯示的值,這個決定可拖動滑塊的位置。
leftValue 滑桿左端的值
rightValue 滑桿右端的值
options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:float – 被用戶設置的值
描述:一個用戶可以拖動到滑桿,可以在min和max之前改變一個值。
◆ static function Space():void
描述:在前一個控件和後面的控件之間製作一個小的空格。
◆ static function TagField (tag : string, params options : GUILayoutOption[ ]) : string
◆ static function TagField (tag : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function TagField (label : string, tag : string, params options : GUILayoutOption[ ]) : string
◆ static function TagField (label : string, tag : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function TagField (label : GUIContent, tag : string, params options : GUILayoutOption[ ]) : string
◆ static function TagField (label : GUIContent, tag : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
參數
Label 該域前面可選定標籤
Tag 該域​​顯示的標籤
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性。任何在這裡設置的值將覆蓋由style定義的設置。
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:string – 用戶選擇的標籤
描述:製作一個標籤選擇域
◆ static function TextArea (text : string, params options : GUILayoutOption[ ]) : string
◆ static function TextArea (text : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
參數
Text 用於編輯​​的文本
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:string – 用戶輸入的文本
描述:製作一個文本區域
這個就像GUIlayout。 TextArea一樣。但是正確地響應全選,拷貝,粘帖等。在編輯器中
◆ static function TextField (text : string, params options : GUILayoutOption[ ]) : string
◆ static function TextField (text : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function TextField (label : string, text : string, params options : GUILayoutOption[ ]) : string
◆ static function TextField (label : string, text : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
◆ static function TextField (label : GUIContent, text : string, params options : GUILayoutOption[ ]) : string
◆ static function TextField (label : GUIContent, text : string, style : GUIStyle, params options : GUILayoutOption[ ]) : string
參數
Label 顯示在該文本前面的可選標籤
Text 用於編輯​​的文本
Style 可選的GUIStyle
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:string – 用戶輸入的文本
描述:製作一個文本區域
這個就像GUIlayout。 TextField一樣。但是正確地響應全選,拷貝,粘帖等。在編輯器中,可以有一個可選的標籤在前面
◆ static function Toggle (value : bool, params options : GUILayoutOption[ ]) : bool
◆ static function Toggle (label : string, value : bool, params options : GUILayoutOption[ ]) : bool
◆ static function Toggle (label : GUIContent, value : bool, params options : GUILayoutOption[ ]) : bool
參數
Label 該開關前面可選的標籤
Value 這個開關的顯示狀態
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置

參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回: bool – 這個開關的顯示狀態
描述: 製作一個開關
◆ static function Vector2Field (label : string, value : Vector2, params options : GUILayoutOption[ ]) : Vector2
參數
Label 顯示在該域上的標籤
Value 用於編輯​​的值
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Vector2 – 用戶輸入的值
描述:製作一個X&Y域以便輸入一個Vector2
◆ static function Vector3Field (label : string, value : Vector3, params options : GUILayoutOption[ ]) : Vector3
參數
Label 顯示在該域上的標籤
Value 用於編輯​​的值
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Vector3 – 用戶輸入的值
描述:製作一個X&Y域以便輸入一個Vector3
◆ static function Vector4Field (label : string, value : Vector4, params options : GUILayoutOption[ ]) : Vector4
參數
Label 顯示在該域上的標籤
Value 用於編輯​​的值
Options 一個可選的佈局選項的列表,它用來指定額外的佈局屬性,任何在這裡設置的值將覆蓋由style定義的設置
參見:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
返回:Vector4 – 用戶輸入的值
描述:製作一個X&Y域以便輸入一個Vector4
EditorGUIUtility
類,繼承自GUIUility
用戶EditorGUI的各種輔助函數
注意:這是一個編輯器類。為了使用它你必須防止腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加“usingUnityEditor”
變量
◆statie var systemCopyBuffer:string
描述:系統拷貝緩存
使用這個使拷貝和粘貼為你自己的數據工作
◆statie var whiteTexture:Texture2D
描述:獲取一個白色紋理
類方法
◆statie function AddCursorRect(position:Rect,mouse:MouseCursor):void
參數
position 顯示控件的矩形
mouse 使用鼠標光標
描述:添加一個自定義的鼠標光標到一個控件
function OnGUI()
{
// 當鼠標懸停在這個矩形上時,顯示“link”光標
EditorGUIUtility.AddCursorRect (Rect(10,10,100,100), MouseCursor.Link);
}
◆static function DrawColorSwatch (position : Rect, color : Color) : void
參數
position 繪製樣板顏色的矩形。 Color繪製顏色
描述:繪製一個顏色樣本
◆static function FindTexture (name : string) : Texture2D
描述:從源文件名獲取一個紋理
◆static function HasObjectThumbnail (objType : Type) : bool
描述:給定的類有對像有小物體
◆static function Load (path : string) : Object
描述:加載一個內置資源
這個函數將在Assets/Editor Default Resources/ + path中查找資源,如果沒有,它將按照名稱嘗試內置的編輯器資源
var handleMaterial : Material = EditorGUIUtility.Load (Load("HandleMaterial.mat"));
◆static function LoadRequired (path : string) : Object
描述:加載位於路徑上的內置資源
這個函數將在Assets/Editor Default Resources/ + path中查找任何資源。
var handleMaterial : Material = EditorGUIUtility.Load (Load("HandleMaterial"));
◆ static function LookLikeControls (labelWidth : float = 100, fieldWidth : float = 70) : void

參數
labelWidth 用於前綴標籤的寬帶
fieldWidth 文本條目的寬度。參見:LookLikeInspector
描述:使所有ref::EditorGUI外觀像普通控件
這將使EditorGUI::ref::使用默認風格,看起來想控件(例如eg EditorGUI.Popup成為一個完全是彈出菜單)
◆ static function LookLikeInspector () : void
描述:使所有ref::EditorGUI外觀像簡化邊框的視控件
這個將使EditorGUI使用的默認風格的外觀就像它在檢視面板中一樣
參見:LookLikeControls
◆ static function ObjectContent (obj : Object, type : System.Type) : GUIContent
描述:返回一個帶有名稱和圖標的GUIContent物體
如果物體為空,圖標將根據類型選擇
◆ static function PingObject (obj : Object) : void
描述:Ping​​窗口中的一個對象,就像在檢視面板中點擊它
◆ static function QueueGameViewInputEvent (evt : Event) : void
描述:發送一個輸入事件到遊戲
◆ static function RenderGameViewCameras (cameraRect : Rect, statsRect : Rect, stats : bool, gizmos : bool) : void
cameraRect 用於渲染所有遊戲相機的設備坐標
statsRect 統計應該顯示的地方
stats 疊加顯示統計數據
gizmos 也顯示gizmos
描述:渲染所有遊戲內的相機
繼承的成員
繼承的類變量
hotControl 當前具有熱點的控件controlID
keyboardControl 具有鍵盤焦點控件的controlID
繼承的類函數
GetControlID 為一個控件獲取唯一ID
GetStateObject 從一個controlID.獲取一個狀態
QueryStateObject 從一個controlID.獲取一個存在的狀態物體
MoveNextAndScroll 只允許從OnGUI內部調用GUI函數
GUIToScreenPoint 將一個點從GUI位置轉化為屏幕空間
ScreenToGUIPoint 將一個點從屏幕空間轉化為GUI位置
RotateAroundPivot 使GUI圍繞一個點選擇的輔助函數
ScaleAroundPivot
EditorGUI

只用於編輯器GUI的類,這個類包含了附加到UnityGUI的通用2D元素
注意:這是一個編輯器類。為了使用它你必須防止腳本到工程文件夾的Assets/Editor中,編輯器類位於UnityEditor命名空間因此對於C#腳本你需要在腳本開始位置添加“usingUnityEditor”
這些工作的非常像普通的GUI函數,在EditorGUILayout中也有相同實現
類變量
static var actionKey : bool
描述:平台相關的"action"調整鍵被按下(只讀)
Mac OS X為 Command, Windows上為Control
類方法
◆static function ColorField (position : Rect, value : Color) : Color
◆static function ColorField (position : Rect, label : string, value : Color) : Color
◆static function ColorField (position : Rect, label : GUIContent, value : Color) : Color
參數
position 屏幕上用於域的矩形區域
label 顯示在該域前面的可選標籤
value 用於編輯​​的顏色
返回:Color – 用戶選擇的顏色
描述:製作一個用來選擇Color的域
◆static function DrawTextureAlpha (position : Rect, image : Texture, scaleMode : ScaleMode = ScaleMode.StretchToFill, imageAspect : float) : void
參數
position 屏幕上用來繪製紋理的矩形區域
image 顯示的Texture
scaleMode 當紋理的長寬比不適合繪製的長寬比時如何縮放這個圖片
alphaBlend 是否用alpha 混合顯示圖片(默認)如果為假,圖片將繪製到屏幕
imageAspect 用於源圖像的寬高比,如果為0(默認),使用來自圖片的寬高比
描述:在一個矩形中繪製紋理的alpha通道
參見: GUI.color, GUI.contentColor
◆static function EnumPopup (position : Rect, selected : System.Enum, style : GUIStyle = EditorStyles.popup) : System.Enum
◆static function EnumPopup (position : Rect, label : string, selected : System.Enum, style : GUIStyle = EditorStyles.popup) : System.Enum
◆static function EnumPopup (position : Rect, label : GUIContent, selected : System.Enum, style : GUIStyle = EditorStyles.popup) : System.Enum
參數
position 屏幕上用來繪製紋理的矩形區域
label 該域前面可選的標籤
selected 該域顯示的選項
style 可選的GUIStyle.
返回:float- 被用戶選擇的選項
描述:製作一個彈出式選擇域
使用當前選擇的值作為參數並返回用戶選擇的值
◆static function FloatField (position : Rect, value : float, style : GUIStyle = EditorStyles.numberField) : float
◆static function FloatField (position : Rect, label : string, value : float, style : GUIStyle = EditorStyles.numberField) : float
◆static function FloatField (position : Rect, label : GUIContent, value : float, style : GUIStyle = EditorStyles.numberField) : float
參數
position 屏幕上用來浮點值的矩形區域
label 顯示在浮點域前面的可選標籤
value 該域顯示的選項
style 可選的GUIStyle.
返回:float- 被用戶輸入的值
描述:製作一個文本域以便輸入浮點值
◆static function Foldout (position : Rect, foldout : bool, content : string, style : GUIStyle = EditorStyles.foldout) : bool
◆static function Foldout (position : Rect, foldout : bool, content : GUIContent, style : GUIStyle = EditorStyles.foldout) : bool
參數
position 屏幕上用於箭頭和標籤的矩形區域
foldout 顯示折疊狀態
content 顯示的標籤
style 可選的GUIStyle.
返回:bool- 用戶選擇的折疊狀態,如果為真,應該渲染子對象
描述:製作一個左側帶有折疊箭頭的標籤
這個可以用來創建一個樹或則文件夾結構,這裡子對像只在父展開的時候顯示
◆ static function InspectorTitlebar (position : Rect, foldout : bool, targetObj : Object) : bool
參數
position 屏幕上用於標題欄的矩形區域
foldout 顯示折疊狀態
targetObj 使用該標題欄的對象
返回:bool- 用戶選擇的折疊狀態
描述:製作一個檢視窗口標題欄
該標題欄有一個折疊箭頭,一個幫助圖標和設置菜單,設置菜單以來於所提供對像類型
◆static function IntField (position : Rect, value : int, style : GUIStyle = EditorStyles.numberField) : int
◆static function IntField (position : Rect, label : string, value : int, style : GUIStyle = EditorStyles.numberField) : int
◆static function IntField (position : Rect, label : GUIContent, value : int, style : GUIStyle = EditorStyles.numberField) : int
參數
position 屏幕上用於整型域的矩形區域
label 顯示在該整型域前面的可選標籤
value 用於編輯​​的值
style 可選的GUIStyle.
返回:int- 用戶輸入的值
描述:製作一個文本域以便輸入整數
◆static function IntPopup (position : Rect, selectedValue : int, displayedOptions : string[], optionValues​​ : int[], style : GUIStyle = EditorStyles.popup) : int
◆static function IntPopup (position : Rect, selectedValue : int, displayedOptions : GUIContent[], optionValues​​ : int[], style : GUIStyle = EditorStyles.popup) : int
◆static function IntPopup (position : Rect, label : string, selectedValue : int, displayedOptions : string[], optionValues​​ : int[], style : GUIStyle = EditorStyles.popup) : int
◆static function IntPopup (position : Rect, label : GUIContent, selectedValue : int, displayedOptions :
GUIContent[], optionValues​​ : int[], style : GUIStyle = EditorStyles.popup) : int
參數
position 屏幕上用於域的矩形區域
label 可選標籤
selectedValue 顯示的選項的值
displayedOptions 一個帶有顯示X選項的數組,用戶可以選擇
optionValues​​ 一個為每個選項存儲值的數組
style 可選的GUIStyle.
返回:int- 被用戶選擇的值
描述:製作一個整形彈出式選擇域
只用當前選擇的整數作為參數並返回用戶選擇的整數
◆static function IntSlider (position : Rect, value : int, leftValue : int, rightValue : int) : int
◆static function IntSlider (position : Rect, label : string, value : int, leftValue : int, rightValue : int) : int
◆static function IntSlider (position : Rect, label : GUIContent, value : int, leftValue : int, rightValue : int) : int
參數
position 屏幕上用於滑竿的矩形區域
label 該滑竿前面可選擇的標籤
value 滑竿顯示的值
leftValue 滑竿左端值
rightValue 滑竿右端值
返回:int- 用戶設置的值
描述:製作一個可以拖動的滑竿,可以在min和max之間設置參數
◆ static function LabelField (position : Rect, label : string, label2 : string) : void
參數
position 屏幕上用於標籤域的矩形區域
label 前面的標籤
label 右側的標籤
描述:製作一個標籤域(用來顯示只讀信息)
◆static function LayerField (position : Rect, layer : int, style : GUIStyle = EditorStyles.popup) : int
◆static function LayerField (position : Rect, label : string, layer : int, style : GUIStyle = EditorStyles.popup) : int
◆static function LayerField (position : Rect, label : GUIContent, layer : int, style : GUIStyle = EditorStyles.popup) : int
◆ staticfunctionLayerField(position:Rect,label:GUIContent,Layer:ini,styleGUIStyle=EditorStyles.popup):int
參數
Position 屏幕上用於域的矩形區域
Label 該域前面可選的標籤
layer 顯示在該域中的層
返回:int 用戶選擇的層
描述:製作一個層選擇域
◆ static function ObjectField(position : Rect,obj : Object,objType : System Type) : Object
◆ Static function ObjectField (position : Rect, label : string, obj : Object, objType System.Type) : Object
◆ Static function ObjectField(position : Rect,label : GUIContent,obj : Object,objType : System.Type):Object
參數
Position 屏幕上用於域的矩形區域
Label 該區前面可選的標籤
Obj 該域顯示的對象
objType 對象的類型
返回:Object 被用戶設置的對象
描述:製作一個物體放置的槽域
◆ Static function PasswrodField (position : Rect,password : string,style : GUIStyle= EditorStyles.textField) : string
◆ Static function PasswordField (position : Rect,label : string,password : string,style : GUIStyle=EditorStyles.textField) : string
◆ Siatic function PasswordField(position : Rect,label:GUIConient,password : string,style : GUIStyle = EditorStyle.textField) “ string
參數
Position 屏幕上用於密碼域的矩形區域
Label 顯示在該密碼域前面的可選標籤
Password 用於編輯​​的密碼
Style 可選的GUIStyle
返回:string- 用​​戶輸入的密碼
描述:製作一個用戶可以輸入密碼的文本域
這個就像GUI.PasswordField, 但是正確的響應所有選擇,在編輯器中,可以有一個可選的標籤在前面。
◆ static function Popup (position : Rect, selectedIndex : int, displayedOptions : string[], style : GUIStyle = EditorStyles.popup) : int
◆ static function Popup (position : Rect, selectedIndex : int, displayedOptions : GUIContent[],
◆ style : GUIStyle = EditorStyles.popup) : int
static function Popup (position : Rect, label : GUIContent, selectedIndex : int, displayedOptions : GUIContent[], style : GUIStyle = EditorStyles.popup) : int
參數
Position 屏幕上用於域的矩形區域
Label 該域前面可選的標籤
selectedIndex 該域顯示的選項的索引
displayedOptions 顯示在彈出菜單中的選項數組
style 可選的GUIStyle
返回:int-被用戶選擇的選項的索引
描述:製作一個哦他能夠用的彈出式選擇域
使用當前選擇的索引作為參數並返回用戶選擇的索引
aaa1218bbb
aaa1218bbb
社員
社員

文章數 : 65
積分 : 4726
注冊日期 : 2011-11-22

https://design.666forum.com

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章