locked
AdControl renders in a layer above the mouse - no interaction possible - Unity3D & C#

    Question

  • Hello,

    After a few hours banging my head and trying to make the mouse go OVER the ad, instead of UNDER it, I found what the problem is. Perhaps an odd issue with the control, but it could be Unity's fault too. Well, here is some info to contextualize:

    • Windows Store App (8.1)
    • Unity3D 4.6.1
    • Advertising SDK 8.1.40402.2
    • Visual Studio Ultimate 2013 Update 4

    I have a standard adControl implementation, just like the help files. I implemented on XAML markup first, then started over and did a C# implementation. Tried many things along the way, but the problem persisted.

    I had no problems setting up the ad itself, it shows properly in every way I implemented and can be activated on a touchscreen. But it renders on top of the layer that the mouse is rendered, so the mouse pointer just goes underneath the control and has no interaction with it.

    What caused the problem: I changed the mouse pointer in Unity to an image. As long as I have a different mouse pointer, the problem remains.

    Workaround: Changed back to the standard pointer. The adControl works perfect with the default pointer.

    I wonder if this is a bug of the control, or if Unity is setting up the custom pointer the wrong way. I would like to solve this issue to have my custom pointer back in the game.

    This should be easy to replicate for testing: just create anything in Unity3D, change the mouse pointer and run a Unity build. Open the project in VS and build. Perhaps another test is to change the pointer within Visual Studio and see if the problem also happens.

    Thanks!

    Ricardo


    • Edited by rdaros Wednesday, January 28, 2015 5:30 AM
    Wednesday, January 28, 2015 5:30 AM

Answers

  • You'll need to add your custom cursor as a cursor resource in your executable and then set the Window.Current.CoreWindow.PointerCursor's type to custom and ID to your cursor resource. This will require using Visual Studio to create a Desktop resource (RC) file with your cursor info, compile it to a res file, and then ad the .res file to the .csproj file in the Visual Studio solution generated by Unity.

    You should be able to set the CoreWindow's cursor directly from Unity by wrapping the Windows Runtime code in a #if NETFX_CORE block, but you may need to also disable Unity's cursor handling so your version and Unity's don't interfere with each other.

    --Rob

    Wednesday, January 28, 2015 7:17 PM
    Owner

All replies

  • You'll need to use a Windows cursor to appear on top. You're running the cursor sa Unity sprite so it displays within the Unity scene which is in a SwapChainPanel behind xaml controls such as the as control.
    Wednesday, January 28, 2015 5:39 AM
    Owner
  • I appreciate your answer Rob, it makes sense. Is it possible (and easy) to change the default Windows cursor to a custom image? I'm sure this is a very basic question, but I'm just getting into Windows and Windows Phone dev and my platform knowledge is limited. Thanks!
    Wednesday, January 28, 2015 6:38 AM
  • You'll need to add your custom cursor as a cursor resource in your executable and then set the Window.Current.CoreWindow.PointerCursor's type to custom and ID to your cursor resource. This will require using Visual Studio to create a Desktop resource (RC) file with your cursor info, compile it to a res file, and then ad the .res file to the .csproj file in the Visual Studio solution generated by Unity.

    You should be able to set the CoreWindow's cursor directly from Unity by wrapping the Windows Runtime code in a #if NETFX_CORE block, but you may need to also disable Unity's cursor handling so your version and Unity's don't interfere with each other.

    --Rob

    Wednesday, January 28, 2015 7:17 PM
    Owner