Hello, im new to Unity, I don't understand whats wrong with this code. I have 47 errors......

╔**Errors:**════════════════════════════════════════════════════════════════════════
║Assets\HandPresence.cs(27,47): error CS1519: Invalid token ‘(’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(27,83): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(29,26): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(29,28): error CS1519: Invalid token ‘in’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(29,38): error CS1519: Invalid token ‘)’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(31,22): error CS1519: Invalid token ‘(’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(31,33): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(31,33): error CS1026: ) expected
║Assets\HandPresence.cs(31,33): error CS1519: Invalid token ‘+’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(31,55): error CS1519: Invalid token ‘)’ in class, struct, or interface member declaration
║Assets\HandPresence.cs(33,1): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(33,19): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(33,19): error CS1026: ) expected
║Assets\HandPresence.cs(33,19): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(35,5): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(35,18): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(35,29): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(35,30): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(37,5): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(37,15): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(38,5): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(39,9): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(39,27): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(39,47): error CS1001: Identifier expected
║Assets\HandPresence.cs(39,58): error CS1001: Identifier expected
║Assets\HandPresence.cs(40,5): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(41,5): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(43,15): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(43,19): error CS1031: Type expected
║Assets\HandPresence.cs(43,19): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(43,19): error CS1026: ) expected
║Assets\HandPresence.cs(43,19): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(44,9): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(44,27): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(44,61): error CS1001: Identifier expected
║Assets\HandPresence.cs(44,72): error CS1001: Identifier expected
║Assets\HandPresence.cs(45,5): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(47,5): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(47,22): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(47,51): error CS1001: Identifier expected
║Assets\HandPresence.cs(47,62): error CS1001: Identifier expected
║Assets\HandPresence.cs(48,5): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(48,18): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(48,58): error CS0116: A namespace cannot directly contain members such as fields or methods
║Assets\HandPresence.cs(48,60): error CS8124: Tuple must contain at least two elements.
║Assets\HandPresence.cs(48,61): error CS1022: Type or namespace definition, or end-of-file expected
║Assets\HandPresence.cs(50,1): error CS1022: Type or namespace definition, or end-of-file expected
╚══════════════════════════════════════════════════════════════

CODE:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;

public class HandPresence : MonoBehaviour
{
public bool showController = false;
public InputDeviceCharacteristics controllerCharacteristics;
public List controllerPrefabs;
public GameObject handModelPrefab;

private InputDevice targetDevice;
private GameObject spawnedController;
private GameObject spawnedHandModel;
private Animator handAnimator;

// Start is called before the first frame update
void Start()
{
TryInitialize();
}

void TryInitialize();
List devices = new List();

InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);

foreach (var item) in devices)
{
Debug.Log(item.name + item.characteristics);
}
if (devices.Count > 0)
{
targetDevice = devices[0];
GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
if (prefab)
{
spawnedController = Instantiate(prefab, transform);
}
else
{
Debug.Log(“Did not find corrresponding controller model”);
spawnedController = Instantiate(controllerPrefabs[0], transform);
}

spawnedHandModel = Instantiate(handModelPrefab, transform);
handAnimator = spawnedHandModel.GetComponent();

}

//updates hand animations
void UpdateHandAnimation()
{ //trigger
if (targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
handAnimator.SetFloat(“Trigger”, triggerValue);
}
else
{
handAnimator.SetFloat(“Trigger”, 0);
}
//grip
if (targetDevice.TryGetFeatureValue(CommonUsages.grip, out float gripValue))
{
handAnimator.SetFloat(“Grip”, gripValue);
}
else
{
handAnimator.SetFloat(“Grip”, 0);
}
}

// Update is called once per frame
void Update()
{
if (!targetDevice.isValid)
{
tryIntialize();
}
else
{
if (showController)
{
spawnedHandModel.SetActive(false);
spawnedController.SetActive(true);
}
else
{
spawnedHandModel.SetActive(true);
spawnedController.SetActive(false);
UpdateHandAnimation();
}
}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;

public class HandPresence : MonoBehaviour
{
    public bool showController = false;
    public InputDeviceCharacteristics controllerCharacteristics;
    public List<GameObject> controllerPrefabs;
    public GameObject handModelPrefab;

    private InputDevice targetDevice;
    private GameObject spawnedController;
    private GameObject spawnedHandModel;
    private Animator handAnimator;

    // Start is called before the first frame update
    void Start()
    {
        TryInitialize();
    }

    void TryInitialize();
               List<InputDevice> devices = new List<InputDevice>();

    InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);

        foreach (var item) in devices)
        {
            Debug.Log(item.name + item.characteristics);
}
if (devices.Count > 0)
{
    targetDevice = devices[0];
    GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name);
    if (prefab)
    {
        spawnedController = Instantiate(prefab, transform);
    }
    else
    {
        Debug.Log("Did not find corrresponding controller model");
        spawnedController = Instantiate(controllerPrefabs[0], transform);
    }

    spawnedHandModel = Instantiate(handModelPrefab, transform);
    handAnimator = spawnedHandModel.GetComponent<Animator>();

}

//updates hand animations
void UpdateHandAnimation()
    {   //trigger
        if (targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
        {
            handAnimator.SetFloat("Trigger", triggerValue);
        }
        else
        {
            handAnimator.SetFloat("Trigger", 0);
        }
        //grip
        if (targetDevice.TryGetFeatureValue(CommonUsages.grip, out float gripValue))
        {
            handAnimator.SetFloat("Grip", gripValue);
        }
        else
        {
            handAnimator.SetFloat("Grip", 0);
        }
    }

    // Update is called once per frame
    void Update()
    {
    if (!targetDevice.isValid)
    {
        tryIntialize();
    }
    else
    {
        if (showController)
        {
            spawnedHandModel.SetActive(false);
            spawnedController.SetActive(true);
        }
        else
        {
            spawnedHandModel.SetActive(true);
            spawnedController.SetActive(false);
            UpdateHandAnimation();
        }
    }

}

i have an oculus rift s btw

i followed this tutorial

change void TryInitialize(); to void TryInitialize() {

every } needs an opening {

You can see it also when you look at your code how the indentations are completely crazy and unreadable following this line: “List devices = new List()” – notice how the line is suddenly all messed up.