- Home /
Script updates prefab but not instantiated clone of prefab
I have a couple of sliders set to a canvas. One slider is the player's HP and the other is the Target's HP. I have a CanvasGroup added to the Target HP slider. My code checks to see if there is a target selected and if there is, it fades the CanvasGroup on just the Target slider to 1.
public Canvas hudCanvas;
CanvasGroup cg = hudCanvas.GetComponentInChildren<CanvasGroup>();
if (selectedTarget == null)
cg.alpha = 0;
else
cg.alpha = 1;
When I play my scene and target the object, the alpha changes 1 one and when I deselect the target it chances back to 0, but only on the prefab child object in my project and not the instantiated child object in the Hierarchy so the change is not showing up in the scene. How can I correct this?
Comment