Warning : implicit downcast

Hi

I’m french so forgive me for the mistakes, and I’m also a noob so forgive me for my (stupie) question :

I’m getting a warning because of two implicit downcast (and I know what it means) but I can’t solve the problem :
In fact I’m trying to get a text in the child of an other child (I want to print some things for debuging in the right top corner of the screen from a script in the player object : (player > Camera > Debug text)).

@System.NonSerialized var tex : TextMesh;

// Récupération du texte / Get text
	for (var child : Transform in tr)
	{
		if(child.name == "Camera")
		{
			for (var child2 : Transform in child)
			{
				if(child2.name == "Debug Text")
					tex = child2.GetComponent(TextMesh);
			}
		}
	}

I tried write “var child : Object” instead of “var child : Transform” but it doesn’t work …

Unrelated : I made a pretty gameplay, who want to try ?

you want to print some text in the upper right corner, OnGUI? or you in 3D (<-TextMesh)?
you are looking for the Camera’s child gameobject Debug Text?
It’s not making a lot of sense to me…
If you want to Debug or print text on an event, why not just use a string and OnGUI…?
if you are trying to do something totally different then please explain the best you can.

Use #pragma downcast.

–Eric

Maybe I’m not using the right solution, but in order to find some bugs in my scene, I try to write some informations on the right top corner. To do so, I created a ‘3D Text’ which I try to access from a script in its ‘gran’father’ :

Player

Mesh
Camera

3D Text

(Notice that I dont use the debug.log function for some reasons.)

Is it better ? :stuck_out_tongue: