Draw a waveform on a mobile texture

Hello there. I want to draw an outputting sound waveform on a texture that is supposed to move with a given 2D GameObject ‘A’ (typically to be drawn upper the head of a character). As I want this texture to be a prefab afterward (I want to display it above many other characters) it would be very convenient for me to make it a child of ‘A’. Right now, what I’m doing is to draw the waveform on a GUITexture, created as a child of ‘A’. However, as you already know, the location of the GUITexture is different from the other GameObjects (positions are scaled between 0 and 1), and cannot move properly with its parent. As far as I can see, whatever the solution I choose (keeping it as a child of ‘A’ or not), I will have to manipulate the transform.location and the Pixel Insets in a very inconvenient way, whereas it would be very simple with another type of object, being a simple child of ‘A’. I hope I’m clear.

My question is the following: is there any way to put back the GuiTexture transform.position to a normal scale ? If not, can I use another type of object to draw inside dynamically ? I was hoping I could do it in an empty sprite, but I can’t find anything about this on the internet…

I read your question when it first came across the list and again just now. I’m still not sure I understand. My suggestion is to do the following:

  • Place an empty game object where the position where you want your GUITexture
  • Make that empty game object a child of the object that is currently the parent of your GUITexture
  • Don’t make the GUITexture a child

Attach the following script to the GUITexture:

#pragma strict

var toFollow : Transform;

function LateUpdate() {
    transform.position = Camera.main.WorldToViewportPoint(toFollow);
}

You would initialize toFollow by draging and dropping the empty ‘marker’ game object on the ‘toFollow’ variable. Note that you would not manipulate ‘pixelInset’.