How to make UUIDs fixed for all nodes before and after build?

How to make UUIDs fixed for all nodes before and after build?


Hi friends!

I’m developing a physics based game.
Now I’m implementing save/load function for my game. I wanted to save all physics properties of all nodes in the scene to local storage as json text. I made a list which has keys are UUIDs of nodes and values are the data to be stored. It works perfectly, saves and loads when I test in Cocos Creator Editor (Simulator).
The problem is:
All UUIDs are removed or changed during build process and game assigns randomly changing UUIDs to nodes each start. So it’s impossible to find the same node with changing UUID to restore data. Sometimes node orders and parents are changing because of game logic. So I need some way to fix UUIDs for nodes and keep same UUIDs with released app.

What is your opinion?


Sorry,we can not do this.
you can create a uuid for your nodes and use it for store and restore.
for example,make your own init function and call it at create or restore nodes.
when the node is restoring from your savefile,call the init func and give the save data to the parameter,then you can restore the node from save data.
when the node is creating in game logic without save data, it will be created and had a new can write it’s info and uuid to savefile when you need a save.

init (data) {
    if (data.uuid == null)
        this._myUuid = CreateUuidFunc();

read(data) {
    this._myUuid = data.uuid;
    this.speed= data.speed;
    this.node.position = data.position;

write() {
    var data = {};
    data._myUuid = this._myUuid;
    data.speed = this.speed;
    data.position = this.node.position;
    var buffer = serializeData(data);


Thank you my friend!
I’ll try to customize Javascript Engine of Cocos Creator to define solid UUIDs for node.