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
0
Question by Unislash · Feb 03, 2011 at 10:09 AM · javascripteditor-scriptingmouseclickpaint

Determine point in world space from mouse in Scene View

Hello,

Is there any way (that works) to return the coordinates of where the cursor is on the Scene View in the editor? I'm trying to effectively make a painting script for the editor. I've been working on this for nearly 4 hours, but nothing seems to get close to working.

The general thought is: 1) Trigger on mouse-click or key press (key press apparently requires a menu item so you can use a shortcut, but then that requires the function to be static) 2) Grab mouse location (you could use handles, you could use events, you could use camera...) 3) Ray cast from that point into scene 4) On hit, grab the point ( 5) place prefab from AssetData at point, or whatever)

Any ideas? I would post code but I keep reworking it to the point where I now have nothing much to post.

Cheers,

Unislash

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Wolfram · Feb 03, 2011 at 10:39 AM

I seem to remember the active camera (which can also be the Editor camera) can be accessed via Camera.current. If that is true, you can use your standard method to find the hitpoint (camera.ScreenpointToRay, Physics.Raycast, ...). Not a complete answer, but it should point you in the right direction - which is the intention of UnityAnswers anyways ;-)

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 Unislash · Feb 03, 2011 at 07:15 PM 0
Share

Yes, I've worked with that thought process. There are two problems: First, if you want there to be a hotkey functionality as i do, you either need to add the script to a menu (which requires it to be static, and then can't use the camera functions) or invoke OnSceneGUI, which i can't seem to get working at all. Then you need to get the mouse position, and to do this via editor you need to use Events, which I also can't seem to get working at all. Guidance would be appreciated :-)

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

Accessing OnSceneGUI with EditorWindow in JS 1 Answer

function Update in edit mode 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Execute unattached script in Edit Mode 0 Answers

Problem with OSX/Unity during long bake series (bug? workaround?) 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