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 /
avatar image
0
Question by seandolan · Feb 11, 2018 at 01:38 PM · array3ddatamapint

Store map as int array and load/save

I have a game map stored in an int array. I want to be able to store this int array and load it to determine tiles in my 3d game level. I am not sure that storing this int array in a file is safe, as someone can just copy say Level 1 and rename it to Level 99 to complete the level.

What is a safe way to store an int array created by a Random.Range set of values for future use? I need to be able to load and save these maps.

Comment
Add comment · Show 6
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 Cherno · Feb 11, 2018 at 02:35 PM 1
Share

Store another variable along with the map data that contains the map number. Check this when loading and if it's not the same as the map that should be loaded, stop the map loading.

avatar image seandolan Cherno · Feb 11, 2018 at 02:39 PM 0
Share

That's a very smart idea. Store an extra value makes sense. I guess I need to encrypt the file somehow as well. Thanks for your comment.

avatar image Nomenokes · Feb 11, 2018 at 02:39 PM 0
Share

I personally like lightly encrypting $$anonymous$$e with sine and cosine functions because they'll scramble the values a little bit

avatar image PizzaPie · Feb 11, 2018 at 03:03 PM 0
Share

How do you currently strore(serialize) them? There is no actual 100% foolproof way to prevent "unwanted" manipulation. With a range from localy saved files with a text based format been the unsafest to an encrypted database on server side been the safest it all boils down to the answer of a simple question, does it really matter if the player cheats?

If it is a single player game with no online score board you really shouldn't care, while on the other hand if it is an online game where people compete against each other you should definitely care.

Anyway if the data are generated on edit time you ll be safe enough with the use of scriptable objects and Unity's serializer.

avatar image seandolan PizzaPie · Feb 11, 2018 at 04:44 PM 0
Share

I don't "currently strore(serialize) them" - I have a game map stored in an int array.

 int[,] map;
 public int mapWidth;
 public int mapHeight;
 void Start () {
    map = new int[mapWidth,mapHeight];
 }
 
avatar image seandolan seandolan · Feb 11, 2018 at 04:46 PM 0
Share

Like it's just inside the int array created at runtime.

1 Reply

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by Meguia · Feb 11, 2018 at 05:20 PM

Use ScriptableObjects!

By default it's serialized as a binary asset, but you can save/load it as json (or any other format) during development.

This talk is realy interesting: https://www.youtube.com/watch?v=6vmRwLYWNRo

Also you can read more information here:

https://docs.unity3d.com/Manual/class-ScriptableObject.html

https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/scriptable-objects

https://unity3d.com/learn/tutorials/topics/scripting/ability-system-scriptable-objects

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 Commoble · Feb 11, 2018 at 06:17 PM 0
Share

Unless I'm forgetting something important, you generally don't want to use scriptable objects to load and save data during runtime -- they're intended to be used as readonly data and you usually don't edit them outside of the inspector or editor tools (though if you really wanted to use them for that, I don't think there's anything stopping you)

This unity tutorial recommends using a binary formatter for saving/loading data; the file this creates won't be 100% uneditable by someone who really wants to edit it, but A) it will prevent people from randomly stumbling into a plaintext file containing their save data, which is generally good enough, and B) if someone really wants to hack their own save you can't really stop them short of hosting the data on a remote server ins$$anonymous$$d of on the player's computer

avatar image seandolan · Feb 12, 2018 at 04:20 PM 0
Share

Thanks, I ended up finding the following tutorial a bit easier to understand. https://www.youtube.com/watch?v=sWWZZByVvlU

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

95 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you calculate walls between tiles in a 3d environment? 5 Answers

Split each number in an int without converting to char and string first? 1 Answer

Array - Convert Object into Int 5 Answers

Find Highest Value in Array 5 Answers

Convert Array to String 3 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