Search Unity

Mouse.current.position

Discussion in 'Input System' started by douglassophies, Jul 20, 2019.

  1. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    I made a post awhile ago (late 2018 ish) about mouse input not working in Web. I thought it was fixed now based on some forum posts so i tried again today. However logging Mouse.current.position.ReadDefaultValue() gives 0 all the time.
    Is it still not fixed or am i just missing something?

    Code (CSharp):
    1. Debug.Log(Mouse.current.position.ReadDefaultValue());
     
  2. I'm a bit lost here, what do you expect to get from the ReadDefaultValue() exactly?
     
    BAIZOR and douglassophies like this.
  3. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    Update: It still does not work in the actual build although the below solved the editor issue

    Thanks Lurking-Ninja, i think the answer to my question of "is it still broken or am i missing something", has been resolved as the latter! ;)
    It should be
    Code (CSharp):
    1. Mouse.current.position.ReadValue()
    I copy and replaced everywhere else when i made the switch, but in this one example i thought i was competent enough to type it without mistakes...
    Thanks again for pointing it out!
     
    Last edited: Jul 21, 2019
  4. Well, it was a legit question, I'm really missing something, apparently, but I'm glad that my ignorance has helped. :D
     
  5. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    Ah, i did it again in my reply! The "default" should not be there (fixed it now in an edit).
    ReadValue() vs ReadDefaultValue()
    Without it, it correctly gives the mouse position. I used the autocomplete without looking and never saw the "default" version. Not sure what its for but it returns 0 in my case.
     
    Lurking-Ninja likes this.
  6. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    Bad news when i tried a WebGL build. It all stops working at this point ;(
    Hoping this is something else small i have missed - anyone have any ideas?
     
  7. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    The web console error message:

    ArgumentNullException: Value cannot be null.
    Parameter name: statePtr
    at UnityEngine.InputSystem.InputControl`1[TValue].ReadValueFromState (System.Void* statePtr) [0x00000] in <00000000000000000000000000000000>:0
    (Filename: currently not available on il2cpp Line: -1)


    This is on 0.9.0