Reactivated models are not showing up

So, I have a script that will set single models in a game object to active or inactive based on what a slider position is. Also, all models are set to inactive when the script first starts.

When following the script variables it appears to work as expected, but in the preview screen the screen will load and my first model, associated to the default first position, will load. I move the slider to position 2 and the model for 2 is made visible. The problem comes when I try to move the slider back to 1. When its set back to 1, model 2 will disappear, but model 1 doesnt appear to come back.

Here is the script that updates the body part. If any other info or code is needed, let me know.

function updateBody(num,part) 
{
         if(!tempHead.Equals(part[num-1]))         
         {
              tempHead.SetActiveRecursively(false);
              tempHead.renderer.enabled = false;
              tempHead = part[num-1];
              tempHead.renderer.enabled = true;
              tempHead.SetActiveRecursively(true);
         }
}

Bump.

Let me know if any other code or info is needed.

Thanks.

Looks like you are editing the variables of a deactivated game object. Haven’t got unity handy to test, but I’ve always assumed thats a no-no.

The renderer aspect of the code was added as an after thought. Was getting desperate. If I cant make a disable/enable function work properly then I will probably just use a transform and move each object off the screen when not needed. This is just a menu screen, so extra models arent too much of an issue right now.

Bump again :slight_smile:

So, this may be just an issue with my menu or something I dont understand.

I changed my script to just change the local position since each object is attached to a main object. With the location change in place my script behaves the same.

Menu loads with the model and the first model for the head is visible. Head 2 is not visible. (head 1 and 2 local positions are listed in the inspector correctly)
-Expected behavior
I move the slider to select head number 2. Head number 2 is visible and 1 is not. (head 1 and 2 local positions are listed in the inspector correctly)
-Expected behavior
I move the slider back to head 1. Now head 1 and 2 are not visible. (head 1 and 2 local positions are listed in the inspector correctly)
-Not expected
I move the slider back to head 2. Now head 2 is visible and 1 is not visible. (head 1 and 2 local positions are listed in the inspector correctly)
-Expected bahavior

I have tried disabling a renderer, setactiverecursively and changing position with the same results. So, my question is, is there some function I need to call to have models reloaded or something?