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 /
avatar image
0
Question by xamomax · Jul 16, 2016 at 06:52 AM · inputembedding

How to send keyboard and mouse input to an embedded Unity player launched with -parentHWND?

I am using the Unity Stand Alone Player command line option "-parentHWND" to embed Unity into a Windows application (created in Delphi XE10, though I don't think that matters). This is working awesome, except for one problem: I cannot get mouse or keyboard input into the Unity part.

When I run inside of Unity, or as a standalone exe, the keyboard and mouse inputs work great. When I embed, the host application receives all the inputs instead, locking out the Unity player.

Presumably I need some way to send a message to "pass on" these inputs to the Unity part. I am fairly new to Unity, so how would I do that? What kind of external messages can I send that Unity will accept? Or, perhaps I need to use some special mode to "get global inputs" or something like that, if there is such a thing? What is the right way to solve this?

Thanks!

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
1

Answer by xamomax · Jul 20, 2016 at 12:03 PM

To those of you also wondering the answer to this, I have come across the solution.

The trick is that the embedded Unity application must be "Activated". How to do this can be found in a sample project .zip file, which you can get in the -parentHWND section of this page:

https://docs.unity3d.com/Manual/CommandLineArguments.html

The long story short of it, is that you have to find a handle to the Unity Window, and then once you have that handle, you can send a Windows message to "activate" it.

A key point here, is that it actually has a Windows Handle, which opens it up to Windows Messaging in general, I suppose.

If you happen to be a Delphi user, and would like some Delphi source code for this, send me a message, and Hopefully I'll get to it and post it back here for you, once I've cleaned it up a bit.

I hope this helps someone.

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 Elkis · Apr 10, 2017 at 02:33 AM 0
Share

Thank you! This was of great help!

avatar image houlding · Jul 15, 2019 at 11:44 PM 0
Share

Hi,

I'm interested in a Delphi solution if you still have one available. Can you add objects to the unity scene via Delphi?

Cheers

Greg

avatar image Bunny83 houlding · Jul 16, 2019 at 12:20 AM 0
Share

No, Unity is a completely seperate application that doesn't even share any memory. All he did is parenting Unity's device context to a window of a different application. Unity is still a seperate application. Of course you could communicate between the two applications through sockets or similar things.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

Unity Editor swallows gamepad input 0 Answers

Local Multiplayer Player Select Screen with new Unity GUI 1 Answer

Stylus button not registered in Unity5 as mouse button0 0 Answers

How can I achive faster response time from Input? 3 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