Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Mar 26, 2016 at 09:29 PM by Yeti47 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Yeti47 · Mar 27, 2016 at 09:24 PM · guieditorwindowclippingdrawmesh

Graphics.DrawMeshNow in Editor Windows OnGUI clipping problem

Hello folks,

I'm currently working on an editor extension. For that I need to render a Mesh inside an Editor Window. I tried using Graphics.DrawMeshNow and it works surprisingly well in terms of just displaying the mesh. By the way, I'm only calling DrawMeshNow during the GUI's Repaint event.

The Mesh is automatically rendered at a position relative to the current GUI area, which is just perfect. However, there is a crucial problem with this.

Even though the positioning works as expected, DrawMeshNow completely ignores clipping, i. e. if it is used inside, say, GUI.BeginGroup or GUI.BeginScrollView it overlaps the given bounds.

But what's even worse, is that it is even drawn ABOVE the editor window's title bar.

Is there a way to sort of set a clipping area for Graphics.DrawMeshNow? Maybe trough the GL class or something?

Thank you very much in advance!

EDIT:

Nevermind, I found a good workaround. Instead of drawing the Mesh directly, I use Handles.DrawCamera to render a temporary scene camera into my editor window. The camera shows another temporary gameobject with the mesh I want to display. However, it was a real struggle to get this to work, since all cameras are always stretched to the currently selected aspect ratio. Therefore, I had a really hard time getting the camera view to fit into my window the way I wanted it.

Thought I'd share the solution to this problem in case someone else finds himself in the same exhausting situation:

The aspect ratio will NOT be automatically enforced if the hideflags of the camera's gameobject are set to at least Hideflags.Hide. The camera will then perfectly fit into the rect passed into the Handles.DrawCamera method.

Really nice. I hope this is intended behavior and does not get "fixed" in a future update.

:)

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

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I make a progress bar in the editor lock the background? 0 Answers

How do I get a reference to the default editor windows (Hierarchy, Console, and Inspector)? 1 Answer

How to force Unity to Repaint an EditorWindow? 1 Answer

EditorWindow not properly drawing 1 Answer

How to stop GUI Text from cutting off half a letter? 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