scriptableObject

Hi!
Is anything like scriptableObject is avaliable in Cocos Creator?

I want to edit some properties of my “config” in runtime and have my editing saved after I stopped the editor

Right now I have “config” node right in the scene. This node I can edit at runtime. Problem is my changes dissappears after I stop the editor.

Any workaround any best practices?

Try to make you script running in editor with @executeInEditMode, then your changes made in runtime inside the editor should be able to be saved

Hi!
You mean it will be saved or it can be saved with some approach? :slight_smile:

Adding @executeInEditMode didn’t make any difference

Cocos 3.7.1
saveScriptRuntime.zip (4.3 MB)

@executeInEditMode(true)

Could you describe the exact process of modifying your script data and saving ?

Hi,Bro!
Please refer to this documentation: Decorator · Cocos Creator

what’s bool flag for?

What I expect:

  1. set values to my script in editor
  2. run “Preview in Editor”
  3. change values in my script
  4. exit preview
  5. values that was assigned during runtime are saved

You can see in this clip values are not saved after I exit preview mode

Video

This is normal. Currently, any modification made by CocosCreator to the property value of the component during runtime will be restored after the runtime.Scriptableobject is a data container that can hold large amounts of data independent of class instances of Unity, currently CocosCreator does not support it.

Hi!
Okay now it’s clear

Maybe you can suggest any workaround? :upside_down_face:

Firstly, Preview mode doesn’t allow any data serialization, if you modify values in edit mode, it will be saved.
But if you do want to save data while running the game in runtime, you can try Data Storage

1 Like

For small things you can copy component data before closing it then paste after editor stop.
I follow this process.