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 gangafinti · Jan 30, 2014 at 07:03 AM · arraylistc# tutorialtransforms

How to adress a Transform inside a arraylist that's inside a arraylist.

I am trying to put a arraylist inside a arraylist and then put transforms inside the arraylist that is already inside the first arraylist. I tried the following. The debug I put in there returns a Null item but if I look at the count it says 7.

public class Main : MonoBehaviour {

 private List<List<Transform>> playPieceList = new List<List<Transform>>();
 
 void PieceSpawner()
 {
 List<Transform> playPieceListInside = new List<Transform>();
 playPieceList.Add(playPieceListInside);
     for(int e = 0; e < 7; e++)
     {
         Transform tempPlayPiece;
         Vector3 posPiece = new Vector3(0.1708656f - 0.0574332f * e, 0.1f, -0.228953f);
         tempPlayPiece = Instantiate (playPiece, posPiece, Quaternion.identity) as Transform;
         playPieceList[0].Add(tempPlayPiece);
     }
 playPieceList.Add(playPieceListInside);
 Debug.Log(playPieceList[0][0]);
 }

}

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

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

Answer by GameVortex · Jan 30, 2014 at 08:44 AM

The debug returning a null means that the content of position 0 in the list inside the master list is null. This is most likely a result from the Instantiate going wrong. Put a debug to find out if the for loop actually instantiates objects and that the object is valid. Maybe the prefab reference is null or you could try instantiating it as a GameObject first and adding its transform to the list.

Another thing is that you are adding the list two times (at line 6 and 14) to the master list, you probably want to add it just once.

Also, don't say ArrayList when you mean List. =P

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 gangafinti · Jan 31, 2014 at 04:11 PM 0
Share

Thank you so much for your help! It was indeed the instantiate. It was a really stupid rookie mistake, but in the playpiece variable was a scene GameObject ins$$anonymous$$d of the Prefab. Also my appologies for adressing it as a Arraylist ins$$anonymous$$d of List. To be honest I didn't learn the difference yet. Anyway it works now thank you!

avatar image robertbu · Jan 31, 2014 at 04:25 PM 0
Share

@gangafinti - if this answer answered your question, please click on the checkmark next to the left of the answer to close it out. Thanks.

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

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

Animating UV transforms in Shader 4 Answers

Gaps and overlaps between platforms in the infinite runner 0 Answers

Array vs ArrayList 3 Answers

arraylist doesn't stop adding to string-infinite c# 1 Answer

How to display data from array,arraylist while clicking the button? 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