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.
  2. Dismiss Notice

Resolved Updating Unity causing "error CS0115... no suitable method found to override"

Discussion in 'XR Interaction Toolkit and Input' started by Cooleobrad, Nov 30, 2020.

Thread Status:
Not open for further replies.
  1. Cooleobrad

    Cooleobrad

    Joined:
    Dec 16, 2016
    Posts:
    15
    I recently updated my version of unity and the XR packages, but have been met with errors when trying to compile my previous project.

    As an example
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.XR.Interaction.Toolkit;
    3.  
    4. public class OffsetGrab : XRGrabInteractable
    5. {
    6.     private Vector3 interactorPosition = Vector3.zero;
    7.     private Quaternion interactorRotation = Quaternion.identity;
    8.  
    9.     protected override void OnSelectEnter(XRBaseInteractor interactor)
    10.     {
    11.         base.OnSelectEnter(interactor);
    12.         StoreInteractor(interactor);
    13.         MatchAttachmentPoints(interactor);
    14.     }
    15.  
    When I hover over "OnSelectEnter" it says, "CS0117:'XRGrabInteractable' does not contain a definition for 'OnSelectEnter'". I have the same issue with "OnSelectExit" later on in the code for this file. How do I go about fixing this?
     
  2. jorrit-de-vries

    jorrit-de-vries

    Joined:
    Aug 7, 2009
    Posts:
    71
    These methods are unfortunately internal, for what I believe no reason. I have submit a request to open up this API and remove the internal modifiers. You can hook into the events which might be dispatched of course, but not sure if that would work in your case.
     
  3. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    220
    In 0.10.0-preview.7, the
    OnSelectEnter
    method was split into two methods:
    OnSelectEntering
    and
    OnSelectEntered
    . You will need to rename your method and the call to the base method to one of these two. The same change was made with
    OnSelectExit
    being split into
    OnSelectExiting
    and
    OnSelectExited
    .

    This was done to allow for both the Interactor and Interactable to have a chance to handle that state change in a first pass before they invoke public events in the second pass. What was happening was listeners to the Interactor event were trying to operate on the Interactable before it had a chance to process that change itself, leading to errors. The Interaction Manager calls these methods like:
    Code (CSharp):
    1. interactor.OnSelectEntering(interactable);
    2. interactable.OnSelectEntering(interactor);
    3. interactor.OnSelectEntered(interactable);
    4. interactable.OnSelectEntered(interactor);
    Those methods are protected internal and virtual so you're able to override and call them in a derived class.
     
    jorrit-de-vries likes this.
  4. jorrit-de-vries

    jorrit-de-vries

    Joined:
    Aug 7, 2009
    Posts:
    71
    Cheers, didn't know that
     
Thread Status:
Not open for further replies.