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

    加载资源Resources以及加载资源错位问题

    作者:张志勇来源:原创浏览:时间:2020-09-30 00:07:50我要评论
    导读:加载资源Resources例:Resources文件下有个MyImage加载资源cubePreb = Resources.Load("MyImage",typeof(Game ));生成Game cube= Inst...

    加载资源Resources

    例:Resources文件下有个MyImage

    加载资源

    cubePreb = Resources.Load("MyImage",typeof(Game ));

    生成

    Game cube= Instantiate(cubePreb) as Game ;

    设置父类

    cube.transform.parent = game .transform;

     

    错位

    g3.transform.SetParent(this.transform,false);

    Canvas是UnityEngine下的,不开源,这个方法不受父类影响

    加载图片

    void Start(){

    //实例化空的游戏对象

    Game pic =new Game ("Gray");

    //加载图片,进行接收

    Sprite spr = Resources.Load("Gray");

    //添加加载到的图片资源到2D精灵组件

    pic.AddComponent().sprite = spr;   

    }}

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