Texture2D.LoadImage best way to load photo texture

The documentation gives the code below as the way to dynamically load a jpg (after changing its extension to txt) into Texture2D. Is this the only way to load a jpg as a texture? If not, what is the best way.

Thanks,

Jeff

// Load a .jpg or .png file by adding .txt extensions to the file
// and dragging it on the imageTextAsset
var imageTextAsset : TextAsset;
function Start () {
var tex = new Texture2D (4, 4);
tex.LoadImage(imageTextAsset.bytes);
renderer.material.mainTexture = tex;
}

there is this one too :

Resource.Load
Loads an asset stored at path in the Resources folder.
Returns the asset at path if it can be found otherwise returns null. The path is relative to the Resources folder, extensions must be omitted. The Resources folder can be anywhere inside the Assets folder.

// Assigns a texture named "Assets/Resources/glass" to a Plane.
function Start () {
var go = new GameObject.CreatePrimitive(PrimitiveType.Plane);
go.renderer.material.mainTexture = Resources.Load("glass");
}

// Instantiates a prefab at the path "Assets/Resources/enemy".
function Start () {
var instance : GameObject = Instantiate(Resources.Load("enemy"));
}

but i’m not sure if that’s what you want, maybe you can give it a try.

also you need to put your stuff under Resources folder to use that function.