public void UpdateSelectedMaterials() { if (outlineMesh) { SyncOutlineGameObject(); } UpdateOutlineGameObjectSelected(); int materialLength = outlineGameObject ? unselectedMaterials.Length : unselectedMaterials.Length * 2; if (selectedMaterials == null || materialLength != selectedMaterials.Length) // avoid GC alloc on subsequent calls { selectedMaterials = new Material[materialLength]; } for (int i = 0; i < unselectedMaterials.Length; i++) { Color color; if (unselectedMaterials[i].HasProperty("_Color")) { color = unselectedMaterials[i].color + highlightMaterial.GetColor("_TintColor") / 3; } else { color = unselectedMaterials[i].GetColor("_TintColor") + highlightMaterial.GetColor("_TintColor") / 3; } color.a = 1.0f; Material material = MaterialCache.MaterialByColor(color, renderMesh, renderWireframe, renderNormals, textureCacheId); selectedMaterials[i] = material; if (!outlineGameObject) { selectedMaterials[i + unselectedMaterials.Length] = outlineMaterial; } } }
public void UpdateStickySelectedMaterial() { Color color = material.color * stickySelectedMaterial.color; color.a = 1.0f; blendedStickySelectedMaterial = MaterialCache.MaterialByColor(color, true, true, true); }
public static List <UnityEngine.Material> GetMaterials(Mesh mesh) { List <UnityEngine.Material> materials = new List <UnityEngine.Material>(); List <Material> mmMaterials = mesh.materials.GetMaterials(); foreach (Material mmMaterial in mmMaterials) { UnityEngine.Material material = MaterialCache.MaterialByColor(mmMaterial.color, mesh.GetRenderMesh(), mesh.GetRenderWireframe(), mesh.GetRenderNormals()); materials.Add(material); } return(materials); }
public void UpdateStickySelectedMaterials() { blendedStickySelectedMaterials = new Material[unselectedMaterials.Length]; for (int i = 0; i < unselectedMaterials.Length; i++) { if (stickySelectedMaterial) { Color color = unselectedMaterials[i].color * stickySelectedMaterial.color; color.a = 1.0f; blendedStickySelectedMaterials[i] = MaterialCache.MaterialByColor(color, renderMesh, renderWireframe, renderNormals, textureCacheId); } else { Color color = unselectedMaterials[i].color * Color.red; color.a = 1.0f; blendedStickySelectedMaterials[i] = MaterialCache.MaterialByColor(color, renderMesh, renderWireframe, renderNormals, textureCacheId); } } }
public static UnityEngine.Material MaterialToInstance(Mesh mesh, Material material, bool noWireframe = false) { return(MaterialCache.MaterialByColor(material.color, mesh.GetRenderMesh(), mesh.GetRenderWireframe(), mesh.GetRenderNormals())); }
public static UnityEngine.Material MaterialToInstance(Material material, bool renderMesh, bool renderWireframe, bool renderNormals) { return(MaterialCache.MaterialByColor(material.color, renderMesh, renderWireframe, renderNormals)); }