x


dosent work

hi community i wrote this script but it dosent update the text in the grid buttons do you have any ideas why this could happen? heres the code:

using UnityEngine; using System.Collections; using System.Collections.Generic;

public class TutorialInventar : MonoBehaviour {

public Rect [] gridRects= new Rect[50];

public int countRects=0;

Dictionary items = new Dictionary();

public string[] showNamesInGrid= new string[50];

int countItems=0;

void AddItems(){

items.Add("schwert","Schwert"); items.Add ("schild","Schild");

}

void OnGUI(){

for( int y=0; y<10; y++){ for(int x =0; x<5; x++){

if(countRects<49){

countRects++;

}

gridRects[countRects]= new Rect(0+60*x,0+60*y,60,60);

GUI.Button (new Rect(gridRects[countRects]),showNamesInGrid[countRects]);

} }

if(GUI.Button (new Rect(300,300,60,60),"schwert")){

countItems++; showNamesInGrid[countItems]=items["schwert"];

} }

void Start(){

AddItems ();

}

}

more ▼

asked Jul 11 '12 at 11:18 AM

Driseus gravatar image

Driseus
35 1

Here is the formatted code.

First, there's a problem with your Dictionary declaration - you have to specify what types the key and value of the dictionary are.

Jul 11 '12 at 02:04 PM asafsitner

Please, do not post questions which are named "doesn't work" and please format your code.

Jul 11 '12 at 02:58 PM TowerOfBricks

Also, if you happen to post a question named "doesn't work", at least spell it correctly.

Jul 11 '12 at 02:59 PM TowerOfBricks
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x295
x109
x22

asked: Jul 11 '12 at 11:18 AM

Seen: 245 times

Last Updated: Jul 11 '12 at 02:59 PM