PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > Unity3D教程 > 正文

    关于Prefab

    作者:张志勇来源:原创浏览:时间:2020-09-30 00:07:50我要评论
    导读:创建预设体,创建物体,替换预制

    创建预设体:把一个物体生成为预设体

    PrefabUtility.CreatePrefab(路径,需要生成预设体的物体,替换预制(参数可更改));

    PrefabUtility.CreatePrefab("Assets/myTest.prefab",myCube,ReplacePrefabOptions.ConnectToPrefab);

    通过预设体动态创建物体

    Game test1=(Game )Instantiate(Resources.Load("TestCube"));

    Game test2=Game .Find("Sphere");

    test1.transform.parent=test2.transform;

    这个和上边的基本一样,自己看

    Game test1=(Game )Instantiate(Resources.Load("TestCube"),transform.position,transform.rotation);

    注意:使用预设体时,更改任何,都需要apply

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-130-5979-1.html
    相关热词搜索: