通用文件夾使用要求
Editor文件夾
由于unity是分別編譯的,會生成不同的dll文件,比如: Assembly-CSharp.dll,Assembly-CSharp-Editor.dll,所以通常要把編輯器相關(guān)代碼寫到Editor名字命名的文件夾下。
比如
Assets/Editor
Assets/MyFolder/Scripts/Editor
Assets/Standard Assets/Editor
UNITY_EDITOR
#if UNITY_EDITOR
該寫法通常用于包裹編輯器腳本:
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class NewBehaviourScript : MonoBehaviour
{
void OnEnable ()
{
#if UNITY_EDITOR
EditorWindow.GetWindow<ExampleWindow> ();
#endif
}
}
Editor Default Resources
類似Resources文件夾,提供給EditorGUIUtility.Load調(diào)用

Editor Default Resources.png
var tex = EditorGUIUtility.Load ("logo.png") as Texture;
內(nèi)置資源
編輯器默認(rèn)的資源文件可由EditorGUIUtility.GetEditorAssetBundle獲取
[InitializeOnLoadMethod]
static void GetBultinAssetNames ()
{
var flags = BindingFlags.Static | BindingFlags.NonPublic;
var info = typeof(EditorGUIUtility).GetMethod ("GetEditorAssetBundle", flags);
var bundle = info.Invoke (null, new object[0]) as AssetBundle;
foreach (var n in bundle.GetAllAssetNames()) {
Debug.Log (n);
}
}