Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Assets\CSkripts\HandPresence.cs(17,103): error CS1002: ; expected

Discussion in 'Unity Hub' started by alecAdmin, Dec 10, 2021.

  1. alecAdmin

    alecAdmin

    Joined:
    Nov 30, 2021
    Posts:
    2
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.XR;
    5.  
    6.  
    7. public class HandPresence : MonoBehaviour
    8. {
    9.     private List<GameObject> controllerPrefabs;
    10.     private InputDevice targetDevice;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.  
    16.         List<inputDevice> devices = new List<InputDevice>();
    17.         InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;
    18.         InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, devices);
    19.  
    20.         foreach (var item in devices)
    21.         {
    22.             Debug.Log(item.name + item.characteristics);
    23.         }
    24.  
    25.         if(devices.Count > 0)
    26.         {
    27.             targetDevice = devices[0];
    28.         }
    29.        
    30.     }
    31.  
    32.     // Update is called once per frame
    33.     void Update()
    34.     {
    35.        
    36.         if (targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonValue) && primaryButtonValue)
    37.             Debug.Log("Pressing Primary Button");
    38.        
    39.         if (targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue) && triggerValue > 0.1f)
    40.             Debug.Log("Trigger pressed " + triggerValue);
    41.        
    42.         if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && primary2DAxisValue != Vector2.zero)
    43.             Debug.Log("Primary Touchpad" + primary2DAxisValue);
    44.  
    45.     }
    46. }