void SetDissolveValue(int isOn, float diss, bool activeParaicels) { if (SMR != null && SMR.Length > 0) { foreach (var s in SMR) { if (s != null && s.sharedMesh != null) { for (int i = 0; i < s.sharedMesh.subMeshCount; i++) { s.GetPropertyBlock(MPB, i); MPB.SetInt(dissolveOn, isOn); MPB.SetFloat(dissolveAmount, diss); s.SetPropertyBlock(MPB, i); } } } } if (particels != null && particels.Length > 0) { foreach (var ps in particels) { if (ps != null && ps.gameObject.activeSelf != activeParaicels) { ps.gameObject.SetActive(activeParaicels); } } } }
/// <summary> /// 开启角色的边缘光效果 /// </summary> /// <param name="state">true开启,false关闭</param> /// <param name="col">边缘光颜色</param> /// <param name="width">边缘光宽度,0最宽,角色全亮,10以上很窄</param> public void SetEdgeLit(bool state, Color col, float width) { if (SMR == null || SMR.Length < 1) { return; } foreach (var smr in SMR) { int matCount = smr.sharedMaterials.Length; for (int i = 0; i < matCount; i++) { smr.GetPropertyBlock(MPB, i); if (state) { MPB.SetInt(edgeLightId, 1); MPB.SetFloat(edgeColorWidthId, width); MPB.SetColor(edgeColorId, col); } else { MPB.SetInt(edgeLightId, 0); } smr.SetPropertyBlock(MPB, i); } } }
private void SetPosClipValue(int isOn, float zPos, Color color) { if (SMR == null || SMR.Length < 1) { return; } Matrix4x4 localSpace = transform.worldToLocalMatrix; foreach (var r in SMR) { for (int i = 0; i < r.sharedMesh.subMeshCount; i++) { r.GetPropertyBlock(MPB, i); MPB.SetMatrix(localSpaceProp, localSpace); MPB.SetInt(_UsePosClipProp, isOn); MPB.SetFloat(_PosMaskZProp, zPos); MPB.SetColor(_PosMaskEdgeColorProp, color); r.SetPropertyBlock(MPB, i); } } }