I am using cocos creator 3.7.2.
When you create an extension and press a button in a new panel, you want to use the prefab uuid in the editor to add it to the Hierarchy.
await Editor.Message.request(‘scene’, ‘create-node’,
{
assetUuid: uuid
});
A problem arises.
- It is created well in Hierarchy, but there is an issue where the inspector information of the original prefab is missing.
Do you know how to fix it?
1 Like
Met the same problem, also using cocos creator 3.7.2
When I try printing out the created nodes, it says prefab: {state: 0, …}, while nodes created by dragging has prefab: {state: 2, …}
addition:
The code I used is
let createdUuid = await Editor.Message.request("scene", "create-node", {parent: someUuid, assetUuid: prefabUuid, unlinkPrefab: false})
I tried the same thing on 3.7.4 and 3.8.1, problem still exists.
After some try-and-error…
The correct typescript is
let createdUuid = await Editor.Message.request("scene", "create-node", {parent: parentNodeUuid, assetUuid: prefabUuid, unlinkPrefab: false, type: "cc.Prefab"})
You need to specify “type” as “cc.Prefab”, then you create the node like a prefab.
Note: I haven’t tested in 3.7.4 nor 3.8.1, this is working in 3.7.2
1 Like