Text Disappearing When Parent Object Moved Via its Transform

Hello developers!

I have run into an issue. I’m working on a little game, and I have set up some code that causes some ‘cards’ in the game to move around (I’m using a coroutine with a vector3.lerp thing in it). The cards are moving around like I want them to, but as soon as they start moving all the text elements on the cards disappear.

The way I have them organized is that I have a canvas game object that all the cards are children of, and then each card has some sprite children to create icons on the cards, and each icon has a text child to show a value for the stat associated with that icon.

Does anyone have any ideas why the text might be disappearing, but everything else is working as intended? I will attach an image of the hierarchy in case the way I explained it isn’t clear.

The other image shows what the cards look like after their movement (the text is missing).

Thanks for any help you can give!


1 Like

Share your code?

Maybe you’re just moving the background to be in front of the text. Is the z coordinate of the position changing?

I was able to eliminate the problem by splitting it into multiple canvases, and having the button be a part of a different canvas but this doesn’t seem like a good permanent solution and I’m not sure why it was necessary.

That being said, I’m having the same problem again now, so it’d still be helpful for me to gain some understanding. This time, I have an inactive text object with two button children. I have code that sets this to active in a certain situation, but as soon as those UI elements become active every piece of text in the canvas with them, and all the buttons, disappear.

Here’s the code that is setting them active :

void MyTurnOnClick()
    {
        if (InitiativePosition == 0)
        {
            StartCoroutine(MyTurnStart());
        }
        else
        {
            gameObject.SetActive(false);
        }
    }

IEnumerator MyTurnStart()
    {
        anim.SetTrigger("MyTurn");
        BigCard = true;

        yield return new WaitForSeconds(1);

        turnInstrucitons.SetActive(true);


        yield return null;
    }

turnInstructions is the text and buttons that are hidden on start, but should become visible when I click the start turn button. They are set correctly in the inspector.

Could this be something to do with having too much stuff in one canvas? Everything works as intended until those turnInstructions elements are set active. It’s weird though, because there just isn’t that much stuff in the canvas. There’s 7 text elements and a button. I’ll attach a picture of my current hierarchy too.

6193566--679290--Goblin hierarchy.png

It’s hard to say without having more information about what components are on those disabled objects.

Does TurnInstructions or one or more of its children have an Image component on it? Generally, UI elements that are lower down in the hierarchy are drawn after and therefore on top of elements earlier in the hierarchy. It could simply be that you have an opaque image on one or more of those objects that is covering everything else up.

1 Like

I don’t think that is it, the first attached image shows the area covered by the Turn Instructions (there should be text and buttons appearing in there.) That stuff isn’t appearing, and all the other text and buttons also disappear. The second image shows it before I click the button that’s supposed to activate the TurnInstrucitons.

6193728--679326--area.png
6193728--679329--what we want.png