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 YayGee · Jul 03, 2013 at 06:39 PM · gameinventoryinventory system

Inventory question

I have been watching this unity tutorial on Youtube where you learn how to make an inventory. Everything has been going well until I watched Episode 7. I just can't understand what I did wrong. I can't see any difference with his script and my script. http://www.youtube.com/watch?v=rJZrhEl5V58&list=PLxLNqnnCshwm9ayxqMpeWH4P1SLzrN92- I know which part of the script is wrong, but I posted the whole script anyway.

 import System.Collections.Generic;
 
 //holding all our items
 var items : Item[];
 //inventory
 var MainInventory : List. <Item> = new List.<Item>();
 
 //Equip menu ( 0=hat, 1=helmet, 2= shoulders, 3=gloves, 4=pants, 5=boots, 6=ring, 7= neckless)
 var EquipMenu : Item[];
 
 function Start () {
     
     MainInventory.Add(items[0]);
     MainInventory.Add(items[1]);
 }
 
 
 function OnGUI () {
     
     for (var x = 0; x < MainInventory.Count; x++) {
     
         if(GUI.Button(Rect(Screen.width/2, Screen.height/ 2 + ( 20 * x),100,20), GUIContent ( MainInventory[x].Name,
         "Stanima: " + MainInventory[x].Stamina + "\n" +
         "Power: " + MainInventory[x].Power + "\n" +
         "Attack Speed: " + MainInventory[x].attackSpeed + "\n" +
         "Rarity: " + MainInventory[x].rarity))) {
         
             if (MainInventory[x].itemType == MainInventory[x].itemType.helmet) {
                      
                 EquipMenu[0] = MainInventory[x];
                 MainInventory.RemoveAt(x);
                 }
                 else if (MainInventory[x].itemType == MainInventory[x].itemType.shoulders) { 
                     EquipMenu[1] = MainInventory[x];
                     MainInventory.RemoveAt(x);        
                 }                                                
         }
         GUI.Label(Rect(Screen.width/2 + 70, Screen.height/ 2 + ( 20 * x),300,300), GUI.tooltip);
     }
     for (var y = 0; y < EquipMenu.length; y++) {
         
         if (EquipMenu[y] != null);
             
             if(GUI.Button(Rect(Screen.width/2 - 150, Screen.height/ 2 + ( 20 * y),100,20), "" + EquipMenu[y].name)) {
                 
                 MainInventory.Add(EquipMenu[y]);
                 EquipMenu[y] = null;
                 }
             }
         }

Note: I know that I did the second script right because it otherwise wouldn't work in the previous videos in the tutorial if I wrote it wrong.

Comment
Add comment · Show 3
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 iwaldrop · Jul 03, 2013 at 07:13 PM 0
Share

Are you getting a compile error?

avatar image YayGee · Jul 04, 2013 at 12:18 AM 0
Share

No, this is the error: Assets/Inventory/Inventory.js(22,101): BCE0004: Ambiguous reference 'constructor': UnityEngine.GUIContent.constructor(UnityEngine.Texture, String), UnityEngine.GUIContent.constructor(String, String), UnityEngine.GUIContent.constructor(String, UnityEngine.Texture).

avatar image iwaldrop · Jul 04, 2013 at 12:20 AM 0
Share

Well, that is a compile error, and it makes sense if $$anonymous$$ainInventory[x].Name is a String and not a Texture. That error is telling you everything you need to know. You need to pass a Texture, not a String, as the first parameter of GUIContent().

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Oribow · Jul 04, 2013 at 11:53 AM

Translate import System.... to using System.... in the first line

Comment
Add comment · 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

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

AI enemy scripting help 1 Answer

Inventory, simple and easy 5 Answers

Scripting error #2! 2 Answers

Issues with Inventory script 0 Answers


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