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 /
This question was closed Dec 26, 2013 at 03:12 AM by Drshk7 for the following reason:

Other

avatar image
0
Question by Drshk7 · Dec 25, 2013 at 08:36 AM · buglistsizehierarchyelement

[Photos added]Changing size of list in hierarchy not working.

alt text

Above picture: I want to add an element by changing the size to 1 but it doesn't change to one it stays as 0... T.T

PS: I've already put up a lot of questions on this in the past... Nobody knows what the answer....

I have a list like: public List somelist = new List(); and whenever I try to increase the element size (the number of things in the list), it always changes back to zero. Is there anyway to change element size in the script? Help?

I'm not finished but, alright, here's the whole script: using UnityEngine; using System.Collections; using System.Collections.Generic;

 public class map: MonoBehaviour 
 {
     public static map instance;
     public List<mapsettings> maplist = new List<mapsettings>();
     private mapsettings loadmap = null;
 
     void Awake()
     {
         instance = this;
         loadmap = maplist[0];
     }
 
     // Use this for initialization
     void Start () 
     {
     
     }
     
     // Update is called once per frame
     void Update () 
     {
     
     }
 
     void OnGUI ()
     {
         if(guiscript.startserver == true)
         {
             GUILayout.BeginArea(new Rect(0,0,500,550))
 
             foreach(mapsettings map in maplist)
                 GUILayout.Button(map.mapname);
 
             GUILayout.EndArea();
         }
     }
 }
 
 
 [System.Serializable]
 public class mapsettings
 {
     public string mapname;
     public string maploadname;
 }
 

Found similar post: http://answers.unity3d.com/questions/547631/cant-add-animation-element.html

asdf.png (2.6 kB)
Comment
Add comment · Show 9
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 Therian13 · Dec 25, 2013 at 08:38 AM 0
Share

would you be able to include the whole script? its possible you have something on the update function that may be resetting it back to 0.

avatar image Entrio · Dec 25, 2013 at 08:52 AM 0
Share

please post your update function and, as Therain13 mentioned, the whole script pelase

avatar image Benproductions1 · Dec 25, 2013 at 09:03 AM 0
Share

There's no place in the script where you change the size of the List<>. Please post the parts of the script relevant to the question, nothing more is necessary, but anything less will make it unanswerable.

avatar image Drshk7 · Dec 25, 2013 at 09:05 AM 0
Share

I have some errors: ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System.Collections.Generic.List`1[mapsettings].get_Item (Int32 index) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633) menumanager..ctor ()

and

Assets/Scripts/map.cs(5,29): warning CS0414: The private field `map.loadmap' is assigned but its value is never used

avatar image Benproductions1 · Dec 25, 2013 at 09:34 AM 0
Share

Line 10, you're getting the first element of an empty list. The List<> has a length of 0, so how can you get the first element?

Show more comments

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Benproductions1 · Dec 25, 2013 at 11:16 AM

Hello,

The type List<> is not seizable and is not accessible from the inspector. Therefore it is neither saved nor loaded with a prefab or a scene and will not persist. If you want a collection that is seizable and shows up in the inspector, I suggest you use built-in arrays instead, however they do come with the downside that they are fixed size.

The fact that the List<> mapList shows in the hierarchy is either due to a custom editor or a very obscure bug. In either case it's incorrect and shouldn't be there.

Hope this helps,
Benproductions1

Comment
Add comment · Show 6 · 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 Drshk7 · Dec 25, 2013 at 09:04 PM 0
Share

Thanks for the answer. One more question: Doesn't the list store strings? If so, I could use it for string names for scenes such as Application.LoadLevel(mapname); right? In a tutorial I was following: http://www.youtube.com/watch?v=BU5zRpy2StE ..... At 8:45, he changes the size of the list. How come he can do it and I can't???

avatar image Benproductions1 · Dec 26, 2013 at 01:59 AM 0
Share

That's really not supposed to work. He might have written some extensions to the List<> class to make it serializable.

avatar image Drshk7 · Dec 26, 2013 at 02:29 AM 0
Share

Update: I tried array and I still have the same problem!!! I guess it's an error after all. I tried public string[] maplist; and did the increasing size of elements and it still doesn't work... Oh well.

avatar image Drshk7 · Dec 26, 2013 at 03:06 AM 0
Share

Can you please try to change the size of an array in the inspector and see if it works? I hope I'm not the only one with this bug/glitch...

avatar image Benproductions1 · Dec 26, 2013 at 05:55 AM 0
Share

I've been doing it since I first started using Unity and nothing has changed with any updates. Try doing it in a new project. If that doesn't work reinstall Unity. If that doesn't work then install an older version of Unity. If that doesn't work reinstall your OS and if that doesn't work... well... we're all screwed then

Show more comments

Follow this Question

Answers Answers and Comments

21 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

Related Questions

A node in a childnode? 1 Answer

Inherit size of particles from parent 0 Answers

Texture Doubled in size in RAM Profiler 3 Answers

JSON deserialization 0 Answers

Sorting Game Object Name In Numerical and Alphabetical Order via List 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