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 Christian Refvik · Jul 03, 2013 at 11:25 PM · pluginnativedirect3d

How can the native Unity plugin be initialized before the Direct3D rendering device is created?

I'm writing a plugin and I need to call NvAPI_Stereo_SetDriverMode. According to the NVAPI documentation, this needs to happen before the Direct3D 9 or 11 device is created.

The soonest I could call this function is when the plugin is loaded, but I do not know when or on which thread this occurs - this isn't documented. The kGfxDeviceEventInitialize event is called after the device is created, so that is too late.

If the plugin could issue its own create / destroy device events, that might solve my problem, but I don't think this is possible.

Has anyone come across this issue and know how I can solve it?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Christian Refvik · Jul 10, 2013 at 05:58 PM

I've tried the following approaches and nothing seems to work:

  • DLL main using both process attach and thread attach

  • Unity command-line arguments with -executeMethod option

  • Unity plugin native graphics initialize event

I've verified all of these approaches are being called, but none of them are early enough. If anyone has any insight into this, please let me know. I'm trying to get NVIDIA 3D vision to work in direct mode. I've searched the forums and answers for this and based on the answers and examples I've seen, no one currently has this working.

If Unity could to add a pre-initialize device event, then this would work.


Okay, I contacted Unity3D support and they said the following:

Unfortunately it is not possible to send events to your plugin before the graphics device is initialized.

I certainly wish they had this feature. I need to do some NVIDIA driver initialization before the device is created. I also tried to use a wrapper application to do the initialization before Unity starts (ie. using spawn, fork/exec, and CreateProcess), but that doesn't work either.

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

Answer by PMY Archon · Oct 22, 2013 at 12:27 PM

If you're creating a Standalone build, you can write a simple DLL and a launcher.

Launcher will CreateProcess() of standalone executable file with CREATE_SUSPENDED flag set.

Then you can inject your DLL with a call to NvAPI_Stereo_SetDriverMode() from DLL_PROCESS_ATTACH section.

P.S. Don't forget to call ResumeThread() after you finish injection.

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

16 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

Related Questions

How to access an Android native plugin in unity ? 0 Answers

Passing large Vector array to native plugin without copying 2 Answers

Different approaches to Android plugins 0 Answers

U3DXTException: in SocialXT.Share 0 Answers

Encrypt native plugins/protect IP 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