Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hudechek · Jun 17, 2014 at 03:29 AM · mmo

Im not understanding the errors im getting in my script

So basically I'm building a inventory script and I'm not totally done but i keep getting unexpected symbol errors all over specifically:

Error CS1525: Unexpected symbol 'private' Error CS1525: Unexpected symbol ';', expecting ')' or ',' Error CS1525: Unexpected symbol 'GUILayout'

I can't find the problem i have look every where in the script! here it is all help is super appreciated :)

using UnityEngine; using System.Collections;

public class Inventory : MonoBehaviour {

 private bool inventorywindowtoggle = false;
 private Rect inventorywindowrect = new Rect (300, 100, 400, 400);
 private dictonary <int,string>    inventoryNameDictonary;


 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }

 //inventory show mechanic
 void OnGUI() 
 {
     inventorywindowtoggle = GUI.Toggle(new Rect (800,50,100,50), inventorywindowtoggle, "inventory");

     if(inventorywindowtoggle) 
         inventorywindowrect = GUI.Window(0, inventorywindowrect, inventorywindowmethod, "inventory");

 }

 void inventorywindowmethod (int methodID)
 {
     //Dictonary
      private dictonary <int, string>    inventoryNameDictonary = new dictonary<int,string>()
     {
     {0, string.Empty},
     {1, string.Empty},
     {2, string.Empty},
     {3, string.Empty},
     {4, string.Empty},
     {5, string.Empty},
     {6, string.Empty},
     {7, string.Empty},
     {8, string.Empty},
     {9, string.Empty},
     {10, string.Empty},
     {11, string.Empty},
     {12, string.Empty},
     {13, string.Empty},
     {14, string.Empty},
     {15, string.Empty}
     }


     //Items
     ItemClass swordItem = new ItemClass (0,"Sword", SwordIcon, "Standard Sword nothing Special");
     ItemClass staffItem = new ItemClass (1,"Mage Staff", StaffIcon, "Standard Staff for Wizard things");
     ItemClass sheildItem = new ItemClass (2,"Sheild", SheildIcon, "Standard Metal Sheild to help prevent death");

     //Display Dictionary
     inventoryNameDictonary[0] = swordItem.name;
     inventoryNameDictonary[1] = staffItem.name;
     inventoryNameDictonary[2] = sheildItem.name;

     //Inventory layout
     GUILayout.BeginArea (new Rect (5,50,395,400));

     GUILayout.BeginHorizontal ();
     GUILayout.Button (inventoryNameDictonary[0], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[1], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[2], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[3], GUILayout.Height (50));
     GUILayout.EndHorizontal ();

     GUILayout.BeginHorizontal ();
     GUILayout.Button (inventoryNameDictonary[4], GUILayout.Height ((50));
     GUILayout.Button (inventoryNameDictonary[5], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[6], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[7], GUILayout.Height (50));
     GUILayout.EndHorizontal ();

     GUILayout.BeginHorizontal ();
     GUILayout.Button (inventoryNameDictonary[8] GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[9], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[10], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[11], GUILayout.Height (50));
     GUILayout.EndHorizontal ();

     GUILayout.BeginHorizontal ();
     GUILayout.Button (inventoryNameDictonary[12], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[13], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[14], GUILayout.Height (50));
     GUILayout.Button (inventoryNameDictonary[15], GUILayout.Height (50));
     GUILayout.EndHorizontal ();

     GUILayout.EndArea ();
 }

 public class ItemClass
 {
     int id;
     string name;
     Texture2D icon;
     string discription;

     public ItemClass (int ide, string nam, Texture2D ico, string dis)
     {
     id = ide;
     name = nam;
     icon = ico;
     discription = dis;

     }
 
         


 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by supernat · Jun 17, 2014 at 03:57 AM

You have many issues. You need to add "using System.Collections.Generic;" because Dictionary only exists in this package. You're typing lower case dictionary instead of Dictionary. In several places, dictionary is misspelled. You can't declare a variable inside a method as private. You're missing semicolons at the end of some of your closing brackets for your variables. And you're missing closing parenthesis in several places. Once you clear some of these, the IDE will seem to provide more useful input to you.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hudechek · Jun 17, 2014 at 04:43 PM 0
Share

Were would I place the Dictionary if not in the method? Can I place it with the Update, i guess that might make since since it needs to update based on the item attributes it is looking at but I'm not totally sure sorry for all the questions.

avatar image tanoshimi · Jun 17, 2014 at 06:17 PM 0
Share

You can have the Dictionary inside inventorywindowmethod, no problem. But don't declare a local variable there with private Dictionary because you already declared a global Dictionary with the same name at the top of the script. To intialise it in inventorywindowmethod, you just need

 inventoryNameDictonary = new Dictionary()<int,string>() { ... }

And please be careful with your spelling and attention to capitalisation etc. - you're going to run into a lot of problems otherwise.

avatar image hudechek · Jun 17, 2014 at 07:46 PM 0
Share

Oh awesome thanks! and ya following someones how to guide kinda confused me I'm just going to start reading c# books ins$$anonymous$$d

avatar image hudechek · Jun 18, 2014 at 04:15 PM 0
Share

Awesome thanks you so much man! haha ill go back through I didn't know I needed the Systems.Collections.Generic im just learning coding and some of the tutorials im using arnt very specific on case sensitivey and stuff.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Animation spins wildly after completed 0 Answers

hide object start script 4 Answers

Flashlight Blink? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges