Detecting Mouse Down in Update Loop

20 views
Skip to first unread message

Hailey

unread,
Nov 1, 2022, 12:39:09 PM11/1/22
to AltTester - UI test automation tool for gaming
Hello, I have unity code that is detecting mouse events in an update loop like:

protected virtual void Update(){
    if (Input.GetMouseButton(0)){
        Debug.LogError("1");
    }
    else if (Input.GetMouseButtonDown(0)){
        Debug.LogError("2");
    }
    else if (Input.GetMouseButtonUp(0)){
        Debug.LogError("2");
    }
    else{
        Debug.LogError("No Input.");
    }
}

When I am running my altunity automation to press the mouse button like:
altdriver.press_key(AltUnityKeyCode.Mouse0,0,2,True)

I have verified that the mouse is clicking. I can see it with the altunity input visualizer and I have also verified that it successfully interacts with unity elements beneath it, but the altunity click is never detected by my update loop. The update loop is running, but it always says there is no input even when altunity is pressing key AltUnityKeyCode.Mouse0. Is there anything I can do about this from the altunity side without changing the unity code?

robert....@altom.com

unread,
Nov 2, 2022, 5:38:06 AM11/2/22
to Hailey, AltTester - UI test automation tool for gaming

Hello Hailey,

 

I tried to reproduce the problem but I was not completely able to reproduce it. When I tried to run it, the console displayed once “1” and once “2” and lots of “No Input.” after 😊. The problem was that while the command is running it should display “1” multiple times which is not happening. This is a bug from us and we will fix it In the next release.

 

A workaround for this issue would be to use the following code:

        altdriver.key_down(AltKeyCode.Mouse0)

        time.sleep(2)

        altdriver.key_up(AltKeyCode.Mouse0)

 

But if you don’t see any “1” in “2” then you might have your project set to the new input system. The code you wrote(in the update method) is for the old input system. Please check that your project is set correctly.

 

--
You received this message because you are subscribed to the Google Groups "AltTester - UI test automation tool for gaming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alttesterforu...@altom.com.
To view this discussion on the web visit https://groups.google.com/a/altom.com/d/msgid/alttesterforum/48d8f4d8-6dbf-485f-a428-2e5ac4b0bc20n%40altom.com.

 


Virus-free.www.avast.com
Reply all
Reply to author
Forward
0 new messages