(GUI problems I think) Tons of errors somebody who can help?...

Code where things go wrong and errors

		GUI.Label (new Rect(10,10,50,25),"Name:");
		_toon.Name = GUI.TextArea(new Rect(65,10,100,25),_toon.Name);
		
		
		for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
		GUI.Label(new Rect(10,40(cnt + 25),100,25),((AttributeName)cnt).ToString());
		GUI.Label(new Rect(115,40(cnt + 25f),30,25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue);}
		GUI.Button(new Rect(150,40,25,25),"+");
		GUI.Button(new Rect(150,40,25,25),"-");
			
		GUI.Label(new Rect(250,10,100,25),"Points left:" + pointsLeft.ToString());

What is it supposed to do
So what this supposed to do is takes all from the Enum of AttributeName and then align the labels so it looks good. and I get a tons of errors.
Well there are no errors on the other scripts the whole scripts of this (Refernce to how the “_toon” is defined)

Whole script

using UnityEngine;
using System.Collections;
using System;

public class CharacterGenerator : MonoBehaviour {
	private PlayerChar _toon;
	private const int exp = 350;
	private const int min_att = 10;
	private int pointsLeft;
	
	// Use this for initialization
	void Start () {
		_toon = new PlayerChar();
		_toon.Awake ();
		for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
			_toon.GetPrimaryAttribute(cnt).BaseValue = min_att;
		
		pointsLeft = exp;
		}
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnGUI(){
		//Remake this for necromancy
		GUI.Label (new Rect(10,10,50,25),"Name:");
		_toon.Name = GUI.TextArea(new Rect(65,10,100,25),_toon.Name);
		
		
		for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
		GUI.Label(new Rect(10,40(cnt + 25),100,25),((AttributeName)cnt).ToString());
		GUI.Label(new Rect(115,40(cnt + 25f),30,25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue);}
		GUI.Button(new Rect(150,40,25,25),"+");
		GUI.Button(new Rect(150,40,25,25),"-");
	
		GUI.Label(new Rect(250,10,100,25),"Points left:" + pointsLeft.ToString());
		
	}
	
}

the PlayChar is my character base which compiles without error too. Thus that shouldn’t be the problems.


Only looked at one error and found this in your Code:

// 5 parameters
new Rect(10,40,(cnt + 25),100,25)

// missing operator
new Rect(150,40(cnt + 25),25,25)

Thank you…14 to go I’ve been working on this can’t find it x-x

The answer Marrrk supplied should have fixed all the errors.
You are used 5 variables for a rectangle instead of 4.

GUI.Label(new Rect(10,40,(cnt + 25),100,25),((AttributeName)cnt).ToString());
GUI.Label(new Rect(115,40,(cnt + 25f),30,25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue);}
GUI.Button(new Rect(150,40,(cnt + 25),25,25),"+");
GUI.Button(new Rect(150,40,(cnt*25),25,25),"-");

Replace that with this:

GUI.Label(new Rect(10,40(cnt + 25),100,25),((AttributeName)cnt).ToString());
GUI.Label(new Rect(115,40(cnt + 25f),30,25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue);}
GUI.Button(new Rect(150,40(cnt + 25),25,25),"+");
GUI.Button(new Rect(150,40(cnt*25),25,25),"-");

Im guessing you wanted the “(cnt + 25)” multiplyed

10 error left, I’ll update the orginal post.

But still the same error I pointed out. djfunky did replicate the error:

40(cnt + 25)

is not usable, there is still an operator missing between the 40 and the (

40 operator? (cnt + 25)

for example:

40 * (cnt + 25)

But I guess you meant this:

40 + cnt * 25

Your errors are saying that your “cnt” hasn’t had a number assigned to it yet, so maybe the problem is with the loop? :face_with_spiral_eyes:
Try replacing part of the loop with this:

cnt <= Enum.GetValues(typeof(AttributeName)).Length

I thought Unity automatically multiplied it by expanding the bracket, thanks for pointing that out Marrrk.
You learn a new thing each day :smile:

Sorry missunderstood now theres only:
CharacterGenerator.cs(36,21): error CS1503: Argument #2' cannot convert int’ expression to type string' and CharacterGenerator.cs(36,21): error CS1502: The best overloaded method match for UnityEngine.GUI.Label(UnityEngine.Rect, string)’ has some invalid arguments
to fix?
or did I overlook that too?

It just means that there is something wrong with this part of line 36

_toon.GetPrimaryAttribute(cnt).AdjustedBaseValue

I don’t know about the script you have, but the “.AdjustedBaseValue” needs to return a string, and by the looks of the errors, it isn’t
Possibly try:

_toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString()

Okey no errors but it confuses me how …AdjustedBaseValue.ToString(); doesn’t work when AdjustedBaseValue + “” works?
THANKS A LOT!

Internally AdjustedBaseValue + “” will become AdjustedBaseValue.ToString() + “”

Ah okey. New problem it seems to loop into infinity…Nothing showed up when I pressed play!..I tried make it debug and paste to log. Seems like it get the strings it should thus it doesn’t show up probably beacause it keep infinity. Any help?