怎样在不知道脚本名字情况下加载脚本

  • Creator 版本: <3.3>
    public static addPrefabToNode(Path:string, Parent:Node, …args:any[]){
    assetManager.loadBundle(Path,Prefab,null,(error,data)=>{
    if(error == null)
    {
    let node:Node = instantiate(data);
    Parent.addChild(node);
    let scr = node.getComponent(Script);//报错
    scr.init(args);
    }
    else
    {
    console.log(“加载预设出差:”+ Path +" "+error);
    }
    });
    }
    如上述函数,想封装一个方法将一个预设添加到某节点上,然后可能需要传参给新加的预设,所以需要获取绑定在预设上的脚本,但是写node.getComponent(Script)时,会报错,查了原因,是因为Script是继承于asset的,而不是component,所以会报错,但是脚本又是确确实实绑在预设上的,也能够通过components获取到脚本的component,但是就是获取不到脚本,现在的cocos cerator3.3,有没有集成的方法,像getComponent(Label)这样的方法来获取未知名称,但是却确实绑定在预设上面的脚本,有没有不通过脚本名称和路径的方法获取脚本的方法,请各位大佬赐教

2.x可以直接传脚本名作为字符串
3.x不知道行不行

如果比较统一可以弄个父类然后其他子类都继承这个父类各自实现, 然后getComponet(父类)应该是可以获取到各自的子类的
大杀器就是自己去遍历node上的_components找