Why is my Unity script not able to be loaded?

141 views Asked by At

I am making a vr game and I am using UnityXR to do so. I am making a script that will have two attach points for an object (pistol). These points change based on which hand is holding the object.

Here is my code:

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

public class XRGrabIneractableTwoAttach : XRGrabInteractable
{
    public Transform leftAttachTransform;
    public Transform rightAttachTransform;

    protected override void OnSelectEntered(SelectEnterEventArgs args)
    {
        if(args.interactableObject.transform.CompareTag("Left Hand"))
        {
            attachTransform = leftAttachTransform;
        }
        else if(args.interactableObject.transform.CompareTag("Right Hand"))
        {
            attachTransform = rightAttachTransform;
        }

        base.OnSelectEntered(args);
    }

}

However, when I save my code and go into Unity, it gives me this. "The associated script can not be loaded. Please fix any compile errors and assign a valid script." I have absolutely no idea how to fix this as the code looks fine to me. Can someone please help me with this?

0

There are 0 answers