- Home /
How do I correct the following error on the Lerpz Tutortial GUI
The GUI Script runs but does not display the buttons correctly and gives me this error -
MissingMethodException: Method not found: 'UnityEngine.GUI.button'. Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices+c_AnonStorey12.<>m_6 () Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) StartMenuGUI.OnGUI () (at Assets/StartMenuGUI.js:22)
Here is my script (The error is on line 22)-
//Make the script also execute in edit mode
@script ExecuteInEditMode()
var gSkin : GUISkin;
var backdrop : Texture2D; //our backdrop image goes here.
private var isLoading = false; //if true, we'll display the "Loading..." message.
function OnGUI()
{
if (gSkin)
GUI.skin = gSkin;
else
Debug.Log("StartMenuGUI : GUI Skin object missing!");
var backgroundStyle : GUIStyle = new GUIStyle();
backgroundStyle.normal.background = backdrop;
GUI.Label ( Rect((Screen.width - (Screen.height * 2)) * 0.75, 0, Screen.height * 2, Screen.height), "", backgroundStyle);
GUI.Label ( Rect((Screen.width/2)-197,50,400,100), "Lerpz Escapes", "mainMenuTitle");
if(GUI.button( Rect((Screen.width/2)-70, Screen.height -160,140,70),"Play"))
{
isLoading = true;
Application.LoadLevel("TheGame");
}
var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer);
if(!isWebPlayer)
{
if(GUI.Button( Rect((Screen.Width/2)-70, Screen.height -80,140,70), "Quit")) Application.Quit();
}
if(isLoading)
{
GUI.Label ( Rect((Screen.width/2)-110, (Screen.height/2) -60,400,70), "Loading...", "mainMenuTitle");
}
}
If anyone can tell me what the error means and what I should be looking for to fix it that would be great.
Thank you!
Answer by Julien-Lynge · Aug 13, 2011 at 08:03 PM
Looks like capitalization to me :). I don't know anything about GUI.buttons, but I do know that GUI.Buttons work.
Thank you very much NOAA_Julien!!! $$anonymous$$y GUI is up and running. This is my second attempt at a GUI, so thanks again for the look and answer!