• assetdatabase.addobjecttoasset 添加对象到资源 - 脚本手册 - -【游戏蛮牛】-游戏出海,ar增强现实,虚拟现实,unity3d,unity3d教程下载首选u3d,unity3d官网 - Powered by Discuz!
     找回密码
     注册帐号

    扫一扫,访问微社区

    assetdatabase.addobjecttoasset 添加对象到资源

    2014-12-31 17:51| 发布者: 杨炎| 查看: 2409| 评论: 0|原作者: 蛮牛|来自: unity3d脚本manual

    摘要: assetdatabase.addobjecttoasset 添加对象到资源static functionaddobjecttoasset(objecttoadd:object,assetpath: string) : voiddescription描述adds objecttoadd to an existing asset at path.将objecttoadd这个 ...

    assetdatabase.addobjecttoasset 添加对象资源

    static functionaddobjecttoasset(objecttoadd:object,assetpath: string) : void

    description描述

    adds objecttoadd to an existing asset at path.

    将objecttoadd这个对象添加到指定路径上的现有资源。

    please note that you should only add assets to '.asset' assets, imported models or texture assets for example will lose their data. all paths are relative to the project folder. like: "assets/mytextures/hello.png"

    请注意,你应该添加资源到”.assets”目录下的资源中,例如导入模型纹理将会丢失它们地数据。所有的路径都是相对于工程目录文件。 例如” assets/mytextures/hello.png”。

    @menuitem("gameobject/creatematerial")

    static function creatematerial () {

    // create a simple material asset

    //新建一个简单的材质资源

    var material = newmaterial(shader.find("specular"));

    assetdatabase.createasset(material, "assets/mymaterial.mat");

    // add an animation clip to it

    //添加一个动画剪辑到材质上

    var animationclip = newanimationclip();

    animationclip.name = "my clip";

    assetdatabase.addobjecttoasset(animationclip, material);

    // reimport the asset after adding an object.

    //在新建一个对象后重新导入资源

    // otherwise the change only shows up when saving the project

    //否则这个更改只会在保存工程时才显示

    assetdatabase.importasset(assetdatabase.getassetpath(animationclip));

    // print the path of the created asset

    //打印新建的资源

    debug.log(assetdatabase.getassetpath(material));

    }

    o static functionaddobjecttoasset(objecttoadd:object,assetobject: object) : void

    description描述

    adds objecttoadd to an existing asset identified by assetobject.

    将objecttoadd这个对象添加到assertobject定义的资源上。

    please note that you should only add assets to '.asset' files, imported models or texture assets for example will lose their data when reimporting or quitting unity.

    请注意,你只能添加资源到”.asset”文件中,例如导入模型或纹理在重新导入或退出unity时将会丢失数据。

    @menuitem("gameobject/creatematerial")

    static function creatematerial () {

    // create a simple material asset

    //新建一个新的材质资源

    var material = newmaterial(shader.find("specular"));

    assetdatabase.createasset(material, "assets/mymaterial.mat");

    // add an animation clip to it

    //添加一个动画剪辑到材质上

    var animationclip = newanimationclip();

    animationclip.name = "my clip";

    assetdatabase.addobjecttoasset(animationclip, material);

    // reimport the asset after adding an object.

    //添加对象后重新导入资源

    // otherwise the change only shows up when saving the project

    //否则这个更改只会在保存工程时才显示

    assetdatabase.importasset(assetdatabase.getassetpath(animationclip));

    // print the path of the created asset

    //打印新建的资源

    debug.log(assetdatabase.getassetpath(material));

    }

    相关阅读

    文章点评
    相关文章