Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Windows exe player is a winform????

Discussion in 'Scripting' started by dujimache, Jul 13, 2018.

  1. dujimache

    dujimache

    Joined:
    Dec 17, 2011
    Posts:
    29
    is the windows standard exe player a winform????can i get the player's winform object ???
     
  2. dujimache

    dujimache

    Joined:
    Dec 17, 2011
    Posts:
    29
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    5,908
    No, it is not.

    WinForms is part of the .net library and wraps around the Windows API to draw to a window using GDI+. Unity doesn't use .Net for anything like that... the only thing unity uses .Net for is that it uses mono (opensource .net) as a scripting environment. All of its graphics and engine specific stuff is done in C++ and does not use managed code or WinForms.

    A 'window' is just a generic resource in the WinAPI, and it can be referenced by the HWND. You can get a reference to a window (which doesn't have to do with WinForms) in various ways, such as the user32.dll method GetWindow:
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515(v=vs.85).aspx

    You can import a WinAPI method from user32.dll like so:
    Code (csharp):
    1. [DllImport("user32.dll")]
    2. public static extern IntPtr GetWindow(IntPtr hWnd, uint nCmdShow);
    Note - this would only work when you build for windows, since it's accessing a windows specific API.

    ...

    What are you attempting to do anyways? Maybe there's another way to get what you need...
     
    Ryiah likes this.
  4. dujimache

    dujimache

    Joined:
    Dec 17, 2011
    Posts:
    29
    thanks, my game is a windows game.Sometimes the Input.GetKeyDown is not working. Any key isn't working.So i don't want to use Input.GetKeyDown to check the keyboard state.
     
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    5,908
    When are you calling 'GetKeyDown'? Because it should work just fine... most everyone uses it on a regular basis. You should be using it in the 'Update' method to get the best results, and avoid using it in FixedUpdate because FixedUpdate may run multiple times in a given frame (giving repeated 'Down' events), or not get called at all in a given frame (no Down event occurring at all).
     
  6. dujimache

    dujimache

    Joined:
    Dec 17, 2011
    Posts:
    29
    yes ,i use it in update, and i am sure the update is still called,but Input.GetKeyDown can't detect the key down event, not always, usually appeard after switch to other app and then return to unity player.
     
  7. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,114
    If you're absolutely sure, you might want to report this as a bug with a detailed description of your version, the OS and the way how to possibly reproduce it.
     
    lordofduct likes this.
  8. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    5,908
    Yeah, if you're certain, create a slimmed down project where you can reproduce it and submit it as a bug to Unity with instructions on the steps to recreate.