The realization of the Unity3d game development system

Source: Internet
Author: User

There are two kinds of dress-up: add-on, update-dress

one, Add-on Dress Up

The so-called add-on, refers to the role model of the body is a complete mesh, the need to replace the part is only a detachable part, so the facelift is actually in a particular part of the increase or remove a model. This kind of dressup is usually used in the role of the weapon replacement, the paladin, acient martial arts Change is this type, the fish bone is just in hand this position replacement model:

second, the renewal of the dress-up

A more modern facelift refers to a role that has a common skeleton network and several sets of maps for that model. then, at this time the dress up is actually the stickers to the corresponding position to achieve the role of the change in appearance, the Paladin is strictly speaking should not be a facelift, it is actually done two sets of models (jade/savage outfit). Gujian Tan's Dressup is actually this type of dress up, here we take an example, to learn how to achieve this type of DRESSUP. First we create a unity project:

First we go to download the official offer example of the dressup, we only need the model inside, because this model provides multiple sets of stickers that we can use. We drag the model to the scene, we expand the model can be found that the model is composed of several parts, each model has a skinnedmeshrenderer component, change the material of the component, we can achieve specific parts of the dress up. As a result, we write the following code:

usingunityengine;usingsystem.collections; public classChangeskin:monobehaviour {//Eye Stickers     publictexture2d[] textureeyes; //face Map-front     publictexture2d[] TextureFace1; //face Map-rear     publictexture2d[] TextureFace2; //Hair Map-front     publictexture2d[] TextureHair1; //Hair Map-rear     publictexture2d[] TextureHair2; //Bottom Coat Stickers-front     publictexture2d[] TexturePants1; //Bottom Coat Sticker-rear     publictexture2d[] TexturePants2; //Top Map-front     publictexture2d[] TextureTop1; //Top Map-rear     publictexture2d[] TextureTop2; //Shoe Stickers-front     publictexture2d[] TextureShoes1; //Shoe stickers-rear     publictexture2d[] TextureShoes2; //Skinnedmeshrenderer corresponding to the mapSkinnedmeshrenderer mesheyes;    Skinnedmeshrenderer MeshFace1;    Skinnedmeshrenderer MeshFace2;    Skinnedmeshrenderer MeshHair1;    Skinnedmeshrenderer MeshHair2;    Skinnedmeshrenderer MeshPants1;    Skinnedmeshrenderer MeshPants2;    Skinnedmeshrenderer MeshTop1;    Skinnedmeshrenderer MeshTop2;    Skinnedmeshrenderer MeshShoes1;        Skinnedmeshrenderer MeshShoes2; voidStart () {//Get SkinnedmeshrendererMesheyes=transform. Find ("Eyes"). Getcomponent<skinnedmeshrenderer>(); MeshFace1=transform. Find ("face-1"). Getcomponent<skinnedmeshrenderer>(); MeshFace2=transform. Find ("face-2"). Getcomponent<skinnedmeshrenderer>(); MeshHair1=transform. Find ("hair-1"). Getcomponent<skinnedmeshrenderer>(); MeshHair2=transform. Find ("hair-2"). Getcomponent<skinnedmeshrenderer>(); MeshPants1=transform. Find ("pants-1"). Getcomponent<skinnedmeshrenderer>(); MeshPants2=transform. Find ("pants-2"). Getcomponent<skinnedmeshrenderer>(); MESHTOP1=transform. Find ("top-1"). Getcomponent<skinnedmeshrenderer>(); MESHTOP2=transform. Find ("top-2"). Getcomponent<skinnedmeshrenderer>(); MeshShoes1=transform. Find ("shoes-1"). Getcomponent<skinnedmeshrenderer>(); MeshShoes2=transform. Find ("shoes-2"). Getcomponent<skinnedmeshrenderer>(); }        voidOngui () {if(guilayout.button ("Show Exterior Pack 1", Guilayout.height ( -)) {setskin (mesheyes,textureeyes[0]); Setskin (meshface1,textureface1[0]); Setskin (meshface2,textureface2[0]); Setskin (meshhair1,texturehair1[0]); Setskin (meshhair2,texturehair2[0]); Setskin (meshpants1,texturepants1[0]); Setskin (meshpants2,texturepants1[0]); Setskin (meshtop1,texturetop1[0]); Setskin (meshtop2,texturetop2[0]); Setskin (meshshoes1,textureshoes1[0]); Setskin (meshshoes2,textureshoes2[0]); }              if(guilayout.button ("Show Exterior Pack 2", Guilayout.height ( -)) {setskin (mesheyes,textureeyes[1]); Setskin (meshface1,textureface1[1]); Setskin (meshface2,textureface2[1]); Setskin (meshhair1,texturehair1[1]); Setskin (meshhair2,texturehair2[1]); Setskin (meshpants1,texturepants1[1]); Setskin (meshpants2,texturepants1[1]); Setskin (meshtop1,texturetop1[1]); Setskin (meshtop2,texturetop2[1]); Setskin (meshshoes1,textureshoes1[1]); Setskin (meshshoes2,textureshoes2[1]); }    }        Private voidSetskin (skinnedmeshrenderer mrenderer,texture2d mtexture) {mRenderer.material.mainTexture=mtexture; }        }

Here we offer two sets of exterior attire. We drag and drop the script onto the model and edit the map array:

Once you've edited the map, we're ready to run the program, and notice that the map matches the model GRID.

This method requires the designer to fully understand the internal structure of the Character's body, so it is necessary to work well with the artist to Achieve.

The source of this article: http://blog.csdn.net/qinyuanpei/article/details/24393683

The realization of the Unity3d game development system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.