Generating custom .plist

Generating custom .plist
0

Hello everyone,

I created a custom made particle system component (based on unity 3d) with more than 50 types of properties and functionalities.

When I finish setup the component, I want to save those properties somehow.
So the best choice is to go on JSON file, however the standard here is plist file.

How do I generate a plist file and download it withing the editor?

are you asking about how to save the plist from Unity?
In cocos creator, when you click on the “Custom” checkbox you will see an option to export your particle system as a plist file.

If it’s your own particle system, and if the output data from it is not meant to be used with any other particle system, then save it in whichever format is most convenient for you. There is no reason for you to use the PLIST format, but if you really do want to output your data in this specific format, then use any XML library to do this.

My question is how to save or generate file within th editor. I dont care from other platforms.

For example. I have component with one prop.
I want to generate a plist for that propert. Thats it. Should be simple.

Check out the Editor Extension part of the manual:
https://docs.cocos2d-x.org/creator/2.2/manual/en/extension/

you can reach the scene nodes with scene walker script and search for particle system components in the scene then read/write whatever you want.

Super Mega Pro Tip:
You can find selected node in the node tree with my carefully handcrafted code snippet here :smiley:
Use it in scene-walker script in editor extension you made.

Find_Selected_Node(node){
    if(node.gizmo && node.gizmo.editing){ // node is selected
        return node;
    }else{
        let found = null;
        for(let i = 0 , n = node.children.length ; i<n ; i++ ){
            let child = node.children[i];
            found = this.Find_Selected_Node(child);
            if(found)break;
        }
        return found;
    }
}

let Selected_Node = this.Find_Selected_Node(cc.director.getScene());