Questions tagged [serialization]
Serialization is the process of converting a data structure or an object state into a different format for storing or network transmission purposes so that it can be reconstructed later.
121 questions
2
votes
0
answers
67
views
Best Approach for Storing / Serializing Property Value Animations
Background
I'm making a platformer game, in C#, in Monogame. I've got a middling amount of experience with gamedev, having done some mini projects in Unity in the past and deciding I don't like a big ...
0
votes
1
answer
65
views
Unity FromJson Utility Not Populating Instance of Class
I've used FromJson in Unity/C# a dozen times, and yet for some reason I cannot figure out why this one's not working.
Here's the code that does the parsing:
...
1
vote
2
answers
209
views
Persist global shader parameter
I use Shader.SetGlobalVector to modify the behaviour of multiple shaders. I added a MenuItem to change these parameters in ...
0
votes
1
answer
120
views
Newtonsoft.Json JsonConvert.DeserializeObject (Polymorphism)
I'm using JsonConvert.DeserializeObject to deserialize animals from the Animal list, but unfortunately they get deserialized as Animals instead of their derived classes (Cat and Dog). As you can see, ...
0
votes
1
answer
173
views
When saving in Json format, some places I want are not saved
I'm making a game in Unity and I'm using json format to save. I have no problem recording it on my computer, but it does not record the animals I catch on my Android phone. How can I solve this? What ...
0
votes
1
answer
192
views
How to save and instantiate game data containing lists of polymorphic types
Let's say I have a class named Entity such as:
...
0
votes
1
answer
105
views
How to make non-respawning collectables with a collection counter?
Using Godot 3.1, I've written this script for diamonds that the player collects:
...
0
votes
1
answer
387
views
How to read/edit data compressed in ZXML format for modding the game Chocolatier?
I'm trying to mod the game Chocolatier from 2007. It has two .xml files, but they don't look like conventional XML when I open them in VS Code or Notepad++. Here's a sample of what they look like:
...
1
vote
1
answer
250
views
How to compare a GameObject's component settings to those of the original Prefab
I have a Prefab with a number of Components, such as:
Rect Transform
Text Mesh Pro
Sprite Renderer
Box Collider 2D
I think Instantiate a GameObject using the Prefab, and configure it. As the ...
1
vote
2
answers
145
views
Loading game state before first save has occurred (chicken/egg problem)
I've learned that storing and loading game saves is commonly done by serializing runtime data into binary files and then loading in those binary files de-serialized to reconstruct the runtime state ...
1
vote
1
answer
324
views
How to stream a game world to & from disc while supporting dynamically added objects?
Let's just say you have a massive world that isn't loaded into RAM all the time, and is streamed from the hard drive storage.
How would that world be stored on the hard drive? Is it serialised?
Let's ...
0
votes
2
answers
1k
views
Can't serialize plain struct with Nullable fields
I try to save game data in PlayerPrefs as JSON string. I read in documentation that I can use plain struct/class with ...
1
vote
2
answers
2k
views
How to check if a Vector3 or Quaternion are unassigned?
How can I check whether Vector3 and Quaternion are not "null"?
I have a saving system and didn't have a vector and ...
1
vote
0
answers
1k
views
Unity: JsonUtility.ToJson() not serializing everything
I'm trying to serialize the state of play of my Unity game (Unity 2021.3.7f1) to JSON using UnityEngine.JsonUtility.ToJson, so that I can persist this state to disk ...
1
vote
1
answer
6k
views
Exposing list of interfaces to inspector using Odin
Use case: scriptable objects that contain different algorithms but generate compatible data, which are used randomly in a procedural system. They implement an interface so that the system can give ...
1
vote
2
answers
1k
views
How should I implement the idea behind this abstract class setup in a Unity-Friendly/Inspector-Usable way?
First up, the name of the question is terrible and I am open to suggestions. For context: I'm still relatively new to C#/Unity and it's hard to ask questions properly when I don't know the terminology....
0
votes
0
answers
69
views
Datatype for procedural terrain generator
I'm making a kind of infinite runner style engine. It generates the terrain in chunks each time a milestone is reached, and stores each chunk as a custom class in a list.
To minimize overhead, it only ...
0
votes
0
answers
207
views
Box2D Body cannot be serialized. How to ignore or serialize it successfully?
In my game, which implements the network functionality with Kryonet, I would like to send a class ("MyBox2DComponent") over the network which e.g. contains a field of type Body (Box2D).
Of ...
0
votes
1
answer
207
views
An issue that could be either serialization, or Unity's SceneManager
At this point, I don't have any idea of what could the issue be. So, I was trying to make a project wide loading screen. Through an editor window, I assigned the loading scene, which was picked up via ...
0
votes
1
answer
236
views
Unreal 4: How to save generated UProceduralMeshComponent to level file in editor and load it at runtime?
I have UProceduralMeshComponent that I generate in editor from data entered by level designer. Now I need to save it to level file in editor to load it in runtime without generating new mesh again.
Is ...
1
vote
1
answer
211
views
Unity serialization with preprocessors
I am working on a Unity multiplayer game using mirror, and i separated server- and client-only code using partial classes and preprocessor #if statements based on this answer i found:
https://gamedev....
0
votes
1
answer
508
views
How do you use configuration files to describe the contents of an entity in an ECS-system?
One of the advantages that's often brought up when talking about ECS-systems is that they allow a higher degree of flexibility in regards to Data vs Code. Without the limitation of hard-coded types, ...
1
vote
1
answer
2k
views
Unity custom editor - nested Property Drawer is getting Enum names for the parent property, instead of the child
I have a class, EnumMap<TEnum,TValue>, for associating each member of an enum type with a value of a given type, since I find myself running into situations ...
2
votes
1
answer
2k
views
Serialize List of References
I have a list of object references inside a serializable class, like this:
...
1
vote
0
answers
2k
views
Unreal Engine 4.26: How to serialize and load the array of custom UObjects (TArray<UObject*>) in C++?
I have a UProperty in struct which is a TArray<UCoverInfo*> where UCoverInfo is inherited from UObject:
...
0
votes
1
answer
690
views
Getting info about the script a [PropertyAttribute] is attached to in Unity
Is there a way to access info about the script that a PropertyAttribute is part of in Unity?
In my case: getting the memberInfos of the script:
...
1
vote
1
answer
349
views
Text Only Dungeon Crawler game. Hardcoding Maps vs Generating Map Data externally?
I am trying to make a text-only dungeon crawler game.
The general structure for the game is in place (ie. a 'Level' is a 16x16 grid of 'Rooms').
...
0
votes
2
answers
1k
views
Designing persistence in an ECS world subdivided into chunks
I'm designing a kind of simple open world with ECS. The whole world is too large to be loaded at once, so I load and unload chunks according to player's position. Nothing fancy, pretty much standard ...
0
votes
1
answer
287
views
How to implement complex serializable property with internal GameObject field
I'm trying to create a complex serialized object with property drawer with assignable GameObject field. I want to make something like Binding. So that you could declare a field in an X Monobehaviour ...
0
votes
1
answer
244
views
After setting a field using the editor API, the field gets cleared on Play in Unity. How to fix it?
After setting a field using the editor API, the field gets cleared on Play in Unity. How to fix it?
I have a menu item. That menu item sets a field on one of my game objects in scene. After the field ...
0
votes
2
answers
1k
views
How can I serialize lists to JSON on mobile?
I'm having difficulties serializing lists with the built in JsonUtility. I eventually figured out this just isn't possible with its limited capabilities.
As much as I'd like to use Newtonsoft, I ...
1
vote
0
answers
528
views
How to serialize animation state?
In Unity, I have an Animator on a character.
Upon saving/loading the game, I want to preserve the pose and animation state the character is in.
However, I can see no way to read/write all the data ...
0
votes
1
answer
2k
views
What is the difference between Serializable, and System.Serializable?
What is the difference between Serializable, and System.Serializable?
I'm guessing ...
0
votes
1
answer
480
views
Extending a ScriptableObject to have a get property instead of a field, without losing serialized data
I have a ScriptableObject that's already used extensively in my project:
...
0
votes
0
answers
887
views
Alternative to Dictionary serialization
I am working on a set of ScriptableObjects that represent base stats for characters in my game. Think Strength, Speed, Intellect, etc. A whole laundry list of em (about 20 stats).
I'd like to later be ...
0
votes
1
answer
3k
views
How do you de/serialize a monobehaviour class?
It seems JsonUtility.FromJson does not work for MonoBehaviour classes (and I can't get Newtonsoft to parse strings to Vector3s)
Suppose you have a MonoBehaviour ...
0
votes
0
answers
105
views
How to annotate a BinaryFormatter packet with a header describing its length?
I am working on a project that is sending data from pc to tablet via usb, using android adb. To serialize the data, we are using BinaryFormatter. The problem I'm running into is that the client is ...
0
votes
1
answer
2k
views
Deserialize only some fields from a JSON file
I'm trying to parse a very large JSON string in Unity. I do not need all the fields and I can't create a class with all the members.
It appears that all examples I have found, including the official ...
0
votes
0
answers
61
views
XML Serializer deleting player files
I've been getting reports from my users that sometimes the game isn't saving. I've recently been provided with the game save files from one of these reports and found all the XML files were completely ...
2
votes
2
answers
3k
views
Component instance reference in Unreal Engine 4
I'm creating a C++ script and I want to get a reference to a component instance.
For example, imagine that I want to get the player camera, which is a ...
0
votes
0
answers
400
views
Saving Complex Data to File Javascript
My game uses lots of complex objects to store game data. (Each block and entity has its own instance of a class)
I am trying to create a saving and loading system, where the user can save game ...
-1
votes
1
answer
288
views
Serializing game information over TCP connection
I'm trying to write a Unity client with C++ game server with TCP socket. When I'm sending game data back and forth with client and server, I'd want to serialize it in someway that can be deserialized ...
3
votes
1
answer
831
views
How to prevent Unity from generating unnecessary changes after saving a scene with no actual changes
I was having trouble where Git shows a lot of changes (for my case, about ~3000 diff change since I have many objects in the scene) after saving a scene (.unity file) in Unity, even though there are ...
2
votes
1
answer
2k
views
Serializing nested ScriptableObjects with runtime changes
I'm making an effort to use ScriptableObjects more in my game architecture, after watching a fantastic Unity Unite talk on the subject. The central idea is to use ScriptableObjects, during runtime, as ...
0
votes
1
answer
2k
views
How to properly format classes for JSON deserialization with JSON.net for Unity?
**UPDATE: This answer has been solved and this post updated to **
I am creating an inventory system and decided to keep a master list of all the items. The goal is to use Newtonsoft's JSON.net to ...
0
votes
1
answer
623
views
Unity editing List via Editor Script
I am currently working on an editor script for a custom component I created, I am using UIElements to do this, the UI is constructed and working all apart from when I try to modify a list item of the ...
2
votes
1
answer
614
views
Json Libgdx serialize / de-serialize a Object Map of Object Maps
Any one have any ideas on how I can serialize / de-serialize an
ObjectMap<Enum, ObjectMap<String, Object>>();
(Object is usually a String Integer ...
1
vote
0
answers
871
views
How can I uniquely identify a GameObject in Unity?
I'm trying to serialize and deserialize my custom classes with Unity. I've got an ISerialize interface that mandates the class can ...
2
votes
1
answer
2k
views
Unity3D - JsonUtility returns empty string
i have the problem that when I convert an instance of highscores through JsonUtility.ToJson the value of my value of it is always {"highscoreEntryList":[{},{},{},{},{},{},{},{},{},{},{}]}...
...
3
votes
1
answer
2k
views
How to reference nameof private serialized field in unity custom inspector
I'm running into a problem that I think will seriously affect maintainability down the road, so I'd like to figure it out now before it becomes a problem.
I've been starting to use private [...