Version: 2023.1
public static Texture2D FindTexture (string name);

描述

从源文件名中获取纹理。

\ 检查纹理的路径。

// Simple editor window that lets you quick check a path of
// a texture in the editor.
//
// If the path exists then it shows a message
// else displays an error message

using UnityEngine; using UnityEditor;

public class FindTextureExample : EditorWindow { string s;

[MenuItem("Examples/Find editor texture")] static void findTextureExample() { FindTextureExample window = EditorWindow.GetWindow<FindTextureExample>(true); window.Show(); }

void OnGUI() { s = EditorGUILayout.TextField("Texture To Locate:", s);

if (GUILayout.Button("Check")) if (EditorGUIUtility.FindTexture(s)) { Debug.Log("Texture found at: " + s); } else { Debug.Log("No texture found at: " + s + ". Check your filename."); } } }

**注意:**此函数仅用于搜索编辑器图标。