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 Magistrix 1 · Aug 17, 2010 at 04:09 PM · errorsyntax-erroruce0001

Strange Error in JScript when using "delete"

Hi! I ve got a really strange Error in this Inventory Script when using the "delete" Statement. If i click the button it should throw out the item ( if there is any item in this slot) an should delete this item. So i thought i could use "delete InventoryItem;" and it worked! But after i restarted my PC i got this error when running the Script again : inv2.js(106,38): UCE0001: ';' expected. Insert a semicolon at the end. I tried everything ( at least i think so ) to get it to work again .... but without success. Has anyone a idea how to get this to work again ???

var inventory : Array;

var ItemObject_1 : GameObject; var ItemTexture_1 : Texture2D;

var ItemObject_2 : GameObject; var ItemTexture_2 : Texture2D;

public var emptyTex : Texture;

public var inventorySizeX = 4; public var inventorySizeY = 5;

var iconWidthHeight = 40; var spacing = 4;

public var offSet = Vector2( 100, 100 );

class InventoryItem { var worldObject : GameObject; var texRepresentation : Texture2D; }

function Awake() { inventory = new Array(inventorySizeX);

for( var i = 0; i < inventory.length; i ++ )
{
    inventory[i] = new Array(inventorySizeY);
}

}

function OnGUI() {

var texToUse : Texture2D; var currentInventoryItem : InventoryItem;

    if(PlayerGUI.doWindow)
    {
         for( var i = 0; i &lt; inventory.length; i ++ )
         {
             for( var k = 0; k &lt; inventory[i].length; k ++ )
             {
                texToUse = emptyTex;
                currentInventoryItem = inventory[i][k];

                 if( inventory[i][k] != null)
                 {
                     texToUse = currentInventoryItem.texRepresentation;
                 }

                 var it = GUI.Button( new Rect( offSet.x+k*(iconWidthHeight+spacing), offSet.y+i*(iconWidthHeight+spacing), iconWidthHeight, iconWidthHeight ), texToUse );


                 if (it)
                 {
                     if(texToUse == ItemTexture_1) 
                         {
                         Instantiate(ItemObject_1,transform.position,transform.rotation);
                         //This is the Problem (Without this line the Code is working):
                         delete InventoryItem;
                         }


                     if(texToUse == ItemTexture_2) 
                         {
                         Instantiate(ItemObject_2,transform.position,transform.rotation);
                         }

                  }
             }
         }
      }

}

function AddItem( item : InventoryItem ) {

for( var i = 0; i < inventory.length; i ++ ) {

 for( var k = 0; k &lt; inventory[i].length; k ++ )
 {

    if( inventory[i][k] == null )
     {
         inventory[i][k] = item;
         return;

     }
 }

}

}

function AddItem( worldObject : GameObject, texRep : Texture2D ) { var newItem = new InventoryItem();

newItem.worldObject = worldObject; newItem.texRepresentation = texRep;

AddItem( newItem ); }

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

4 Replies

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

Answer by Magistrix 1 · Aug 18, 2010 at 09:24 AM

hi ok thx for the quick answers. i fixed this problem with

 inventory[i][k]= null;

:) now it is working.

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
avatar image
0

Answer by Wolfram · Aug 17, 2010 at 04:16 PM

InventoryItem is your class name you can't delete that. Use

delete currentInventoryItem;

(or whichever object you want to delete).

My guess is it didn't compile, even before the reboot, but one often overlooks these errors, and Unity will start normally - with the previous successfully compiled version of the script.

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
avatar image
0

Answer by Magistrix 1 · Aug 17, 2010 at 05:36 PM

I tried

delete currentInventoryItem;

and i tried

delete inventory[i][k];

before but without success.. I tried it again but no change in the error log.

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
avatar image
0

Answer by Eric5h5 · Aug 17, 2010 at 08:12 PM

As far as I know there is no "delete" in Unityscript. If you're trying to remove an element from an Array, use RemoveAt.

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

No one has followed this question yet.

Related Questions

Having difficulty with semicolons. 2 Answers

GetComponent Script and Some basic JavaScript help 2 Answers

Insert semicolon at the end? 2 Answers

CharacterDamage script semi colon error. 1 Answer

';' expected. Insert a semicolon at the end. already one there? 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