Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Sep 20, 2015 at 02:56 PM by Graham-Dunnett.
avatar image
1
Question by Whizzo13 · Sep 20, 2015 at 02:55 PM · variablesif-statementsinventory systembce0051

Unity thinks one of my variables is a System.type

I am creating an inventory system and I need to find out the item type of an item but in my if statement it keeps thinking that one of my variables is a System.type when it is not it is in line 106. This is what it says : Assets/Scripts/Inventory/Inventory.js(106,83): BCE0051: Operator '==' cannot be used with a left hand side of type 'System.Type' and a right hand side of type 'Item.ItemGroup'.

import System.Collections.Generic;

     //Backdrops
     private var invBackDrop : Texture2D;
     private var equipBackDrop : Texture2D;
     //Backdrops end
     
     //Windows detail
     private var windowPosition : Vector2 = Vector2(0,0);
     private var windowSize : Vector2 = Vector2(Screen.width, Screen.height);
     //Windows detail end
     
     private var windowRectangle : Rect = new Rect(windowPosition.x, windowPosition.y, windowSize.x, windowSize.y);
     
     
     
     //GameObjects
     var player : GameObject;
     private var gameManager : GameObject;
     //GameObjects End
     
     //Script Components
     //var playerMotor : UnityStandardAssets.Characters.FirstPerson.FirstPersonController;
     private var items : ItemCreator;
     private var equipmentManager : EquipmentManager;
     //Script Components End
 
     //Main Inventory List
     var MainInventoryList : List.<Item> = new List.<Item>();
     
     private var Group : Item.ItemGroup;
     //Main Inventory List End
     
     
 
     //displaying screens
     private var display : boolean = false;
     
     //When clicking buttons to display equipment screen
     private var displayEquipScreen : boolean = false;
     
     //When clicking butttons to display inventory screen
     private var displayInvScreen : boolean = true;
 
     // Use this for initialization
     function Start () 
     {
         Screen.lockCursor = true;
         Cursor.visible = false;
     
         invBackDrop = Resources.Load("Background/InventoryBackground", Texture2D);
         equipBackDrop = Resources.Load("Background/EquipmentBackground", Texture2D);
         
         player = GameObject.FindGameObjectWithTag("Player");
         gameManager = GameObject.FindGameObjectWithTag("GameManager");
         items = gameManager.GetComponent(ItemCreator);
         equipmentManager = gameManager.GetComponent(EquipmentManager);
         
         
         
         
         //playerMotor = player.GetComponent(FirstPersonController);
         
         
     }
     
     // Update is called once per frame
     function Update () 
     {
         //when you press e it will bring up inventory screen 
         if(Input.GetKeyDown(KeyCode.E) && !display)
         {
             
             display = true;
             Screen.lockCursor = false;
             Cursor.visible = true;
             
         }else if (Input.GetKeyDown(KeyCode.E) && display)
         {
             display = false;
             Screen.lockCursor = true;
             Cursor.visible = false;
         }
         
     }    
     function OnGUI()
     {
         if(display)
         {
             if(displayInvScreen)
             {
                 if(GUI.Button(Rect(Screen.width / 2, Screen.height / 2 + 50, 120, 20), "Equipment"))
                 {
                     
                     displayEquipScreen = true;
                     displayInvScreen = false;
                 }
                 
                 GUI.DrawTexture(windowRectangle, invBackDrop, ScaleMode.StretchToFill);
                 for(var x = 0; x < MainInventoryList.Count; x++)
                 {
                     
                     if(GUI.Button(Rect(Screen.width / 2 - 350, Screen.height / 2 - (x * 50), 90, 50), GUIContent(" " + MainInventoryList[x].name , MainInventoryList[x].icon)))
                     {
                     
                     106:     if(MainInventoryList[x].ItemGroup == Group.light)
                         {
                         
                         }
                         //if(MainInventoryList[x].ItemGroup == MainInventoryList[x].ItemGroup.light)
                         //{
                         //    print("We have reached the equipment stage");
                             //This will make it so that when you equip an item to a slot that is already full then it will equip the item and get the other item and put it in the main Inventory
                         //    if(equipmentManager.equipmentList[0].equipped)
                         //    {
                         //        MainInventoryList.Add(equipmentManager.equipmentList[0]);
                         //        equipmentManager.equipmentList[0] = MainInventoryList[x];
                         //        equipmentManager.equipmentList[0].equipped = true;
                                 
                         //    }    
                                 //if there is nothing there do this
                         //        equipmentManager.equipmentList[0] = MainInventoryList[x];
                         //        MainInventoryList.RemoveAt(x);
                         //        equipmentManager.equipmentList[0].equipped = true;
                                                             
                         //}else if(MainInventoryList[x].ItemGroup.food)
                         //{
                         
                         //}
                     }
                 }
         
             }
             if(displayEquipScreen)
             {
                 GUI.DrawTexture(windowRectangle, equipBackDrop, ScaleMode.StretchToFill);
                 
                 if(GUI.Button(Rect(Screen.width / 2, Screen.height / 2 - 80, 120, 20), "Inventory"))
                 {
                     displayEquipScreen = false;
                     displayInvScreen = true;
                 }
             }
         
             if(GUI.Button(Rect(Screen.width / 2, Screen.height / 2 + 50, 120, 20), "Equipment"))
             {
                 displayEquipScreen = true;
                 displayInvScreen = false;
             }
             
             
         }
     }
 
 
Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Sep 20, 2015 at 02:55 PM 0
Share

I added a tag to bce0051 to allow you to look at existing questions and answers.

avatar image Kearney444 · Sep 20, 2015 at 04:59 PM 0
Share

Your comparison is wrong I think. I think it should be : if($$anonymous$$ainInventoryList[x].ItemGroup.light == Group.light)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I save the value that C1,C2,C3,C4 and C5 get inside the if condition and use it later to display it in a text? 3 Answers

Why can't won't my if then statements work? 1 Answer

Problem with if statements relating to images 1 Answer

Distance sensor 1 Answer

why != is different from var1 = !var2? 2 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