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 ROM · Sep 02, 2010 at 11:55 AM · texturemoveguitexturehealth

Moving a GUITexture?

Basically I have a health bar (GUITexture) and I want it to slowly move in at the start of the game, moving between two points. I could of course move it by invoking a method that offsets it by a few pixels every 0.1 seconds or something but I was wondering if there was a cleaner way to move it?

Thanks in advance

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by AtomicMarine · Jan 12, 2011 at 08:11 PM

Try this code it might work.

Use a Update then get the GUI to move to a certain position and run a check. Just replace the x and y values with your respective values and remember to start with your starting position as your default also put ur GUITexture in an empty game object with a position of (0,0,0) and set your GUI texture's position to 0,0,0 and use the pixel inset as opposed to the transform as its more accurate

var gui : GUITexture; var pos : Vector2(x,y); var size : Vector2(x,y);

function Update{

//moving it along the x axis if (pos.x != 40){

//the 0.1 wil make it move slowly, increase this value to make it move in faster gui.pixelInset = Rect(pos.x + 0.1,pos.y,size.x,size.y);

}else{

gui.pixelInset = Rect(pos.x,pos.y,size.x,size.y); }

}

Comment
Add comment · 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
0

Answer by · Sep 02, 2010 at 12:52 PM

Take a look at Vector3.Lerp. I haven't used GUITextures before, but it looks you can move them by setting transform.position.

There's an example given, but you'd probably want to adapt it by invoking a coroutine on Start(), rather than having it constantly updated past the first second.

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

How can i avoid mouse clicking on alpha areas in my GUITexture? 1 Answer

GUI Texture disapears when I move it 1 Answer

Guitexture appear/disappear 1 Answer

Get GUITexture to follow ScreenPointToRay ray cast 1 Answer

How to script GUI Texture Window to see it in Script (Object's component) 1 Answer


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