EditorGUIUtility.FindTexture 查找纹理

static function FindTexture (name : string) : Texture2D

Description描述

Get a texture from its source filename.

从源文件名获取一个纹理。

EditorGUIUtility.FindTexture 查找纹理

Checks the path of a texture.
检查纹理的路径。

// Simply editor window that lets you quick check a path of
// a texture in your project instead of waiting your code to
// compile.
//快速检测纹理的路径,而不用等待代码编译
// if the path exists then it shows a message
// else displays an error message
//如果路径存在,则显示一条消息,否则显示错误消息
class EditorGUIUtilityFindTexture extends EditorWindow {

	var path : String = "";

	@MenuItem("Examples/Check Path For Texture")
	static function Init() {
		var window = GetWindow(EditorGUIUtilityFindTexture);
		window.position = Rect(0,0,180,55);
		window.Show();
	}

	function OnGUI() {
		path = EditorGUILayout.TextField("Path To Test:", path);
		if(GUILayout.Button("Check"))
			if(EditorGUIUtility.FindTexture(path)) {
				Debug.Log("Yay!, texture found at: " + path);
			} else {
				Debug.LogError("No texture found at: " + path + " Check your path");
			}
	}
}
最后修改:2011年7月15日 Friday 10:41

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。