How to create a Save / Load system for Unity Tilemaps? - unity3d

I am making a game that procedurally generates a level and sets tiles via Tilemap.SetTile().
I've been reading and watching tutorials about saving in unity and from what I understand I need to serialize data so it can be saved in a binary file. However, I don't even know where the data about the tiles in the tilemap is being saved.
How could I make this system - where can I find information about stored tiles in a tilemap?
Is there perhaps an already finished saving system that supports Unity tilemaps on the Asset Store?

As already mentioned in a comment, the "serialization" in Unity is absolutely garbage - completely forget about it.
All you do is save the info, probably as JSON, just a text file.
Note that the Json helpers built in to Unity are completely perfect - very easy to use.
Here's a simple and famous example ... https://stackoverflow.com/a/40097623/294884
(Note that you don't literally have to use Json, you can use any simple text format, but Json is so easy you may as well use it.)
There are actually dozens of QA on this site where someone asks "I want to save _ _ _ in Unity, how do I use serialization?" in every single casethe answer is just "Unity serialization is a joke, just save as a text file."

Related

Including non-standard resources in Unity HoloLens app

I'm building an app that must visualize a large point cloud on HoloLens 1st gen. As performance is an issue wit large clouds, I'm using Potree, an octree that takes care that only a preset number of points from the cloud are rendered.
The solution works in the editor, but, you guessed it, not when deployed on HL.
The point cloud in the Potree format is a set of couple of .json and hundreds of .bin files stored in hundreds of subfolders following the octree structure, all of that stored within a single folder, and the path to this folder is accessed by the renderer at runtime. However, I don't know how to include this folder in the HL app. Using Resources doesn't work as it's not really a standard resource. I've seen Asset Bundle suggested elsewhere, but according to this post asset bundling doesn't work on HL.
Is there a way to simply put this complex file structure in an accessible directory on HoloLens?
I feel completely stuck here and any help would be much appreciated.
Some of the things I've tried:
Keijiro Pcx doesn't work here. If rendered as single pixels, points cannot be seen in AR, and if rendered as meshes, the performance is abysmal (which led me to a conclusion octree structure should be used)
the solution here shows how to load one .xml file, but I have hundreds of files so I don't think it would work for me
similarly, this post deals with one .obj file
Unity 2019.4
HoloLens 1st gen
For anyone stumbling upon this - I ended up using Unity StreamingAssets and accessing the folder with Application.streamingAssetsPath - works beautifully!
Using pcx needs to be adjusted to binocular rendering in publishing settings. Please uncheck "Enable Depth Buffer Sharing" in XR Settings, and change "Single Pass" to "Multi Pass", as shown in the figure.enter image description here

Dealing with massive amount of user generated images in Unity3D

I need to create a system where we load images into the game. Those images can be uploaded by the users of my app through a dashboard. I download them to the device(persistent data path) and load them from there.
The question is, should I load them as AssetBundles(through Addressables) or straight from disk with Texture.LoadImage(bytes).
Keep in mind that I will not be able to apply custom compression for them. I use the same compression for all files, whether it's an asset bundle or not. The problem with asset bundles is the management of them. When you update the unity version + the fact that I need to have unity run on a server and create them every time someone uploads an image to the dashboard.
TL;DR;
Is the loading of an image that bad with Texture.LoadImage(bytes) that you should use AssetBUndles even if it involves way more work and problems?
Someone else answered this in a Unity forum.
The best option you can pick is to use RawImage component, which uses textures not sprites, removing the need to load a sprite from a texture, making it much faster. Case in which asset bundles are not required, simplifying the solution while keeping a decent loading speed.
Answer here: https://answers.unity.com/questions/1758532/dealing-with-massive-amount-of-user-generated-imag.html

Display a website using cocos2d

I need to load a website in a cocos 2d game.
For example,when a ccmenu button is clicked,i need to replace a scene where it must load an particular website.
Any ideas please,thanks.
It sounds like you want to get game data from a server, correct? In that case, you probably aren't going to want to load an HTML page. Instead, come up with some a method of storing pertinent game data in a more appropriate file format. I can't say for sure because I don't know anything about your game, but saving your game data as XML might work well. Then, when you need to update the game with data from your sever, use an NSURLRequest or similar to download the XML file, which you can then parse as you see fit.
Look into CCHttpRequest or CCHttpClient.

coredata as front end and text files as backend

How does this sound conceptually.
I wanted to store some text and add tags to it thats easily retrivable. Coredata is the obvious solution, but i also needed that data across the cloud, not just iCloud like dropbox. So I thot i'd use Coredata + textFiles.
obvious approach
use coredata with two entities. One for text and one for tags. Works awesome BUT not ready for syncing.
1. using icloud coredata combo will hurt me badly, its still unreliable, and i cant afford to keep stabilising it.
2. i dont just have ios devices, need it on my computer too.
the solution
Add text in a simple textview.
Add tags to the text as well using some kinda delimiters.
Save the document as a text file (that includes tags) and give the document some unique name
Put that file in dropbox or icloud or whatever as a document But Also, parse it locally in the iOS app so that the text in file is separated into text and tags each of which enters its entity in coredata.
advantage for the solution
I can use the text in a useful way locally (in iphone) and if needed will get those text files from the cloud.
problem with the solution
Data in the cloud (as textfiles) is only so useful. But nonetheless, its there, i can live with this.
SYNCING: how do i make sure that each file is synced appropriately. Im not sure I should use UIManagedDocument? I'm already using coredata locally, dont know how i'd complicate things if i use UIManagedDocument.
My question is, im confused about the syncing and saving part, what should i do to keep it neat and clean.
While writing this question i feel like I screwed up the whole idea.

Record audio, add effects, then save result to a audio file

I am having trouble doing what the title said. My goal is to be able to add any desired effects to your recording, save the modified audio, then send that to a server.
I have searched the fourms and came across these threads:
viewtopic.php?f=7&t=13029&p=45362&hilit=saving#p45362
viewtopic.php?f=7&t=12660&p=44586&hilit=saving#p44586
viewtopic.php?f=7&t=13178&p=45746&hilit=saving#p45746
After reading those, I see it is possible to save the modified audio, but can it only be saved as a wav? Like I said after it is saved it will be sent to a server, so size is a big deal and wavs are relatively big compared to other formats. Ignoring that fact, I tried to implement FMOD_OUTPUTTYPE_WAVWRITER and I cannot get that to work; are there any good examples of using it? I looked though the examples in the library but I didn't see any..
But the basic structure of the app is to record, turn some switches off and on to see what filters you want, preview it, then press a button "Save" that will save it. What would this save function consist of?
Any help appreciated, thanks.
Using FMOD_OUTPUTTYPE_WAVWRITER is fairly straight forward, you set the type via System::setOutput, specify the output file via System::init extradriverdata. The extradriverdata should be an absolute path to a writable area of the device such as the documents directory. After you have finished playing, call System::release and the file will be complete.
The other option for recording wave data with effects is by creating a custom DSP and connecting it to the channel playing the recorded data. You will then get regular callbacks giving you float data that you must write out to disk yourself. You can find examples of DSPs and writing wav files in the dsp_custom and recordtodisk examples respectively.
Finally note that FMOD doesn't come with the facility to write compressed audio to disk, you will need another API to achieve this goal.
You can save as an AAC file via the ExtAudioFile API.