Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 darthtelle · Jul 15, 2015 at 12:45 PM · camerapositionworldrender texture

Find the world position of an object rendered on a scaled Render Texture

The game I am currently working on requires the GUI to be rendered within a safe frame of the screen. We're being constrained to using Unity 4.3 so are unable to make use of the new Unity GUI features, so instead we are using Render Textures to display the GUI and then scale the textures depending on percentage of safe frame required.

For one scenario we need to display a lot of text, so being stuck with 4.3, I am using OnGUI() to draw a scroll rect and have all the text within these bounds. However, due to the need of a safe frame which is scaled to a render texture, whenever we adjust the safe frame percentage the position we want the GUI scroll rect to be drawn at is offset because it can't be rendered on the render texture.

My current solution involves having a game object in world space which represents the position I want to draw the scroll rect (currently I have a sprite there to help visualise position). This is then drawn on the render texture and scaled based on safe frame, but obviously now the render position of my object does not match the world position and I can't figure out how to convert the world position be a scaled texture to the GUI screen position.

Below is code I've currently been trying, but doesn't work. While the render texture position is scaled closer to the center of the screen, the GUI scroll position goes to the outside of the screen.

 Vector3 screen_Position = camera.WorldToScreenPoint(world_Position);
 
 Vector3 position = screen_Position;
         
 // Adjust the position by the safe zone
 position.x *= Options_Manager.Instance.SafeZone;
 position.y *= Options_Manager.Instance.SafeZone;

I'm not sure how to convert the world position to get the scaled render texture position. Any help would be greatly appreciated! Thank you! :)

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

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Changing camera position to shoot through scope on gun 1 Answer

How do I tell a button to move my camera!? 1 Answer

How Can I Stop Rotation From This Script? 0 Answers

Increase Field of View without move some objects 1 Answer

Camera shake 11 Answers


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