Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can I modify the uv position of the image in GUI widget?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Leon, May 15, 2008.

  1. Leon

    Leon

    Joined:
    May 15, 2008
    Posts:
    4
    Hello everyone, I got a problem. And I come from China, my english is not very good. I hope you can understand my meaning.

    As the title, i want to pick a small part of the image in a texture, and put it in a GUI widget, but i do not know how to modify the uv position.

    I'm appreciate if anyone can help me.
    Thank you very much.
     
  2. mjjw

    mjjw

    Joined:
    Nov 12, 2005
    Posts:
    59
    I had the same problem and when I solved it I uploaded the GUIx script to Unify script wiki.
     
  3. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    And to help the original poster, mjjw's script can be found here.

    Not sure if Leon knows the wiki site URL.
     
  4. Leon

    Leon

    Joined:
    May 15, 2008
    Posts:
    4
    I'm reading the code now. Thank you very much, you are so kind and considerate.
    I hope the script is useful.
     
  5. Leon

    Leon

    Joined:
    May 15, 2008
    Posts:
    4
    I applied the code in my script , but there is something wrong.
    "Unknown identifier GUIx ", what should I do? It seems to be that I can only use GUI not GUIx. How could I use GUIx?
     
  6. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    First you have to create a new JS script in your project folder, name it GUIx.js, copy/paste the script contents from the wiki into that JS file. Then when you're drawing your user interface you must still use 'GUI' to access Unity's built-in GUI drawing functions (i.e. GUI.Button(...)), but you must call 'GUIx' to access any of the custom functions found in the GUIx script (i.e. GUIx.DrawTexture(...)).
     
  7. Leon

    Leon

    Joined:
    May 15, 2008
    Posts:
    4
    It works, thank you.