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
1 vote
2 answers
56 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....
user avatar
0 votes
0 answers
39 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 ...
user avatar
0 votes
0 answers
16 views

Possible to overwrite reference type without breaking references?

I'm trying to write a system for loading a bunch of variables from disk at runtime. For a Unity game. I'm using the Easy Save plugin to serialize a parameters class. I have a wrapper class that allows ...
user avatar
0 votes
0 answers
30 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 ...
user avatar
0 votes
1 answer
80 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 ...
user avatar
0 votes
1 answer
32 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 ...
user avatar
  • 231
1 vote
1 answer
48 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....
user avatar
0 votes
1 answer
94 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, ...
user avatar
  • 135
1 vote
1 answer
390 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 ...
user avatar
0 votes
0 answers
119 views

Understanding the EditorPrefs API in Unity

Context I was working on an editor window that had to toggle Preferences > General > AutoRefresh via script so I was using Unity's EditorPrefs API. Problem Editor prefs are saved not in yaml ...
user avatar
  • 733
1 vote
1 answer
200 views

Serialize List of References

I have a list of object references inside a serializable class, like this: ...
user avatar
1 vote
0 answers
497 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: ...
user avatar
  • 231
0 votes
1 answer
38 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: ...
user avatar
  • 733
0 votes
0 answers
15 views

Saving and Loading Component Settings (Serialisation Help)

I am currently taking my first real steps into serialisation in Unity. To start with I thought I would try and save customisations to a weapon back to its data representation WeaponItem a ...
user avatar
1 vote
1 answer
172 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'). ...
user avatar
0 votes
2 answers
244 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 ...
user avatar
  • 66
0 votes
1 answer
97 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 ...
user avatar
  • 109
0 votes
1 answer
26 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 ...
user avatar
  • 238
0 votes
2 answers
119 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 ...
user avatar
  • 125
1 vote
0 answers
144 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 ...
user avatar
  • 792
0 votes
1 answer
627 views

What is the difference between Serializable, and System.Serializable?

What is the difference between Serializable, and System.Serializable? I'm guessing ...
user avatar
0 votes
1 answer
142 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: ...
user avatar
0 votes
0 answers
237 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 ...
user avatar
  • 792
0 votes
1 answer
974 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 ...
user avatar
  • 174
0 votes
0 answers
34 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 ...
user avatar
0 votes
1 answer
240 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 ...
user avatar
  • 103
0 votes
0 answers
32 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 ...
user avatar
  • 2,729
2 votes
1 answer
1k 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 ...
user avatar
0 votes
0 answers
83 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 ...
user avatar
-1 votes
1 answer
121 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 ...
user avatar
1 vote
1 answer
892 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 ...
user avatar
0 votes
1 answer
804 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 ...
user avatar
0 votes
1 answer
345 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 ...
user avatar
1 vote
1 answer
332 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 ...
user avatar
1 vote
0 answers
477 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 ...
user avatar
  • 249
1 vote
1 answer
956 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":[{},{},{},{},{},{},{},{},{},{},{}]}... ...
user avatar
  • 11
1 vote
1 answer
695 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 [...
user avatar
  • 677
1 vote
3 answers
5k 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 ...
user avatar
  • 627
1 vote
1 answer
559 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 ...
user avatar
  • 627
1 vote
0 answers
334 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? ...
user avatar
  • 131
0 votes
1 answer
567 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 ...
user avatar
0 votes
1 answer
183 views

How to add to a MonoBehavior array from an Editor script in Unity

I've made an editor which makes a list of tags and splits them into two rows of true or false values (selectable by the user). I then compile this list into a dictionary, and each entry is like so: <...
user avatar
0 votes
0 answers
463 views

How does Unity store references to GameObjects in a scene

A Monobehaviour can have references to GameObjects in the same scene, but Prefabs, ScriptableObjects can't reference GameObjects in a scene. While Assets, Objects and serialization covers references ...
user avatar
0 votes
1 answer
3k views

Loading a list of items from JSON, all entries are null

(I posted a very similar question here recently and the response I received was helpful. But I have been advised to start a new question, and here it is.) I am developing a Unity game which includes ...
user avatar
  • 101
2 votes
1 answer
5k views

Unity JSON parsing Array of Objects problem - error: JSON must represent an object type

I'm trying to use Json to hold game dialog in a text asset file. I've tried to make a barebones project to test this and it is failing with the Error Message: ArgumentException: JSON must represent an ...
user avatar
0 votes
1 answer
1k views

(Unity) Serializing Data with Custom Object Stored by Reference

I have a custom class that I serialize/deserialize to/from file(s), and is not guaranteed to be identical each time the game runs (in this example, a language pack. it's possible to fix a typo ...
user avatar
0 votes
0 answers
71 views

How to save Player's progress with variables?

I'm trying to save and load my Player's progress. I have a serialized class named "gamestate". This class contains all of the Player's progress, number of lives, total points, etc. That class also ...
user avatar
1 vote
2 answers
39 views

Update dependent values of Serializable C# classes on Inspector

I have some data types' properties that depend on the input given into other attributes, but I haven't found in the Unity's API an elegant way to update them automagically on the Inspector. As an ...
user avatar
0 votes
1 answer
122 views

Why is there no standard 3d file format that saves models as (collections of) primitives?

I have been looking around for a file format that saves models as a collection of primitives (Boxes, Spheres, Cones, Cylinders, etc.). After some research, I came to the conclusion that pretty much ...
user avatar
-1 votes
1 answer
169 views

Unity3D MonoBehaviour in .dll loses serialized data when dll is updated

I have a MonoBehaviour class in a compiled DLL that I have included in my Unity project. It automatically serializes public field data as expected. However, whenever I update the dll (by overwriting ...
user avatar