Hi,
I wanna get node by name. My node’s name is ScriptNode
cc.Class({
extends: cc.Component,
properties: {
ScriptNode: {
default: null,
type: cc.Node
},
},
// use this for initialization
onLoad: function () {
this.ScriptNode = "" // ?????????
},
});
in onLoad, how can I get node by name.
Not that, this script is attached to a prefab .
ScrptNode’s path and UUID
Path: Script, UUID: 1a0d1U/OgdBGZuZIFRlM2vA
I found that.
onLoad: function () {
this.ScriptNode = cc.find("ScriptNode")
},
mbu
June 10, 2016, 6:25am
3
Is the prefab in the Node tree ? If yes, you can just drag the node to the script. If it’s not in the Node tree, you can drag it from the Assets to the script.
prefab is not in the tree.
mbu
June 10, 2016, 7:52am
5
The you can just drag it to the script for the Assets tree. If you can’t do that, you should change, and then it should work.
type: cc.Node
to
type: cc.Prefab
I think you did not understand the question. I wanted to get node at the prefab. I did not want to get prefab.
As I wrote, I solve the question.