public static void Init() { if (instance != null) { return; } instance = new UMaterials(); // rect、ellipseなどマテリアルカラー使用 #if UNITY_STANDALONE // GPUインスタンシングあり fillMaterials[(int)BlendMode.Opaque] = load("Unicessing/Materials/FillOpaqueInstanced"); //fillMaterials[(int)BlendMode.Transparent] = instance.load("Unicessing/Materials/FillTransInstanced"); fillMaterials[(int)BlendMode.Transparent] = load("Unicessing/Materials/FillTrans"); fillMaterials[(int)BlendMode.Add] = load("Unicessing/Materials/FillAddInstanced"); #else fillMaterials[(int)BlendMode.Opaque] = load("Unicessing/Materials/FillOpaque"); fillMaterials[(int)BlendMode.Transparent] = load("Unicessing/Materials/FillTrans"); fillMaterials[(int)BlendMode.Add] = load("Unicessing/Materials/FillAdd"); #endif fillUnlitMaterials[(int)BlendMode.Opaque] = load("Unicessing/Materials/FillUnlitOpaque"); fillUnlitMaterials[(int)BlendMode.Transparent] = load("Unicessing/Materials/FillUnlitTrans"); fillUnlitMaterials[(int)BlendMode.Add] = load("Unicessing/Materials/FillUnlitAdd"); // line、pointなど頂点カラー使用 strokeMaterials[(int)BlendMode.Opaque] = load("Unicessing/Materials/StrokeOpaque"); strokeMaterials[(int)BlendMode.Transparent] = load("Unicessing/Materials/StrokeTrans"); strokeMaterials[(int)BlendMode.Add] = load("Unicessing/Materials/StrokeAdd"); }
private Material findMaterial() { if (isFillShape) { if (nowStyle.isLighting) { return(UMaterials.getFillMaterial(nowStyle.blendMode)); } else { return(UMaterials.getFillUnlitMaterial(nowStyle.blendMode)); } } else { return(UMaterials.getStrokeMaterial(nowStyle.blendMode)); } }
public void draw(Matrix4x4 matrix, Color col, Texture tex, int layer, Camera camera) // for Update { Material material = findMaterial(); materialPB.Clear(); materialPB.SetColor("_Color", col); if (isFillShape && tex != null) { materialPB.SetTexture("_MainTex", tex); } UGraphics.UStyle nstyle = nowStyle; for (int i = 0; i < mesh.subMeshCount; i++) { if (i == wireframeSubmeshIndex) { if (!nstyle.isStroke) { continue; } material = UMaterials.getFillUnlitMaterial(nstyle.blendMode); materialPB.Clear(); materialPB.SetColor("_Color", nstyle.strokeColor); } else if (isFillShape && !nstyle.isFill) { continue; } Graphics.DrawMesh(mesh, matrix, material, layer, camera, i, materialPB); } foreach (UShape shape in children) { shape.draw(matrix, col, tex, layer, camera); } }