查看: 1747|回复: 1
打印 上一主题 下一主题

[二次开发]Unity3D换装系统创建

[复制链接]

3795

主题

2

听众

5万

积分

版主

Rank: 7Rank: 7Rank: 7

纳金币
53202
精华
32

活跃会员 优秀版主 推广达人 突出贡献 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2012-10-12 11:31:00 |只看该作者 |倒序浏览
作者:xggxnn

  查看unity3d的换装demo,感觉比较繁琐,经自行试验,创建如下换装操作,具体步骤如下:


  1、定义需要换装的GameObject,暂定为:Player
  2、默认贴图贴好。
  3、创建脚本 Cloth.js





    var Cloth1 : Texture[];//上衣

    var Cloth2 : Texture[];//裤子

    var Properties_style : GUIStyle;//标签样式

    var int1 : int;

    var int2 : int;
    function Start()

    {

        int1 = 0;

        int2 = 0;

    }
    funciton OnGUI()

    {

        GUI.Button(Rect(20, 10, 70,20),"Cloth",Properties_style);

        GUI.Button(Rect(20, 35 + 25, 70,20),"Trousers",Properties_style);
        if (GUI.Button(Rect(100, 10, 20, 20),">"))//换上衣

        {

            int1++;

            if (int1 > Cloth1.length - 1)  int1 = 0;

            renderer.materials[0].mainTexture = Cloth1[int1];//此处materials[0]表示你衣服贴图材质球所处的位置,下面同此

        }
        if (GUI.Button(Rect(100, 35, 20, 20),">"))//换裤子

        {

            int2++;

            if (int2 > Cloth2.length - 1) int2 = 0;

            renderer.materials[1].mainTexture = Cloth2[int2];

        }

    }
    4、把Cloth.js绑[来源:GameRes.com]定到Player上,然后定义Cloth1和Cloth2这2个数组长度,放上相应的Texture,即可运行查看效果了。



来源:游资网 更多分享尽在web3D纳金网http://www.narkii.com/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

0

主题

3

听众

2063

积分

中级设计师

Rank: 5Rank: 5

纳金币
21
精华
0
沙发
发表于 2017-6-8 11:21:42 |只看该作者
谢谢分享。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-2-6 19:11 , Processed in 0.090270 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部