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 Christian.Tucker · Nov 07, 2013 at 11:51 PM · unity 4textureing

Repeating a texture?

Trying to venture into UnityGUI here and I'm trying to attempt a Healthbar similar to the Old Mega-Man X.

http://remyvanruiten.files.wordpress.com/2013/01/full-health.png

^^For those who don't know what it is^^

No-matter what I try, the sprite is always drawn in the middle of the box.

 using UnityEngine;
 using System.Collections;
 
 public class GUIManager : MonoBehaviour 
 {
     public Texture aTexture;
     private float maxHealth;
     private float currHealth;
 
     private float TopHUDHeight = 608;
     private float HUDHeight = 162;
     
     void Start()
     {
         maxHealth = 100f;
         currHealth = maxHealth;
         aTexture.wrapMode = TextureWrapMode.Repeat;
     }
     
     void Update()
     {
         currHealth = 100f;
     }
     
     void OnGUI()
     {
         GUI.Box(new Rect(0,  TopHUDHeight, Screen.width, HUDHeight), "");
         GUI.Box (new Rect(0, TopHUDHeight, 240, HUDHeight), "Inventory/Money");
         GUI.Box (new Rect(241, TopHUDHeight,25, HUDHeight), "H\nE\nA\nL\nT\nH");
         GUILayout.BeginVertical();
         GUI.DrawTexture(new Rect(241, TopHUDHeight, 25, HUDHeight), aTexture, ScaleMode.ScaleToFit);
         GUILayout.EndVertical();
         GUI.Box (new Rect(267, TopHUDHeight, 490, HUDHeight), "Chat");
         GUI.Box (new Rect(758,TopHUDHeight,25, HUDHeight), "E\nX\nP");
         GUI.Box (new Rect(784, TopHUDHeight, 240, HUDHeight), "Gun/Ammo");    
                 
     }
     
 }
 
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 Christian.Tucker · Nov 08, 2013 at 06:10 AM 0
Share

Added my code.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Huacanacha · Nov 08, 2013 at 12:01 AM

Texture has a 'wrapMode' variable. Make sure yours is set to TextureWrapMode.Repeat and it should tile.

Comment
Add comment · Show 4 · 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 Christian.Tucker · Nov 08, 2013 at 12:07 AM 0
Share

I have Used the TextureWrap$$anonymous$$ode.Repeat as suggested, however it's not working.

avatar image Huacanacha · Nov 08, 2013 at 12:33 AM 0
Share

According to the GUI.DrawTexture docs it takes a regular Texture.

avatar image Huacanacha · Nov 08, 2013 at 01:14 AM 0
Share

Try the different Scale$$anonymous$$odes when calling DrawTexture.

avatar image Christian.Tucker · Nov 08, 2013 at 04:47 AM 0
Share

I have, nothing helps.

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

16 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Texture3D stays black no matter what? 1 Answer

Can you use Sky Light Color baking in free mobile addons, if you have standalone 4.x Pro? 1 Answer

Changing texture of one child gameobject 0 Answers

Blender texture problem! 3 Answers

Using a Gameobject for terrain. 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