void Awake() { selectable = GetComponent <Selectable>(); destruct = GetComponent <Destructible>(); unique_id = GetComponent <UniqueID>(); renders.AddRange(GetComponentsInChildren <MeshRenderer>()); foreach (MeshRenderer render in renders) { foreach (Material material in render.sharedMaterials) { bool valid_mat = material && MaterialTool.HasColor(material); Material material_normal = valid_mat ? new Material(material) : null; Material material_trans = valid_mat ? new Material(material) : null; if (material_trans != null) { MaterialTool.ChangeRenderMode(material_trans, BlendMode.Fade); } materials.Add(material_normal); materials_transparent.Add(material_trans); materials_color.Add(valid_mat ? material.color : Color.white); } } foreach (Collider collide in GetComponentsInChildren <Collider>()) { if (collide.enabled && !collide.isTrigger) { colliders.Add(collide); } } }
void Awake() { see_list.Add(this); select = GetComponent <Selectable>(); renders = GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer render in renders) { foreach (Material material in render.sharedMaterials) { bool valid_mat = material && MaterialTool.HasColor(material); Material material_normal = valid_mat ? new Material(material) : null; Material material_trans = valid_mat ? new Material(material) : null; if (material_trans != null && valid_mat) { material_trans.color = new Color(material_trans.color.r, material_trans.color.g, material_trans.color.b, material_trans.color.a * opacity); MaterialTool.ChangeRenderMode(material_trans, BlendMode.Fade); } materials.Add(material_normal); materials_transparent.Add(material_trans); } } }