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 twoface262 · Dec 09, 2012 at 11:48 PM · androidjavascripttag

Saving multiple objects with same tag

Hello! I'm making a game with multiple cloned objects. I need to start on the saving system, and don't really know where to start. I'm useing Javascript, and making the game for android. I don't want to use playerprefs, and I'm stumped on how to get all the objects saved to a single file. I'm thinking that I'd need to have unity find all the objects with the same tag, and use a loop to save them to a file, but I don't know how to go about that. You're time is appreciated! thank you!

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
2
Best Answer

Answer by clunk47 · Dec 10, 2012 at 06:42 AM

Well, I know C#, JS too, but have forgotten most JS. You'd need to create a list or array. Here's a c-sharp example, I'll link you to the script reference at the bottom so you can read up on arrays and lists for JS.

 using UnityEngine;
 using System.Collections;
 
 public class ArrayTest : MonoBehaviour
 {
     GameObject[] objects;
     
     void Start()
     {
        objects = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
        Debug.Log(objects.Length);
     }
 }



That's if you want to find ALL objects in the scene. If you want to find objects by tag,

 objects = GameObject.FindGameObjectsWithTag("yourTagName");



Then say each object has a different name and you want to find each one of them.

 foreach(GameObject obj in objects)
 {
     Debug.Log(obj.name);
 }
Comment
Add comment · Show 8 · 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 clunk47 · Dec 11, 2012 at 07:15 AM 1
Share

It's one thing I haven't ever actually completed, but I've been trying to code around in my head at night, and I think I could figure it out. I have to do this for my own project anyway, so I'd be happy to share with you any sucessful implementations. Add me on skype Clunk47 and I'll let you know when I have something going.

avatar image twoface262 · Dec 11, 2012 at 02:58 PM 1
Share

Alright. Thanks for the help. I myself have been playing around with a few different concepts. Sinceis somet th ing ive never done before as you can imagine its a pain. Im sure we'll figure something out. In all honesty it doesnt appear to be all that hard to do the saving, but what im unsure of how im going to do it loading, but since with saving its looping wouldnt it continuously loop through and just keep rewriting the same planets over and over again, or would it stop once it hits the last one?

avatar image clunk47 · Dec 11, 2012 at 05:32 PM 1
Share

Well really we wouldn't have to use loops, we could serialize everything as it happens, and store some type of variable to a text, dat, or registry file, then just append new lines. Then on load, check those lines, but make a variable to check each specific line in the txt file. Like location of player could be stored at line[15] or whatever... I'll try to get something started today.

avatar image clunk47 · Dec 11, 2012 at 05:34 PM 1
Share

But yeah just hit me up on skype sometime man, u never know maybe we could work on a small project together sometime, I'm always down for anything profitable :D

avatar image clunk47 · Dec 11, 2012 at 06:10 PM 1
Share

Yeah it would be see, I keep thinking C# lol

Show more comments

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

10 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

Related Questions

A node in a childnode? 1 Answer

two way communication between the unity and streamingassets web page for android 0 Answers

Make an object move in the direction of touch 0 Answers

Writing javascript for web and android 1 Answer

How can I use hit.gameObject.tag? 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