Version: 5.5 (switch to 5.6b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorGUIUtility.FindTexture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function FindTexture(name: string): Texture2D;
public static Texture2D FindTexture(string name);

Description

Get a texture from its source filename.


Checks the path of a texture.

// Simple editor window that lets you quick check a path of
// a texture in your project instead of waiting for 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"); } } }
// 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."); } } }

Note: This function is used for searching for editor icons only.