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 /
This question was closed Dec 28, 2015 at 10:57 AM by WoWNiedzwiadek for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by WoWNiedzwiadek · Dec 28, 2015 at 09:49 AM · unity 5editorarray

Saving the position of GameObjects into array?

I'm making a 2d level editor for my game, operating on 1x1 grid. I want to be able to save the state of the map (it will have predetermined width and height) into the array, basically 0 if there's no object in this "tile", 1 if it's there. I had an idea of creating multiple colliders from script when you create a map (if i have a 25x25 map, in each tile i create a On Trigger Collider with size 1x1), and when i save the data it will check each one for the tag of the object i'm placing. Is there a simpler way of doing it?

Comment
Add comment · Show 1
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 Gnorpelzwerg · Dec 28, 2015 at 10:17 AM 1
Share

I would use a two-dimensional Vector2-array/list, cuz' performance. All other positions in your map are just left out. Are you placing the objects by code or in the editor? if so, u are probably placing then with instantiate function. Before placing them, save their position into a list.

 using System.Collections.Generic;
 //...
 List< Vector2 > positions;
 
 //When placing:
 GameObject tile = Instantiate( ... ) as GameObject;
 positions.Add( tile.position )

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity Editor Panels contains weird color/fonts artifacts (screen tearing) 6 Answers

Tried everything but Intellisense doesn't work VS 2017-2019 0 Answers

Array[] of children of a child 3 Answers

Unity 2017 or 5.6 Doesn't work after install. Editor is broken. 0 Answers

save one big json string vs multi seperate json strings in playerprefs 0 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