• 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 Nov 09, 2016 at 04:38 PM by OussamaB for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by OussamaB · Aug 24, 2013 at 10:58 PM · javascriptarraysizeclasscontent

How to increase the size of a class array?

I've tried using t$$anonymous$$s method to increase the size of my class array by 1 unit:

ClassArray = new ClassVars[ClassArray+1];

But t$$anonymous$$s method clearly removes all the content of the class array and re-creates with the given size w$$anonymous$$ch is "ClassArray+1" in t$$anonymous$$s case.

So how do I increase the size of my class array without removing the existing content of the current array?

Thanks in advance, SoumiDelRio

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

  • Sort: 
avatar image
2
Best Answer

Answer by scipiothegreat · Aug 25, 2013 at 12:00 AM

You could use a generic list.

Comment
Add comment · Show 2 · 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 OussamaB · Aug 25, 2013 at 12:27 PM 0
Share
avatar image Guppie1337 · Jun 04, 2015 at 05:35 PM 0
Share
avatar image
1

Answer by Eric5h5 · Aug 25, 2013 at 12:10 AM

You can use System.Array.Resize, but if you're going to be adding/removing from the array, you'd be better off with a generic List in most cases.

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 DaveA · Aug 24, 2013 at 10:59 PM

It's all here: http://docs.unity3d.com/Documentation/ScriptReference/Array.html

Comment
Add comment · Show 2 · 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 Eric5h5 · Aug 25, 2013 at 12:05 AM 0
Share
avatar image OussamaB · Aug 25, 2013 at 12:26 PM 0
Share
avatar image
0

Answer by trs9556 · Aug 24, 2013 at 11:24 PM

If there isn't a specific method to do that you could make a new array that is the same size as your current array, then store all of your values in that new temp array, increase your array by however much you want (not having to worry about the values because they are being held in another array) then assign the values to that new sized array.

Comment
Add comment · Show 3 · 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 DaveA · Aug 24, 2013 at 11:44 PM 0
Share
avatar image DaveA · Aug 24, 2013 at 11:45 PM 0
Share
avatar image Eric5h5 · Aug 25, 2013 at 12:06 AM 0
Share

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

19 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

Related Questions

Different way to access class variables? 1 Answer

Static array with custom class? 1 Answer

Why Does Initialising Built-In Array of Classes Require Constructor? 1 Answer

Creating A Class Variable That Works With Any Class 0 Answers

How to access a variable within a multidimensional array of class 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