I’m having troubles telling an external component to do something from another script. Here’s the lowdown.
The game I am working on has the ability to switch UI skins through one of the options menus. To accomplish this, I have one game object that persists through all levels. This game object is named Skin. It holds the variable for which skin was last set to use for the entire game. The game object has an attached script named SetSkin that reads as follows:
public var customSkin : GUISkin;
function Start () {
GUI.skin = customSkin;
}
function GetSkin(){
return customSkin;
}
Each scene of the game has its own menu object and script that calls upon the persistent Skin object to find out which skin to use.
var currentSkin : GUISkin;
function Start(){
skinObject = GameObject.Find("Skin");
skinComponent = skinObject.GetComponent(SetSkin);
currentSkin = skinComponent.GetSkin();
}
function OnGUI () {
GUI.skin = currentSkin;
//do menu stuff here.
}
This method of calling upon the Skin object’s currently active GUISkin works wonderfully in Unity. However, as soon as I bring this code into Unity iPhone, every menu object returns the error
‘GetSkin’ is not a member of ‘UnityEngine.Component’.