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 Fewpwew130 · Dec 28, 2014 at 11:34 AM · texturebar

Progress bar UI

Hey everyone! I would like to make a bar shrink/enlarge as time passes. How is it possible to do?

To test: I have a GUI texture of specific size. I've written a script to change its size as a button is pressed, but it doesn't work. Could you help me please?

Here's the script:

 using UnityEngine;
 using System.Collections;
 
 public class barscript : MonoBehaviour {
 
     public GUITexture guii1;
 
     // Use this for initialization
     void Start () {
     guii1 =    GameObject.Find("_GUI Stuff/GUI0").GetComponent<GUITexture>();
     }
     
     // Update is called once per frame
     void Update () {
         if(Input.GetKeyUp(KeyCode.Space))
         {
             guii1.texture.height = guii1.texture.height +15;
     
         }
     }

error: "Exception: not implemented UnityEngine.Texture.set_height (Int32 value)..."

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 jakovd · Dec 28, 2014 at 11:46 AM 0
Share

You are resizing the texture. You should resize the size of the plane/sprite/image object that the texture is on.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by EggQuiz857 · Jan 01, 2015 at 05:14 AM

What I have done is animate a plain and stretch it. It might be the most simple way.

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 Fewpwew130 · Dec 28, 2014 at 01:27 PM

Thank you, can you tell me please how to resize the image then? :)

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 jakovd · Dec 28, 2014 at 01:39 PM 0
Share

Yes I can. Image, as an UI component is added to a gameobject that also has RectTransform component. Through code you would change its size using:

 transform.GetComponent<Rect>.Set(float left, float top, float width, float height);


avatar image Fewpwew130 · Dec 30, 2014 at 02:51 PM 0
Share

I am very sorry, but I failed to understand. Let's try it super simple. I want to resize a 2d picture as UI element (not a plane, because it's a multiplayer game and other players would be able to see it in that case). For that purpose I created an Empty. I added Rect Transform component to it. Now how do I add image I want? I try to drag it over, but it doesn't allow to place it there.

avatar image jakovd · Dec 30, 2014 at 03:20 PM 0
Share

I suggest you start with offical UI tutorials. By the time you finish lesson 4, you will understand this much better.

And don't get me wrong, but multiplayer games are too complicated to start with if you are having problems with this kind of stuff. Start with something simpler.

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

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

Related Questions

Assigning UV Map to model at runtime 0 Answers

Mask a HP Bar 0 Answers

Invert Texture 0 Answers

Food bar help 1 Answer

Floating Health Bars 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