Hi friends.
I need to get prefab uuid from node’s PrefabInfo object. I need to save this uuid and I want to use it later to instantiate objects from prefabs. I can get correct uuid from prefab object itself but can’t get it from the node created.
Let me explain.
I can get uuid and path infor of prefab from editor:
And I can use it in script like this:
var self = this;
let uuid = "2877e0c4-6500-41d8-9698-71d928778555";
cc.AssetLibrary.loadAsset(uuid, function (err, asset) {
if(err){
cc.log("ERROR: " + err);
return;
}
let spawn_object = cc.instantiate(asset);
spawn_object.parent = self.node.parent;
spawn_object.x = self.node.x;
spawn_object.y = self.node.y;
});
So far so good.
I drag the prefab to scene view and create node.
Now I need to find this node’s prefab with code.
I’ve tried get info from “node._prefab” but it only includes this information in PrefabInfo:
_prefab: cc_PrefabInfo:{
asset: null
fileId: "19LYOm+BVNJalMEZnNVgeb"
root: cc_Node {_name: "Crystal_…}
sync: false
}
I’ve tried “fileId” as uuid but it doesn’t work.
I need to find uuid of original prefab in asset database.
Any advices from big brothers?