Why is GUI texture not showing on mouse over in build?

I have buttons in my main menu which would change texture upon mouse over. The changing of the textures on mouse over works fine in the editor. But after build, the textures do not show at all when the button is moused over. It is simple a blank button. I know the button is still there because I am able to click on it and it will execute a function.

This is how I have done it in code.


void Start()
{
PathStartBtn1 = “Assets/Textures/Buttons/Start_Default.png”;
PathStartBtn2 = “Assets/Textures/Buttons/Start_MouseOver.png”;
Tex2D_StartBtn1 = (Texture2D)Resources.LoadAssetAtPath(PathStartBtn1, typeof(Texture2D));
Tex2D_StartBtn2 = (Texture2D)Resources.LoadAssetAtPath(PathStartBtn2, typeof(Texture2D));
}

void OnMouseEnter()
{
gameObject.guiTexture.texture = Tex2D_StartBtn2 ;
}

void OnMouseExit()
{
gameObject.guiTexture.texture = Tex2D_StartBtn1 ;
}

The funny thing is the original texture for the button does show up when the game starts. Only when the cursor goes over it, it simply disappears.

Please help… Anyone?

Okay, So I finally figured it out. These are the things you should be aware of when using GUItexture and accessing assets from folders.

  1. DO NOT USE Resource.LoadAssetAtPath() . It may work on some build but I realized that it is an Editor-Only function, which means it will always work in the editor but it MAY NOT WORK in the build itself.
  2. Use Resource.Load(“SomeAsset”) instead.
  3. The folder in which you can access your assets MUST be in a folder named “Resources”. You could also put sub-folders into this folder. Simple use the forward slash in your path. For example, “Buttons/SomeAsset”.
  4. And lastly, which is the most crucial of course… DO NOT leave the extension in your path. For my case, I would use Resource.Load(“Buttons/Start_Selected”), instead of “Buttons/Start_Selected.png”. This is the main culprit of why the Load function returned a Null in the build.

Hope this will helped somebody. Cheers!