- Home /
Dynamically displaying 2D textures above 3D objects
Hello. I have been working with that few hours during 2 days and I can't get what I wanted. And what I wanted? Something like gif above object (3 textures with phone and growing signal). I need visual effect of calling for reinforcement when enemy looks at player. It's my visualization:
void Preparing(){
radioTexture1.enabled = false;
radioTexture2.enabled = false;
radioTexture3.enabled = false;
}
IEnumerator Calling(){
informing = false;
for (int i=0; i<3; ++i) {
Debug.Log("I'm working! iteracja " + i);
radioTexture3.enabled = false;
radioTexture1.enabled = true;
yield return new WaitForSeconds (0.5f);
radioTexture1.enabled = false;
radioTexture2.enabled = true;
yield return new WaitForSeconds (0.5f);
radioTexture2.enabled = false;
radioTexture3.enabled = true;
yield return new WaitForSeconds (0.5f);
radioTexture3.enabled = false;
}
}
radioTextures 1-3 are GUITexture empty objects with simple texture (childs of my enemy, local position (0,2,0). Any suggestions? I'm going mad, it looks so simple ;_;
I was trying
transform.FindChild("RadarSignalTexture1").position = Camera.main.WorldToViewportPoint(transform.position + 2*Vector3.up);
and it didn't worked. When I created separate script and using similiar construction in child, it works (but texture is flying in each direction when I'm a bit far from enemy) and I can't have 3 scripts in this situation and enabling and disabling each other after 0.5s. It's a bit stupid... Please help :)
Answer by _dns_ · Oct 09, 2014 at 02:30 PM
Hi, using sprites instead of GUITexture might be a better solution. Did you check Unity's team free project/tutorial to see how they do similar things. Example: https://www.assetstore.unity3d.com/en/#!/content/11228
I saw them using sprites in 2D. It is possible to render sprites by SpriteRenderer, animate them (bool star as flag to start animation, then time and next frame of animation; everything looped for few cycles) in 3D, over the head of object?
I realy wanted effect like this: http://img2.wikia.nocookie.net/__cb20100328111233/prototype/images/c/cd/Prototype_Past_Present_Radio-1-.png
but I can't even draw picture over head without using OnGUI :/ Anyone can help me and show path to good solution?
Your answer
![](https://koobas.hobune.stream/wayback/20220613164715im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation not showing when close up 1 Answer
Bug when hiding resolution Dialog? (Settings get reset on startup) 3 Answers
How to fix display 5 Answers
Loading a Model 1 Answer
Something is missing in my code can any body help me? 0 Answers