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 bibleboy4u · Feb 28, 2015 at 09:09 AM · errorinstantiate

How do I fix this error code: BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Collections.Generic.List., UnityEngine.Vector3, UnityEngine.Quaternion)' was found.

I am fairly new at unity and coding in general. I have a script I have been putting together and it keeps having this error:

BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Collections.Generic.List., UnityEngine.Vector3, UnityEngine.Quaternion)' was found.

Here is my script:

alt text

The error is on line 39. I have tried to find an answer everywhere, but with no success. Any help would be appreciated. :)

capture.png (39.3 kB)
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

2 Replies

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

Answer by tanoshimi · Feb 28, 2015 at 09:17 AM

The error is exactly what it says on the tin.

If you go to the manual, you can see the different versions of every method available in Unity. Looking at the Instantiate page, it lists two versions at the top of the page:

 public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);

 public static Object Instantiate(Object original); 


On Line 39, you're calling:

 Instantiate (blocksList, spawnPosition, spawnRotation);

blocksList is a List (you declare it as such on Line 25). spawnPosition is a Vector3. And spawnRotation is a Quaternion. So which of the two versions of the Instantiate method fit that set of parameters? Neither. That's why Unity is telling you "No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Collections.Generic.List., UnityEngine.Vector3, UnityEngine.Quaternion)' was found"

Considering the context of the rest of your code, I imagine you wanted to instantiate a single element from blocksList. i.e. Line 39 should read:

 Instantiate(blocksList[i], spawnPosition, spawnRotation);

(p.s. in the future please post code as a codeblock, not a screenshot)

Comment
Add comment · Show 4 · 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 bibleboy4u · Feb 28, 2015 at 04:09 PM 0
Share

Thanks for the response to my question. (As you can tell I am not very experienced!) I did as you suggested and put blockList[i], but it gave me this error ins$$anonymous$$d of instantiating the GameObject:

ArgumentOutOfRangeException: Argument is out of range. Parameter name: index

Also, yes. The goal of my script is to instantiate a random GameObject from a list to a random position.

Here is a non-screen shot of my code. (Sorry, I did not know about the "codeblock" feature.)

 import System.Collections.Generic;
 
 var blocks            : GameObject [];
 var blocksList        : List.< GameObject >;
 var spawnValues     : Vector3;
 var blockCount        : int;
 var spawnWait        : float;
 var startWait        : float;
 var waveWait        : float;
 
 
 function PopulateBricksList() 
  {
      // declare a new list
      blocksList = new List.< GameObject >();
      
      // get the length of the built-in array
      var totalBlocks : int = blocks.Length;
      
      // add each brick to the brickList
      for ( var i : int = 0; i < totalBlocks; i ++ )
      {
          blocksList.Add( blocks[i] );
      }
  }
  
 function Start () {
     SpawnWaves ();
 }
 
 function SpawnWaves () {
     yield WaitForSeconds (startWait);
     while (true)
     {
         for ( var i : int= 0; i < blockCount; i++)
         {
              var spawnPosition : Vector3= new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
              var spawnRotation : Quaternion= Quaternion.identity;
             Instantiate (blocksList[i], spawnPosition, spawnRotation);
             yield WaitForSeconds (spawnWait);
         }
         yield WaitForSeconds (waveWait);
     }
 }
avatar image bibleboy4u · Feb 28, 2015 at 04:28 PM 0
Share

Never $$anonymous$$d, your answer worked. Thanks so much for all your help!

avatar image meat5000 ♦ · Feb 28, 2015 at 04:41 PM 0
Share

Click the tick to accept the answer.

avatar image bibleboy4u · Feb 28, 2015 at 04:51 PM 0
Share

Thanks, I did not know how to do that either!

avatar image
0

Answer by hexagonius · Feb 28, 2015 at 09:14 AM

blocksList is of type List. You need to fetch one element of that list.

MSDN Generic List Reference

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Simultaneous Null Reference Exception and expected value 1 Answer

Object reference not set to an instance of an object 1 Answer

Instantiating Rigidbodies on PhotonNetwork? Am I doing it wrong? 1 Answer

Keep Instantiated GameObject while exit gamemode in unity 0 Answers

Instantiating an object as a trigger does not send the trigger event 3 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