• 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 Jul 18, 2017 at 01:54 AM by agencebrunel for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by agencebrunel · Jul 18, 2017 at 01:40 AM · expected

why ';' expected ?

  • Unity said me to add ';' on line : GameObject mapiece = Instantiate(block, pos, Quaternion.identity) as GameObject;

  • I don't understand why, he want just after first GameObject.

  • i try to make all my instantiate "block" child of prefab "piece" that make it.

      private var PieceLargeurTaille : int;
         private var PieceLongueurTaille : int;
         //public var block: Transform;
         var piece : GameObject;
         var block : GameObject;
         var spacing = 2.0;
         
         function Start () {
         
             PieceLargeurTaille = Random.Range(4,8);  
             PieceLongueurTaille = Random.Range(5,8); 
         
             for (var y = 0; y < PieceLargeurTaille; y++) {
                 for (var x=0;x<PieceLongueurTaille;x++) {
                     var pos = Vector3 (x, 0, y) * spacing;
                     // Instantiate(block, pos, Quaternion.identity);
                     GameObject mapiece = Instantiate(block, pos, Quaternion.identity) as GameObject;
                     mapiece.transform.parent = transform;
                 }
             }
         }
    
    
    

Thanks

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

  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Jul 18, 2017 at 01:48 AM

You try to mix UnityScript with C#. Your script seems to be a UnityScript file however you tried to declare your "mapiece" variable with C# syntax. You have to use

 var mapiece = Instantiate(block, pos, Quaternion.identity) as GameObject;
Comment
Add comment · Show 1 · 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 agencebrunel · Jul 18, 2017 at 01:53 AM 0
Share

Thank you ! I have do : var mapiece : GameObject;

Then :

mapiece = Instantiate(block, pos, Quaternion.identity) as GameObject; mapiece.transform.parent = transform;

And work !

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

68 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 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 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 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

Android Unity crashes on splash screen. Invalid serialized file version, expected 3.5.2f2. Actual version: 3.5.3f3 1 Answer

UCE0001 semicolon expected, please help 1 Answer

What am I missing? I already have the semicolon at the end.. 1 Answer

";" expected. Insert a semicolon at the end 1 Answer

Unity Keeps Giving Me Errors On My Scripts 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges