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 easyfun · Aug 09, 2013 at 03:20 AM · textureuvmesh rendererprogress bar

how to set the uv of the texture(or mesh renderer)

I wanna make a effect,just like a progress bar,at the begining,it is hidden,then you display the texture more and more,till display all of it ,how can i do that?

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
0

Answer by Peter G · Aug 09, 2013 at 03:36 AM

You shouldn't need to do any uv work. Just some clever texturing. Make a gradient bar then have an alpha cutoff based on how loaded the scene is.

See Eric's answer here for a good place to start.

http://answers.unity3d.com/questions/14770/creating-a-circular-progressbar-timer.html

Comment
Add comment · Show 2 · 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 easyfun · Aug 09, 2013 at 07:17 AM 0
Share

about the example ,it is very thoughtful,but not fit my situation,there shader is inaccuracy and it is not flexible,thanks for the idea.

avatar image Peter G · Aug 09, 2013 at 01:32 PM 0
Share

$$anonymous$$aybe I should have clarified that you can use multiple textures. With some basic texture combiners you can make pretty much any combination of textures work. And if you bring in multiple textures, you really aren't limited to just the alpha channel. You can use all 4 if you want to store data.

avatar image
0

Answer by robertbu · Aug 09, 2013 at 08:27 AM

I'm puzzled by your 'not flexible' and 'inaccuracy' comments to @Peter G. Care to explain?

Here are two different solutions:

  • Attach the following script to an empty game object.

  • Drag and drop a texture onto the 'tex' variable.

  • Run the app

  • Adjust 'fraction' in the inspector.


    pragma strict

    var tex : Texture; var fraction : float = 0.5; private var screenRect = new Rect(0,0,200,50); private var sourceRect = new Rect(0,0,1,1);

    function Start () { screenRect.width = tex.width; screenRect.height = tex.height; }

    function OnGUI() { if(Event.current.type.Equals(EventType.Repaint)) { fraction = Mathf.Clamp01(fraction); screenRect.width = tex.width * fraction; sourceRect.width = fraction; Graphics.DrawTexture(screenRect, tex, sourceRect, 0,0,0,0); } }

For this one:

  • Use the CreatePlane editor script to create a plane (1x1 vertical)

  • Put a material with your texture on the plane

  • Size the plane

  • Attach the script below

  • Specify the width in world units of the plane

  • Run the app and adjust the 'fraction' in the inspector.


    pragma strict

    var fraction : float = 0.5; var width : float; // World unit width

    private var position : Vector3; private var startScaleX : float; private var scale : Vector3;

    function Start () { position = transform.position; scale = transform.localScale; startScaleX = scale.x; }

    function Update() { fraction = Mathf.Clamp01(fraction); transform.localScale.x = startScaleX * fraction;

       var posT = position;
         posT.x -= width * (1.0 - fraction) * 0.5;
         transform.position = posT;
         
         renderer.material.SetTextureScale("_MainTex", new Vector2(fraction, 1.0)); 
     }
    
    
    
Comment
Add comment · Show 1 · 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 easyfun · Aug 09, 2013 at 09:09 AM 0
Share

apologize,im not a english speaker. 'not flexible' and 'inaccuracy' means it only depends on what alpha is,that way makes you can only use the alphas-in-order texture,,it could be wrong on some texture. thanks for the advises,got more ideas on this.

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

15 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

Related Questions

Assigning UV Map to model at runtime 0 Answers

Rotating Textures 0 Answers

Texturing a icosphere 0 Answers

good program for uv texturing 2 Answers

Apply uv coordinates to unity cube by script 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