Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JulesPomme · Oct 28, 2014 at 05:12 PM · textureaudiosoundguitexture

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...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Oct 29, 2014 at 04:35 AM

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'.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JulesPomme · Oct 29, 2014 at 10:48 AM 0
Share

Apparently you understood well because it works, thank you! But in that case, I don't really understand why I need the empty object. I tried to initialize 'toFollow' directly with the parent, and it also works. Anyway, thanks a lot for your help :)

avatar image robertbu · Oct 29, 2014 at 03:04 PM 0
Share

The parent will work as long as the position you are trying to match is the parent's position. Typically with this kind of thing, people are trying to offset the result to be above or below some world position. Think health meter floating over a character for example.

avatar image JulesPomme · Oct 29, 2014 at 03:17 PM 0
Share

Yeah right, in my case it works, but I'll keep that in $$anonymous$$d. Thanks again for the clarification!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

5.1 Channels is backwards in unity (non 3D) 0 Answers

Audio Settings Menu 2 Answers

play sound when moving stop sound when not 1 Answer

Why is my backtrack's volume getting lower? 0 Answers

3D Sound Max Distance Not Working. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges