• 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
-1
Question by peginet · Jul 14, 2013 at 11:19 AM · error-messageanother script

Inventor Script Error , How to Fix It ?

Here Error "Assets/_Scripts/Inventory/InventoryAddItem.js(4,23): BCE0018: The name 'PlayerInventory' does not denote a valid type ('not found'). "

Here Codes : Inventoru Add Item:

 #pragma strict
     //Private
     var TheInventory : InventoryGUI;
     var TheTextures : PlayerInventory;
     var ArrayGrid = 0;
  
     static var InventoryNewItemAdded = -1;
  
     //Icons
     var BlankIcon : Texture;
     var TheNewItem : Texture;
  
     function Start () 
     {
        TheInventory = GetComponent(InventoryGUI);
        TheTextures = GetComponent(PlayerInventory);
     }
  
     function newItem () 
     {
        if (InventoryAddItem.InventoryNewItemAdded > -1)
        {
           TheNewItem = TheTextures.itemTexture[InventoryAddItem.InventoryNewItemAdded];
           if (ArrayGrid < TheInventory.Grids.length)
           {
              if (TheInventory.Grids[ArrayGrid].image == BlankIcon)
              {
                 TheInventory.Grids[ArrayGrid].image = TheNewItem;
                 ArrayGrid = 0;
                 InventoryAddItem.InventoryNewItemAdded = -1;
              }
              else if (TheInventory.Grids[ArrayGrid].image != BlankIcon)
              {
                 ArrayGrid += 1;
              }
           }
        }
     }

Second Code : Inventor GUI: #pragma strict //Private Variables private var InventoryOn = false; private var scrollBarChopGrid : Vector2 = Vector2.zero; private var GridValue : float = -1; var myskin : GUISkin;

//GUI Pos/Size var NamePosition : Vector2 = new Vector2(30,30); var NameSize : Vector2 = new Vector2(250,250); var GridPosition : Vector2 = new Vector2(10,5); var GridSize : Vector2 = new Vector2(323,410); var ClosePosition : Vector2 = new Vector2(312,5); var CloseSize : Vector2 = new Vector2(35,35); var ScrollPosition : Vector2 = new Vector2(312,5); var ScrollSize : Vector2 = new Vector2(355,500); var WindowPosition : Vector2 = new Vector2(0,0); var WindowSize : Vector2 = new Vector2(360,360); var DragWindowPosition : Rect = Rect(0,0,WindowSize.x,WindowSize.y);

//Textures var InventoryWindow : Texture; var CloseIcon : Texture; var Grids : GUIContent[];

function Update () { var AddingNewItem : InventoryAddItem = GetComponent(InventoryAddItem); //On or Off if (Input.GetKeyUp ("i")) {

   if (InventoryOn == false)
   {
      InventoryOn = true;
   }
   else if (InventoryOn == true)
   {
      InventoryOn = false;
      scrollBarChopGrid.y = 0;
   }

} //Window Drag Fix if (Input.GetKey("left shift")) { if (Input.GetKeyDown("i")) { DragWindowPosition.x = 0; DragWindowPosition.y = 0;

   }

} AddingNewItem.newItem(); }

function OnGUI() { GUI.skin = myskin; if (InventoryOn == true) { DragWindowPosition = GUI.Window(0, DragWindowPosition, DoMyWindow, ""); } }

function DoMyWindow(windowID : int) { if (InventoryOn == true) { GUI.BeginGroup(new Rect(WindowPosition.x, WindowPosition.y, WindowSize.x, WindowSize.y), InventoryWindow); //Name GUI.Label(Rect(NamePosition.x, NamePosition.y, NameSize.x, NameSize.y), "Your Inventory");

      //Close Button
      if (GUI.Button(Rect(ClosePosition.x, ClosePosition.y, CloseSize.x, CloseSize.y), CloseIcon))
      {
         InventoryOn = false;
      }
      //Scroll Bar
    scrollBarChopGrid = GUI.BeginScrollView(Rect (ScrollPosition.x, ScrollPosition.y, ScrollSize.x, ScrollSize.y), scrollBarChopGrid, Rect(0,0,0,420));
      // Grid
      GridValue = GUI.SelectionGrid(Rect(GridPosition.x, GridPosition.y, GridSize.x, GridSize.y), GridValue, Grids, 5);
      GUI.EndScrollView();
 
      //Dragable Window
      GUI.DragWindow (Rect (WindowPosition.x, WindowPosition.y, 10000, 40));
   GUI.EndGroup();
 

} }

Comment
Add comment · Show 1
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 markedagain · Jul 14, 2013 at 01:55 PM 0
Share

can u reformat it please, its hard to read and understand unformated

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

GetComponent Trolling Me? 1 Answer

Random Compiler error 1 Answer

Copying file failed (Unable to build) 4 Answers

Error Message 2 Answers

[JavaScript Error] BCE0043: Unexpected token: 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