public void ToDark() { DarkRevert(); Renderer[] renderList = GetComponents <Renderer>(); foreach (Renderer r in renderList) { Material[] mList = r.materials; int nMatIDValue = 0; foreach (Material m in mList) { foreach (int nMatID in m_DarkList) { if (nMatIDValue == nMatID) { string strProperty = "_Emission"; Color clr = m.GetColor(strProperty); if (null != clr) { MaterialPropertyItem item = new MaterialPropertyItem(); item.matValue = m; item.strPropertyName = strProperty; item.clrValue = clr; m_matDarkPropertyTemp.Add(item); m.SetColor(strProperty, Color.black); m.SetColor("_Color", Color.gray); } break; } } nMatIDValue += 1; } } }
public void AddPropertyItemInfor(int dataIndex, MaterialPropertyItem propertyItem) { #if UNITY_EDITOR foreach (var item in m_AllShaderPropertys.Values) { if (item == null) { Debug.LogEditorInfor("当前材质球中有一个材质球属性为空 Index=" + m_MaterialIndex); continue; } } #endif if (m_AllShaderPropertys.ContainsKey(dataIndex)) { Debug.LogError("重复的材质球Shader 属性ID={0} ,确认需要传值正确 ??? ", dataIndex); return; } m_AllShaderPropertys.Add(dataIndex, propertyItem); }