3 Replies - 1485 Views - Last Post: 14 March 2013 - 04:00 AM Rate Topic: -----

#1 TrewSx  Icon User is offline

  • D.I.C Head

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

GUI.Button not displaying in GUI.Window

Posted 13 March 2013 - 12:37 PM

Hello,
i would like to create a GUI.Window which will generate random loot from an Array of items. So far i got the window working but i am struggling with generating the random loot and displaying my GUI.Buttons inside GUI.window.
Could anyone pls help me to solve this problem or at least tell me what is wrong here

#pragma strict
//Loot window script

//Inspector variables
public var buttonWidth						:	float = 40;
public var buttonHeight						:	float = 40;

//Loot variables
public var lootWindowHeight					:	float = 90;
public var itemsListArray					:   Array = [1,2,3,4,5,6,7,8,9,10];


private var _lootWindowRect					:    Rect = new Rect(0,0,0,0);
private static var _lootWindowID			:   int   = 1;																				//ID number has to be Unique for each window
private static var _cnt						:   int   = 0; 									//counter valoue for FOR LOOP
private var _lootWindowOffSet	    		:   int   = 10;




function Start () {
	//Debug.Log("Array items: " + itemsListArray);
	itemsListArray = new Array (itemsListArray);
	
	Populate();
}

function OnGUI() {
	 
	_lootWindowRect = GUI.Window(_lootWindowID, new Rect(_lootWindowOffSet, Screen.height - (_lootWindowOffSet + lootWindowHeight),		//Display Loot window on a screen
	 Screen.width - (_lootWindowOffSet * 2),lootWindowHeight), LootWindow, "Loot Window");
	 
}

private function LootWindow(_lootWindowID) {								
	for(; _cnt < itemsListArray.Count; _cnt++) {
		GUI.Button(new Rect(buttonWidth * _cnt, 0, buttonWidth, buttonHeight), _cnt.ToString());
	}
}

private function Populate() {
	for(; _cnt < 10; _cnt++) {
		itemsListArray.Add(new Array([_cnt]));
		//Debug.Log(_cnt + " -- " + itemsListArray);
	}
}


Is This A Good Question/Topic? 0
  • +

Replies To: GUI.Button not displaying in GUI.Window

#2 TrewSx  Icon User is offline

  • D.I.C Head

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

Re: GUI.Button not displaying in GUI.Window

Posted 13 March 2013 - 03:16 PM

problem fixed
Was This Post Helpful? 0
  • +
  • -

#3 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2087
  • View blog
  • Posts: 3,175
  • Joined: 21-June 11

Re: GUI.Button not displaying in GUI.Window

Posted 14 March 2013 - 03:51 AM

When asking a question in the Other Languages forum, please mention which language you're asking about - preferably in the title of your thread.

This post has been edited by sepp2k: 14 March 2013 - 03:52 AM

Was This Post Helpful? 0
  • +
  • -

#4 TrewSx  Icon User is offline

  • D.I.C Head

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

Re: GUI.Button not displaying in GUI.Window

Posted 14 March 2013 - 04:00 AM

yeah i should have done it, i will remember that for next time
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1