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 Crimson Valor · Dec 10, 2012 at 01:25 PM · guierrortexture

GUI Texture error.

I'm trying to make a Power bar work for my game, I have all my textures and the code for it count from 0 to 1000 and back to 0. Whilst it is counting to 1000 I want the GUI Texture to display the bar moving up and down. But I keep getting this error. Anyone help?

 var currentPower:int = 0;
 var maxPower:int = 1000;
 var Power0:Texture2D;
 var Power10:Texture2D;
 var Power20:Texture2D;
 var Power30:Texture2D;
 var Power40:Texture2D;
 var Power50:Texture2D;
 var Power60:Texture2D;
 var Power70:Texture2D;
 var Power80:Texture2D;
 var Power90:Texture2D;
 var Power100:Texture2D;
 var PowerBarIsRising :boolean = true;
 var barSpeed :float = 5.0;
 var powerToApply :int;
 var powerBar:GUITexture;
 
 
 
 function Start () {
     powerBar= GameObject.Find("PowerBar");
     powerBar.guiTexture.texture = Power100;![alt text][1]
 }
 


[1]: /storage/temp/5674-error.png

error.png (10.7 kB)
Comment
Add comment · Show 1
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 landon912 · Dec 11, 2012 at 01:30 AM 0
Share

Hmmm, of topic but still, I don't recommend doing a health bar this way ins$$anonymous$$d you can use pixel offset and scale a GUITexture behind a border GUI.

1 Reply

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

Answer by Lockstep · Dec 11, 2012 at 01:25 AM

You declare powerBar as GUITexture but during start you pass a GameObject to it. Change the line

 var powerBar : GUITexture;


to

 var powerBar:GameObject;

and it should work as intended.

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Compnent.guiTexture is obsolete 1 Answer

Wearied Error 1 Answer

Issue with Drawing a GUI texture 0 Answers

Sprites and minmizing memory usage 1 Answer

How to place/add a HD image/picture in background of my game? 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