我应用着色器的方式是基本的
var shader : Shader;
function Start () {
transform.GetComponent(Renderer).material.shader = shader;
}
着色器本身只是资产商店的TSF Toon Shader。我只是改变了属性。
Properties {
[MaterialToggle(_OUTL_ON)] _Outl ("Outline", Float) = 1 //0Changed
[MaterialToggle(_TEX_ON)] _DetailTex ("Enable Detail texture", Float) = 0 //1
_MainTex ("Detail", 2D) = "white" {} //2
_ToonShade ("Shade", 2D) = "white" {} //3
[MaterialToggle(_COLOR_ON)] _TintColor ("Enable Color Tint", Float) = 1 //4 //Changed
_Color ("Base Color", Color) = (1,1,1,1) //5
[MaterialToggle(_VCOLOR_ON)] _VertexColor ("Enable Vertex Color", Float) = 0//6
_Brightness ("Brightness 1 = neutral", Float) = 1.0 //7
[MaterialToggle(_DS_ON)] _DS ("Enable DoubleSided", Float) = 0 //8
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull mode", Float) = 2 //9
_OutlineColor ("Outline Color", Color) = (0,0,0,1.0) //10 //Changed
_Outline ("Outline width", Float) = 2 //11 //Changed
[MaterialToggle(_ASYM_ON)] _Asym ("Enable Asymmetry", Float) = 0 //12
_Asymmetry ("OutlineAsymmetry", Vector) = (0.0,0.25,0.5,0.0) //13
[MaterialToggle(_TRANSP_ON)] _Trans ("Enable Transparency", Float) = 0 //14
[Enum(TRANS_OPTIONS)] _TrOp ("Transparency mode", Float) = 0 //15
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 //16
}
然而,即使是完全新的Unity 5.3.5项目中的基本代码也不能正确应用着色器。 (有时它根本不适用,并且从所有角度都保留白色无阴影颜色,有时它在运行时单击着色器组件之前不适用,有时在运行时单击对象之前不适用。)