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
2
Question by hypnoslave · Jan 29, 2011 at 06:05 AM · meshuvgenerateuvs

creating a mesh and generating it's specific uvs

Hi guys. I'll try and be concise. I'm trying to take a a piece of an image and make it into a 3d plane, and I don't know much about generating uvs in unity.

  • I'm building a gui in 3d using planes, textures, and raycast selection

  • we're getting ready for localization and language changes

  • I'd like to take all of the text in my hud and put it in a single texture, so i can make an english version, a french version, etc just by swapping out images.

  • to create the actually 3d hud components, I want to make an editor class where as i can open up the image with all of the text on it, drag select an area to select some text, and have unity create a plane with the uvs mapped to that location.

  • I have already created an editor tool to build a plane, from an image, with the same aspect ratio of that image, so I know a bit about editor extending.

  • I'm really curious here about if it's possible to

    1. display an image in the editor and read mouse clicks to get co-ordinates on that texture
    2. take that data, create a plane, turn that data into uv mapping co-ordinates for the plane, and scale the plane so that the aspect ratio of the plane matches the aspect ratio of the uv co-ordinates.

    Basically the intention here would be to take a section of an image and turn it into a 3d plane.

    Any advice would be delightful. Thanks guys!

    Comment
    Add comment · Show 2
    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 Bunny83 · Jan 29, 2011 at 06:19 AM 0
    Share

    Yeah, it shouldn't be a big deal if you have some basic knowledge and i think you have from what i've read above ;) I don't have much time at the moment (need some sleep ;)) but i'll go for it tomorrow. Just a little hint: GUI.DrawTexture works also in editor windows

    avatar image hypnoslave · Jan 29, 2011 at 06:08 PM 0
    Share

    excellent.. thanks, that's good to know.....

    2 Replies

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

    Answer by hypnoslave · Jan 29, 2011 at 10:38 PM

    I GOT IT!

    in the OnGUI function of your editor:

    • create a new orthographic camera with a texture plane right in front of it.
    • call Handles.DrawCamera to create a render window on the editor gui.
    • create a ray using HandleUtility.GUIPointToWorldRay
    • using physics.raycast on mouse click to check for collision on the plane
    • read the texture coordinates of the raycast collisions with RaycastHit.textureCoord

    then instantiate a plane and set it's uvs to match the coordinates from the clicks that you made.

    voila!

    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 Bunny83 · Jan 30, 2011 at 12:44 AM 0
    Share

    very nice, I just did almost the same :D. First i tried to use DrawTexture, but it's not very flexible. In the scene you can use the whole awesomeness of Unity. I like playing around with the editor. You can even create your own modelling program (or window ;)). I want the Unity editor to be my operation system, that would be nice :P I think you can accept your own answer. great job.

    avatar image hypnoslave · Feb 02, 2011 at 01:00 AM 0
    Share

    hehe cheers :) yeah, unity sure is fantastic....

    avatar image
    1

    Answer by DaveA · Jan 29, 2011 at 06:10 AM

    I would look into this: http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html

    You might be able then to raycast to that texture and read out the coords from the raycast hit texture coordinate

    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 hypnoslave · Jan 29, 2011 at 06:07 PM 0
    Share

    ah, very good, Thank you. I can use that!!

    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

    No one has followed this question yet.

    Related Questions

    Scale mesh but keep original uv? 0 Answers

    Manual UV-Mapping of a Primitive Cube 1 Answer

    Fixing Uvs on a mesh by code cylinder 1 Answer

    How to change mesh UV's permanent in Unity (texture atlas) 1 Answer

    Create planar UVs on procedurally generated mesh 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