游戏开发论坛

 找回密码
 立即注册
搜索
查看: 9363|回复: 1

Unity3D换装系统浅析

[复制链接]

65

主题

171

帖子

641

积分

高级会员

Rank: 4

积分
641
发表于 2012-9-5 00:54: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绑定到Player上,然后定义Cloth1和Cloth2这2个数组长度,放上相应的Texture,即可运行查看效果了。

0

主题

6

帖子

48

积分

注册会员

Rank: 2

积分
48
发表于 2013-3-20 14:26:37 | 显示全部楼层
换材料而已啊,你这个衣服不能飘动啊
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-12 17:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表