/// <summary> /// Loads texture at path which should be under a Resources/ folder. /// </summary> /// <param name="path">Path to texture, must be relative to a Resources/ folder.</param> /// <returns>Loaded texture or null if failed.</returns> public static Texture2D LoadTexture(string path) { if (HEU_AssetDatabase.IsPathRelativeToAssets(path) || HEU_AssetDatabase.IsPathRelativeToPackages(path) || System.IO.Path.IsPathRooted(path)) { HEU_AssetDatabase.ImportAsset(path, HEU_AssetDatabase.HEU_ImportAssetOptions.Default); return HEU_AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D; } else { // Try as relative path to Resources return Resources.Load<Texture2D>(path); } }