Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by GuilhemGuilhem · Feb 20, 2016 at 01:43 PM · editoreditorwindowcustom editorsceneview

Custom editor: EditorGui.DrawPreviewTexture in SceneView only works in the top right corner

Good morning,

I have a custom 2D tile editor tool I wrote for Unity. It allows me to "paint" terrain for my 2D games. I have a "brush tool" and a "draw a rectangle" tool to pain this terrain. When using the rectangle tool, the user drags the mouse in the scene view. When he releases, a rectangle of terrain is created, spanning from the origin of the drag to the end of it. As the user drags the mouse around, I would like to give him a visual feedback of the rectangle he is currently forming. To do so, I am trying to use

void OnSceneView(SceneView view) { EditorGui.DrawPreviewTexture(myWorldCoordinateRectangle, myTexture); view.Repaint(); }

Everything is fine as long as the rectangle is drawn in the top right corner of my scene view, like this:

alt text

But the scene view will not draw anything in the other corners. If the rectangle is totally in another corner, it will not be drawn. If it is partly in the top right corner, only the top right corner part of my texture will be drawn. I have tried to move my scene view camera around, but wherever I place it or whatever the size of my scene view, it is the same issue: only the top right of my camera is drawn:

alt text

I have checked my rectangle size using Debug.DrawLine() and it is following the drag correctly in the other corners. I also tried "EditorGUI.DrawRect" and it is the same issue.

Anyone got any idea?

rectanglenotok2.png (37.0 kB)
rectangleok.png (27.7 kB)
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 andythepandy93 · Dec 13, 2016 at 01:31 PM 0
Share

Have you had any luck figuring this out? I am having the exact same problem as you whilst trying to draw a custom cursor whilst in the editor

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by spacelizardstudio · Dec 15, 2016 at 08:56 AM

No I didn't find how to fix it. I decided to draw 4 debug lines to display my square.

Comment
Add comment · 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

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

51 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Getting mouseposition outside of Editor Window in Scene View 1 Answer

How to access a Custom Editor components 1 Answer

Custom Editor List with child classes 1 Answer

ScriptableObject created from custom editor lose data on Unity restart 1 Answer

Vertical Foldout in Editor Window 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