简体   繁体   中英

The left-hand side of an assignment

Im making game in unity, and trying to make an android swipe control system. It is the same as in toutorial, but somehow it return error for me - "Error CS0131 The left-hand side of an assignment must be a variable, property or indexer". How can I make this code work?

bool isDraging = false;
Vector2 startTouch, swipeDelta = Vector2.zero;

if (isDraging)
{
    if (Input.touches.Length > 0)
        swipeDelta = Input.touches[0].position = startTouch; 
    else if(Input.GetMouseButton(0))
        (Vector2)Input.mousePosition = startTouch = swipeDelta;    
}

Your error is that you are trying to change the mousePosition . Unity Game Engine does not have the ability to change the mousePosition . To accomplish this you need to use the system.windows.forms.cursor.position . To do this you need to add the windows.form.dll to the assembly of your project. To do this download the dll into the Unity asset folder and at the beginning of your code add:

using dllNamespace

Note dllNamespace is the namespace of your dll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM