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 /
  • Help Room /
avatar image
0
Question by Der_Kevin · Nov 12, 2016 at 11:44 AM · arraylist

Cannot implicitly convert type `System.Collections.Generic.List' to `UnityEngine.Vector3[]'

Hey!

so i got this

 public List<Vector3> paths;

and want to fill its content into a

 public Vector3[]    points;

like this:

 gameObject.GetComponentInChildren<DrawSpline>().points = paths;

but that leads to this error:

 error CS0029: Cannot implicitly convert type `System.Collections.Generic.List<UnityEngine.Vector3>' to `UnityEngine.Vector3[]'


i assume i can not just copy over from a over to a [] array(?) but what but be the right way to do that?

Comment
Add comment · Show 3
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 TreyH · Nov 12, 2016 at 12:18 PM 1
Share

To go back and forth between Array and List, there are default functions that can help (although doing it manually is not much effort).

 // Array to List<Vector3>
 points = paths.ToArray ();
 
 // Adding all contents from your Array to the List<Vector3>
 paths.AddRange (points);
 
 // Alternatively, if you only want ONLY the array values
 paths.Clear ();
 paths.AddRange (points);
avatar image Der_Kevin TreyH · Nov 12, 2016 at 01:49 PM 0
Share

thanks! ToArray() helped! you should have post that as answer, so i can give you an accept :)

avatar image TreyH Der_Kevin · Nov 12, 2016 at 02:04 PM 0
Share

@Der_$$anonymous$$evin roger

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by roman_sedition · Nov 12, 2016 at 01:40 PM

You aren't specifying which element of the array you are assigning, maybe use a for loop for this if you want to completely copy over

e.g

 for(int i = 0, i < paths.count; i++)
         {
             gameObject.GetComponentInChildren<DrawSpline>().points[i] = paths[i];
         }






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

65 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

Related Questions

How do i move a list object at the end of the list while shifting back the others? 1 Answer

Unknown Argument Out of Range Index Error On Card Game 1 Answer

How do I add 10 UI text elements to an array or a list...? 1 Answer

Which one to use for, while or something else? 1 Answer

Add an Object to a List which is part of an array does not work. 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