Coming soon - Get a detailed view of why an account is flagged as spam!
view details
3
[help] Converting project from desktop to tablet: how to detect 'mouse' movement?
Post Flair (click to view more posts with a particular flair)
Author Summary
caz- is in help
Post Body

Hi all. I have a project that I made for desktop (Windows), but I recently tried it out on my Surface Pro tablet and realised how enjoyable it is to use it with the stylus. The problem is that a certain functionality is no longer working.

I have a static image of a control surface as the background; i.e., it's a picture of knobs and buttons. In front of this I have a rectangular mesh for each button, with visibility off, with the following script:

using UnityEngine;
using System.Collections;

public class focus : MonoBehaviour {
    public static bool isUsing;

    void Start () {
        renderer.enabled = false;
        isUsing = false;
    }

    void Update () {                
            if( isUsing ){
            if(Input.GetAxis("Mouse Y") > 0){
                OtherScript.Value  =    OtherScript.deltaValue*(Time.deltaTime);//Time.deltaTime/100000;        
            }
            if(Input.GetAxis("Mouse Y") < 0){
                OtherScript.Value -=    OtherScript.deltaValue*(Time.deltaTime);//Time.deltaTime/100000;
            }
        }   
                if(Input.GetMouseButtonUp(0)){
            isUsing = false;
        }                   
    }       
    void OnMouseOver(){
        if(Input.GetMouseButtonDown(0))
            isUsing = true;         
    }
}

What this does is change Value up or down when the mouse is moved up or down, respectively, while the mouse button is held down over the control knob. The trouble is that it doesn't work with the stylus. As far as I can tell, it is the

if(Input.GetAxis("Mouse Y") > 0)

and

if(Input.GetAxis("Mouse Y") < 0)    

conditionals that aren't working. Does anyone have any idea what the easiest way to get this working with the stylus would be?

tl:dr: Input.GetAxis("Mouse Y") does not appear to work with the stylus on Surface Pro. How can I get my desktop project to work with both mouse and stylus?

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
23,835
Link Karma
1,147
Comment Karma
22,656
Profile updated: 2 days ago
Posts updated: 1 year ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago