Why am I getting a cannot convert error?


I’m trying to implement a GUIskin into my game, but i keep getting a cannot convert error.

The exact error is “Assets/Scripts/GUISkin.js(6,20): BCE0022: Cannot convert ‘GUISkin’ to ‘UnityEngine.GUISkin’.”
Below is my code.

#pragma strict
var mySkin : GUISkin;

function OnGUI () {
	// Assign the skin to be the one currently used.
	GUI.skin = mySkin;

	// Make a button. This will get the default "button" style from the skin assigned to mySkin.
	GUI.Button (Rect (10,10,150,20), "Skinned Button");

I don’t understand why I am getting this error. The syntax appears to be correct.


Have you created a custom script called GUISkin.js? It looks like Unity is having a hard time deciding whether you want to use your custom GUISkinversus UnityEngine’s built int GUISkin. (When you create a .js file you create a new type of that name…so when you make GUISkin.js you define a new type called GUISkin)

To solve this, change your GUISkin.js to something else, perhaps ChangeGUI.js or something