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 redsix · Feb 13, 2014 at 03:40 PM · camerabughandles

Looking for a workaround for DrawCamera/Game view crop bug

I'm looking for a workaround for this bug. I'm asking again here since this issue really bothers me and basically prevents me from doing anything more on what I've been working on.

What I'm trying to do is rendering a camera to an EditorWindow using Handles.DrawCamera(). The problem is, that the (normalized/pixel) rect of the camera is always cropped by the game view and I cannot render it the size I want (e.g. the full size of the EditorWindow). If the game view is not visible, it is cropped to 640x480, otherwise to the size of the game view.

What I've already tried:

  • Disabling the camera behavior in the scene

  • HandleUtility.PushCamera() / PopCamera()

  • Setting Camera.current back to the previous one after DrawCamera (Camera.SetupCurrent - if that is what this undocumented method does).

  • Handles.SetCamera(null) after drawing. This causes, aside from a NullReferenceException, another interesting behavior, since now the game view and DrawCamera mutually affect each others size, i.e. the game view still determines its max size, while the rect I pass into DrawCamera crops the game view's render of the camera to a smaller size if I set it to be smaller.

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 RyanZimmerman87 · Feb 14, 2014 at 04:32 AM 0
Share

I don't have an answer but I'll go on a little rant that's somewhat related and at least it will bump your thread.

The Unity editor seems to have a lot of undesired behavior with specific screen sizes or resolutions being displayed.

For example trying to use 1920x1080 in the Game View is not truly 1920x1080 or an accurate representation of what it should be. I almost feel like I need a 2560x1440 monitor to use the Unity Editor properly for 1920x1080, kind of ridiculous. Then again it's my first project so on my next one hopefully I can avoid problems that have anything to do with every resolution setting for all monitors/devices...

Another thing, why doesn't full screen windowed mode work correctly if it's your screens resolution, other games are able to do this with Unity it seems it won't fit right with the bars on top always visible? Need to research if there's a solution to that...

But anyways I'm not sure if I follow your exact problem. But hopefully someone can help you.

It seems Unity requires a dual monitor set up to use efficiently. Even then there are some strange things going on with Unity, windowed mode, and resolution settings within the editor.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by asafsitner · Mar 07, 2014 at 08:05 AM

In order to draw a camera correctly inside a GUI, the camera's `HideFlags` has to be set to `HideAndDontSave`. (It has to be set to that flag exactly - `HideFlags.HideInHierarchy` alone won't do it!)

Because of that, if you'd like to keep interactivity with the camera, you can create another camera and mirror it's state to the hidden camera, which is the actual camera you'll render.

To quickly copy the settings from one camera to another you can use `Camera.CopyFrom`. Remember to also copy the `transform` state!

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 JeevSiewnath · Mar 07, 2014 at 03:35 PM 1
Share

Hi, I actually was the one who submitted the issue. I thought I tested this thoroughly but the hideFlags solution actually works! I've been spending like a week trying to fix this issue and mailing back and forth with Unity, thank you so much!

avatar image asafsitner · Mar 07, 2014 at 04:18 PM 0
Share

Hi, really glad I could help!

It's a weird bug (feature?) for sure, I spent a lot of time battling it as well. :)

avatar image Aircer · Apr 15, 2021 at 04:42 PM 0
Share

Hey, I tried your solution but it didn't work. I am on Unity 2019.4. You just set the HideFlags of the camera and it worked ? Could you show the code just to be sure that I do it correctly.

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

22 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

Related Questions

Wrong camera position/orientation on windows 10 store build: How to fix it? 0 Answers

rotate with alt doesnt work 15 Answers

How to draw another camera's view without "Handles"-class? 0 Answers

Help fixing a bug with camera script 2 Answers

Canvas position not in sync with camera 0 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