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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
71 views

How to save and instantiate game data containing lists of polymorphic types

Let's say I have a class named Entity such as: ...
Trobibot's user avatar
0 votes
0 answers
169 views

ReorderableList - Seemingly forced to get element's SerializedProperty in a weird way

I inherit from this and then make instances of the children: public abstract class Connection : ScriptableObject { public State nextState; } And then I hold ...
ruge's user avatar
  • 1
0 votes
1 answer
40 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: ...
Nina Monti's user avatar
0 votes
1 answer
159 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: ...
user4068's user avatar
1 vote
1 answer
126 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 ...
kanamekun's user avatar
  • 369
1 vote
2 answers
78 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 ...
Michael Moreno's user avatar
1 vote
1 answer
114 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 ...
Zebrafish's user avatar
  • 189
0 votes
2 answers
742 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 ...
EzioMercer's user avatar
1 vote
2 answers
860 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 ...
stingalimian galimian's user avatar
1 vote
0 answers
859 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 ...
ChrisC's user avatar
  • 116
0 votes
1 answer
2k 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 ...
arcadeperfect's user avatar
1 vote
2 answers
817 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....
Disgusting's user avatar
0 votes
0 answers
62 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 ...
arcadeperfect's user avatar
0 votes
0 answers
112 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 ...
EchtFettigerKeks's user avatar
0 votes
1 answer
116 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 ...
YoshGJ's user avatar
  • 433
0 votes
1 answer
167 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 ...
Robotex's user avatar
  • 251
1 vote
1 answer
131 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....
ToltottKaposzta's user avatar
0 votes
1 answer
338 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, ...
JensB's user avatar
  • 147
1 vote
1 answer
1k 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 ...
crass_sandwich's user avatar
2 votes
1 answer
1k views

Serialize List of References

I have a list of object references inside a serializable class, like this: ...
RenX's user avatar
  • 707
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: ...
Robotex's user avatar
  • 251
0 votes
1 answer
376 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: ...
Charly's user avatar
  • 742
1 vote
1 answer
225 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'). ...
I_Keep_Trying's user avatar
0 votes
2 answers
771 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 ...
Sisyphe's user avatar
  • 66
0 votes
1 answer
136 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 ...
zORg Alex's user avatar
  • 129
0 votes
1 answer
69 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 ...
qqqqqqq's user avatar
  • 268
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 ...
Vandel212's user avatar
  • 135
1 vote
0 answers
387 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 ...
Weckar E.'s user avatar
  • 822
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 ...
Shrey Joshi's user avatar
0 votes
1 answer
375 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: ...
Commodore Yournero's user avatar
0 votes
0 answers
669 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 ...
Weckar E.'s user avatar
  • 822
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 ...
ina's user avatar
  • 284
0 votes
0 answers
68 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 ...
ethan codes's user avatar
0 votes
1 answer
962 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 ...
mneumann's user avatar
  • 103
0 votes
0 answers
41 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 ...
mr-matt's user avatar
  • 2,759
2 votes
2 answers
2k 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 ...
Daniel Marques's user avatar
0 votes
0 answers
210 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 ...
Eyesight Technology's user avatar
-1 votes
1 answer
213 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 ...
James BAn's user avatar
3 votes
1 answer
686 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 ...
kkl's user avatar
  • 43
2 votes
1 answer
1k 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 ...
crass_sandwich's user avatar
0 votes
1 answer
1k 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 ...
Ian Rosenberg's user avatar
0 votes
1 answer
494 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 ...
Pheonix2105's user avatar
2 votes
1 answer
449 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 ...
Macmanmatty's user avatar
1 vote
0 answers
771 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 ...
Chuck's user avatar
  • 249
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":[{},{},{},{},{},{},{},{},{},{},{}]}... ...
Hypes's user avatar
  • 21
2 votes
1 answer
1k 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 [...
Adam B's user avatar
  • 780
1 vote
3 answers
7k views

ScriptableObjects lose references/stored objects upon build/restarting the Unity Editor?

I'm working on implementing room prefabs for my 2D procedural map generation algorithm. Basically I made a tool which parses a scene's monsters, items, etc into an ObjectContainer prefab, and into ...
Tudvari's user avatar
  • 721
1 vote
1 answer
699 views

Saving and loading a GameObject's full state easily in Unity3D?

I'm working on placing predesigned tilemap rooms in my procedural dungeons, and I would like to design the items' and monsters' placement in these special rooms as well. Currently I "compile" my ...
Tudvari's user avatar
  • 721
1 vote
0 answers
468 views

How would I go about serializing my LibGDX game?

I am currently using Kryo for serialization. I have a Player class, but it extends Sprite. Sprite isn't serializable. This means I can't serialize Player as a whole. Is there another way to do this? ...
Tipsi's user avatar
  • 131
0 votes
1 answer
688 views

Fast Serialization for Multiplayer Gaming

I wish to make a Java based multiplayer game. I am learning all about sockets and so forth. I have built a very basic UDP system that serializes an object with all the information about the game state ...
Galindan's user avatar