im having problems with my a function i created…
its to draw menu function…
where there is no errors only on that part( function DrawMenu)…
here’s the full script…
i converted it from C#…
#pragma strict
private enum MenuMode{
MENU_OFF,
BUTTON1 ,
BUTTON2
}
private var areaRect : Rect;
private var _Show : boolean = false;
private var ShowMenu = MenuMode.MENU_OFF;
function Start(){
var width : int = Screen.width;
var height : int = Screen.height/5;
var areaLeft : float = 0;
var areaTop = Screen.height - height;
areaRect = new Rect(areaLeft,areaTop,width,height);
}
function Update(){
if( _Show == false)
if(Input.GetMouseButtonUp(0)){
DrawMenu();
}
}
function OnGUI(ShowMenu : MenuMode){
switch (ShowMenu){
case MenuMode.BUTTON1:
DrawMenu();
break;
case MenuMode.BUTTON2:
DrawMenu();
break;
default:
break;
}
function DrawMenu (){ //this is the error occurred
var buttonGroupStyle : GUIStyle = new GUIStyle(GUI.skin.button) ;
buttonGroupStyle.stretchWidth = true;
buttonGroupStyle.stretchHeight = true;
GUILayout.BeginArea(areaRect);
GUILayout.BeginHorizontal(buttonGroupStyle);
if(GUILayout.Button("BUTTON 1", buttonGroupStyle)){
}
ShowMenu = MenuMode.MENU_OFF;
_Show = true;
if(GUILayout.Button("BUTTON 2", buttonGroupStyle)){
}
ShowMenu = MenuMode.MENU_OFF;
_Show = true;
if(GUILayout.Button("BUTTON 3", buttonGroupStyle)){
}
ShowMenu = MenuMode.MENU_OFF;
_Show = true;
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
#the area where function DrawMenu originally looks like this in C#…
private void DrawMenu()
{
// Setup style for buttons.
GUIStyle buttonGroupStyle = new GUIStyle(GUI.skin.button);
buttonGroupStyle.stretchWidth = true;
buttonGroupStyle.stretchHeight = true;
GUILayout.BeginArea(mAreaRect);
GUILayout.BeginHorizontal(buttonGroupStyle);
// Turn flash on or off.
if (GUILayout.Button("Toggle Flash", buttonGroupStyle))
{
if (!mFlashEnabled)
{
// Turn on flash if it is currently disabled.
this.GetComponent<CameraDeviceBehaviour>().SetFlashTorchMode(true);
mFlashEnabled = true;
}
else
{
// Turn off flash if it is currently enabled.
this.GetComponent<CameraDeviceBehaviour>().SetFlashTorchMode(false);
mFlashEnabled = false;
}
mMenuToShow = MenuMode.MENU_OFF;
mButtonPressed = true;
}
// Turn auto focus on or off.
if (GUILayout.Button("Autofocus", buttonGroupStyle))
{
if (!mAutoFocusEnabled)
{
// Turn on flash if it is currently disabled.
this.GetComponent<CameraDeviceBehaviour>().StartAutoFocus();
mAutoFocusEnabled = true;
}
else
{
// Turn off flash if it is currently enabled.
this.GetComponent<CameraDeviceBehaviour>().StopAutoFocus();
mAutoFocusEnabled = false;
}
mMenuToShow = MenuMode.MENU_OFF;
mButtonPressed = true;
}
// Choose focus mode.
if (GUILayout.Button("Focus Modes", buttonGroupStyle))
{
mMenuToShow = MenuMode.MENU_FOCUS_MODES;
mButtonPressed = true;
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
p/s : the errors that occurred is related on the (function DrawMenu)… its like missing some codes or something…
how to solve this…
please help…
thank you…