我們制造一個子彈的模型
1 首先設置3d max中參數,設置Customize->Units Setup Metic為厘米
2 建模,這里我們使用plane,一個平面,如圖
3 然后導出
4 unity中模型設置,如圖
在這里有個參數Scale Factor,這個參數很重要,設置小了,導致在unity里面可能看不到,大了又不合適。
5 創建一個material
6 創建一個shader,把這個shader賦值給剛才創建的material
這里的shader代碼如下
Shader "AngryBots2/FX2/Additive" { Properties { _MainTex ("Base", 2D) = "white" {} _TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0) } CGINCLUDE #include "UnityCG.cginc" sampler2D _MainTex; fixed4 _TintColor; half4 _MainTex_ST; struct v2f { half4 pos : SV_POSITION; half2 uv : TEXCOORD0; }; v2f vert(appdata_full v) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); return o; } fixed4 frag( v2f i ) : COLOR { return tex2D (_MainTex, i.uv.xy) * _TintColor; } ENDCG SubShader { Tags { "RenderType" = "Transparent" "Reflection" = "RenderReflectionTransparentAdd" "Queue" = "Transparent"} Cull Off Lighting Off ZWrite Off Fog { Mode Off } Blend One One Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest ENDCG } } FallBack Off }
7,創建texture,從這個shader中可以看出,使用的是一張2d紋理圖片,把這個2d紋理圖片拖到正確的位置上
8 material效果如下
9 最終射出的子彈效果圖如下
以上就是設置的全過程。
這里需要我們對shader有個簡單的了解。