private void SelectedPlaceableChanged(Placeable placeable) { selectedPlaceable = placeable; // Enable/disable panel accordingly cGroup.alpha = placeable == null ? 0 : 1f; cGroup.blocksRaycasts = placeable != null; cGroup.interactable = placeable != null; // If we have something selected, populate panel if (selectedPlaceable != null) { label.text = "Selected: " + selectedPlaceable.name; // Destroy previous color selectors foreach (ColorSelector cs in colorSelectorParent.GetComponentsInChildren <ColorSelector>()) { Destroy(cs.gameObject); } // Create new color selectors foreach (ModifyableColor modColor in placeable.modifyableColors) { ColorSelector selector = Instantiate(selectorPrefab, colorSelectorParent); selector.transform.localScale = Vector3.one; selector.SetTitle(modColor.title); selector.SetValueWithoutNotifty(modColor.current); selector.OnValueChanged += (c) => ColorSelectorValueChanged(modColor, c); } } }