EventKeyboardEvent and GUI

Page 1 of 1

1 Replies - 1119 Views - Last Post: 09 March 2013 - 10:51 PM Rate Topic: -----

#1 TrewSx  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 07-June 12

EventKeyboardEvent and GUI

Posted 09 March 2013 - 07:45 PM

Hello could you please help me with my script, i have been trying to make it work for hours now and it's just does not work. I want to have a GUI window appear and disappear on a KeyboardEvent. When i press 'i' inventory will open and close, help me please

#pragma strict
//Inventory script 


//Inspector var
var mySkin		:	GUISkin;

var inventoryWindowHeight	:	float = 90;

var buttonWidth				:	float = 40;
var buttonHeight			:	float = 40;
var closeButtonWidth		:	float = 20;
var closeButtonHeight		:	float = 20;


//Private var
var _displayInventory	    : boolean = false;
var _offset_				:   float = 10;
private var _inventoryWindowID		:   int   = 0;
private var _inventoryWindowRect	:    Rect = new Rect(10,10,Screen.height / 2 + 10,Screen.width / 2 - 200);



function Start () {

}

function OnGUI() {
	GUI.skin = mySkin;
	
	if (Event.current.Equals (Event.KeyboardEvent ("[enter]")))
    _displayInventory = true; 
	_inventoryWindowRect = GUI.Window(_inventoryWindowID, _inventoryWindowRect, InventoryWindow, " Inventory ");	
	
	if (Event.current.Equals (Event.KeyboardEvent ("return")))
    print ("Event...");
     _displayInventory = false; 
}

function	InventoryWindow(_inventoryWindowID) {								
	GUI.skin = mySkin;
	GUI.DragWindow();
}

function ToggleInventoryWindow () {
		_displayInventory = ! _displayInventory;

	
}




Is This A Good Question/Topic? 0
  • +

Replies To: EventKeyboardEvent and GUI

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8401
  • View blog
  • Posts: 31,266
  • Joined: 12-June 08

Re: EventKeyboardEvent and GUI

Posted 09 March 2013 - 10:51 PM

Don't open duplicate topics. Keep it all on one thread. Closing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1