private void Start() { if (SelectableMesh == null) { SelectableMesh = new Mesh(); } if (_SelectableMeshBorder == null) { _SelectableMeshBorder = new BorderPointSet[0]; } Border = GetComponent <BorderRenderer>(); Border.Points = SelectableMeshBorder; AlphaShaderID = Shader.PropertyToID("_Alpha"); if (_GroundMaterialSource != null) { GroundMaterial = new Material(_GroundMaterialSource); } if (GroundAlpha != LastGroundAlpha && GroundMaterial != null) { GroundMaterial.SetFloat(AlphaShaderID, GroundAlpha); LastGroundAlpha = GroundAlpha; } #if UNITY_EDITOR SceneView.RepaintAll(); #endif }
void Update() { // We have to detect changes this way instead of using properties because // we want to be able to animate the alpha value with a Unity animator. if (GroundAlpha != LastGroundAlpha && GroundMaterial != null) { GroundMaterial.SetFloat(AlphaShaderID, GroundAlpha); LastGroundAlpha = GroundAlpha; } }