Character Customization

Language: C#/Json

Engine: Unity

Time: No Specific                                    DeadLine(Research)

Work: UI & Character                            Customization


I worked on a character customization that is still in progress. it's more research to learn all the aspects of a character customization what i can expect, and which ways i can go in this subject.

I do this together with a friend, it pure research and eventually we want to make a working character customization. The reason why we want to research character customization is because we want to learn more of this feature. it has key elements like a UI but also a lot of elements like the skinned mesh renderer. but it also needs a sort of a database to save the character so that if i use it in a game. that the player can create a character and then use it in the game. and we're still exploring all the possibilities, we also do this for work.


This Github Repository is private.

Character Customization the research so far

This is one of the arms and with buttons we can change those arms in a different game object

With these buttons Next arm & Prev arm if we click on one of those, we can change the arm from above to a different arm style.

If we clicked on the next button it will change to a cylinder. The position of the object/mesh will stay the same. but the scale of the object will also stay the same.

This is how the next arm works in code. This function works together with a list of different Game objects or a Mesh or a different option you want to use. It also looks at the bodypart that you've put in the inspector. in the next slide i will show you how that works in the inspector.

Here you'll see the different body parts and almost every body part can be changed except the head part. reason why is because i haven't made a head for the test character. So that's why i leave it open. But as you can see from here as well that the torso is a game object. And in the torso options are the mesh so, the object is just an changing the mesh. 

And here we show how you can go back to the previous option. but it doesn't really matter if you only press next torso, you'll get back to beginning the same goes for previous torso

 

But as from above you saw the list. well here i make the list with a serialize field private list. This shows it in the inspector and there you could add anything that you want but it has to be the same thing as every game object with a mesh could go in the list but a game object that uses a skinned mesh renderer and not a mesh can't be put in because it uses a different mesh.


Saving & Loading Character With JSON

This is the beginning of the Json file. at get component In Parent<Character Customization> grabs the data of the script that is needed for all the IDs of the character. The IDs are needed for character customization to understand which object or mesh will be next in place that is defined in the list. The path and persistent Path are needed to give the Json file a path where it will be saved. It is also needed for loading the Json file. But we'll be there in a bit.

Here is how it will be saved. Well, it grabs the character data that is present the moment you press the save button it will save the character as how it is set in the game. So, if you change it and save it again it will overwrite the existing file and all the new objects that you've changed will be saved in the Json file.

This is the way of loading the data. For this we use a string in the function so that we can say in the inspector what file we need. The reason why is so that it understands which file it has to load. So, if there we're multiple files and you haven't defined the right filename it will have a problem because it doesn't know which one. But right now, it does. 

To understand the rest of the Json file and how it will be saved and which data you need is explained here. This is almost the same as next torso, but it isn't a button. What happens here. It knows alright I've chosen a different arm, and here it gives the data towards the torso Index so it understands that the data is changed. But every time a next option is chosen it will change it here aswell so that if you save the game that data will be given to the Json file.

This is where the data will be received. so, every time data changes it will return new character data. And from these indexes it will go to a special class that is needed for the Json file and unity so that the data can be received in the Json file.

This is the class that is needed for Json and unity (C#) to receive and give the data to the Json. If you don't use this, it will never receive data so the file will stay empty.

There will be more content in the future.