Scriptable Object to save at runtime

Hello, I’m making a customization for my game. Characters are stored in scriptable objects, and I’m using a simple binary serialization for saving data. I thought that combining those two I could make the character customization,but the serialize doesn’t take into account meshes and materials.
I have read that I might be able to achieve something like that with json, however I don’t know how to use it.
Is there any better way or simpler way to do it?
I need to store the information on which mesh goes where and what material for each mesh,and a bunch of ints.

Do the mesh/materials change during runtime?

yes, at least once, and i need to keep those changes from play session to play session.

You don’t need to save the material or mesh. What I would do is have a scriptable object which contains an array of meshes and materials which can be used as a resources object. Simply save the int index of the mesh/material which is in use. You can then restore that on load and use it to select which to use.

the problem is that i have over 200 materials. it would take me a lot of work to make that work

edit: the way im working with the character creator is that every Item has its own texture lists 4-5 textures per mesh aprox. if i just use one array for all textures things are going to be very ugly i guess.

How would you structure the data representation of your character creator? Off the top of my head, I’d probably assign an id/index to every object, and then save those. The structure could look something like:

[Serializable]
struct CharacterCreatorData {
  int headId; // base mesh
  int headSubId1;
  int headSubId2;
  int headSubId3; // a few fields for whatever secondary attributes you want to apply to the base head (textures, whatever)
  Color headColor1;
  Color headColor2;
  Color headColor3; // maybe some colors?

  // rinse and repeat for other body parts
}

Your “sub ids” can then refer to the specific textures in each Item list. No need to put all textures in one array.

Then all you have to do is create a method that will read this struct and assign everything correctly.