Duplicate class name in metadata without implementations in its virtual methods
Hi,
I'm working with the XR Toolkit and was looking at how one of the base classes is set up. There seems to be two scripts of the same name active in the project. One in a Scripts folder in Unity project and the other in my \Local\Temp\MetadataAsSource\ folder.
My knowledge of C# is 'in progress' but I always thought that virtual methods in a base class had to have an implementation. However, the script in my Temp folder has virtual methods without implementations (like abstract methods).
Can anyone explain what's going on here as Unity is obviously doing something 'under the hood'? I've pasted a section of each script below, as they're quite long.
In Temp folder:
#region Assembly Unity.XR.Interaction.Toolkit, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// D:\Projects In Progress\Unity\VR-XRButton-master\Library\ScriptAssemblies\Unity.XR.Interaction.Toolkit.dll
#endregion
using System.Collections.Generic;
namespace UnityEngine.XR.Interaction.Toolkit
{
[DefaultExecutionOrder(-98)]
[SelectionBase]
public abstract class XRBaseInteractable : MonoBehaviour
{
protected XRBaseInteractable();
public XRInteractionManager interactionManager { get; set; }
public bool isSelected { get; }
public bool isHovered { get; }
public List<XRBaseInteractor> hoveringInteractors { get; }
public LayerMask interactionLayerMask { get; set; }
public List<Collider> colliders { get; }
public GameObject customReticle { get; set; }
public XRInteractableEvent onHoverExit { get; set; }
public XRInteractableEvent onFirstHoverEnter { get; set; }
public XRInteractableEvent onHoverEnter { get; set; }
public XRInteractableEvent onLastHoverExit { get; set; }
public XRInteractableEvent onSelectEnter { get; set; }
public XRInteractableEvent onSelectExit { get; set; }
public XRInteractableEvent onActivate { get; set; }
public XRInteractableEvent onDeactivate { get; set; }
public virtual void AttachCustomReticle(XRBaseInteractor interactor);
public float GetDistanceSqrToInteractor(XRBaseInteractor interactor);
public virtual bool IsHoverableBy(XRBaseInteractor interactor);
public virtual bool IsSelectableBy(XRBaseInteractor interactor);
public virtual void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase updatePhase);
public virtual void RemoveCustomReticle(XRBaseInteractor interactor);
protected virtual void Awake();
protected virtual void Reset();
protected internal virtual void OnActivate(XRBaseInteractor interactor);
protected internal virtual void OnDeactivate(XRBaseInteractor interactor);
protected internal virtual void OnHoverEnter(XRBaseInteractor interactor);
protected internal virtual void OnHoverExit(XRBaseInteractor interactor);
protected internal virtual void OnSelectEnter(XRBaseInteractor interactor);
protected internal virtual void OnSelectExit(XRBaseInteractor interactor);
public enum MovementType
{
VelocityTracking = 0,
Kinematic = 1,
Instantaneous = 2
}
}
}
In Unity project:
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace UnityEngine.XR.Interaction.Toolkit
{
/// <summary>
/// UnityEvent that responds to changes of hover, selection, and activation by this interactable.
/// </summary>
[Serializable]
public class XRInteractableEvent : UnityEvent<XRBaseInteractor> { }
/// <summary>
/// Abstract base class from which all interactable behaviours derive.
/// This class hooks into the interaction system (via XRInteractionManager) and provides base virtual methods for handling
/// hover and selection.
/// </summary>
[SelectionBase]
[DefaultExecutionOrder(XRInteractionUpdateOrder.k_Interactables)]
public abstract class XRBaseInteractable : MonoBehaviour
{
/// <summary>Type of movement for an interactable</summary>
public enum MovementType
{
/// <summary>In VelocityTracking mode, the Rigid Body associated with the will have velocity and angular velocity added to it such that the interactable attach point will follow the interactor attach point
/// as this is applying forces to the RigidBody, this will appear to be a slight distance behind the visual representation of the Interactor / Controller</summary>
VelocityTracking,
/// <summary>In Kinematic mode the Rigid Body associated with the interactable will be moved such that the interactable attach point will match the interactor attach point
/// as this is updating the RigidBody, this will appear a frame behind the visual representation of the Interactor / Controller </summary>
Kinematic,
/// <summary>In Instantaneous Mode the interactable's transform is updated such that the interactable attach point will match the interactor's attach point.
/// as this is updating the transform directly, any rigid body attached to the GameObject that the interactable component is on will be disabled while being interacted with so
/// that any motion will not "judder" due to the rigid body interfering with motion.</summary>
Instantaneous,
};
[SerializeField, Tooltip("Manager to handle all interaction management (will find one if empty).")]
XRInteractionManager m_InteractionManager;
/// <summary>Gets or sets Interaction Manager.</summary>
public XRInteractionManager interactionManager
{
get { return m_InteractionManager; }
set
{
m_InteractionManager = value;
RegisterWithInteractionMananger();
}
}
[SerializeField, Tooltip("Colliders to use for interaction (if empty, will use any child colliders).")]
List<Collider> m_Colliders = new List<Collider>();
/// <summary>Gets colliders to use for interaction with this interactable.</summary>
public List<Collider> colliders { get { return m_Colliders; } }
[SerializeField, Tooltip("Only interactors with this Layer Mask will interact with this interactable.")]
LayerMask m_InteractionLayerMask = -1;
/// <summary>Gets or sets the layer mask to use to filter interactors that can interact with this interactable.</summary>
public LayerMask interactionLayerMask { get { return m_InteractionLayerMask; } set { m_InteractionLayerMask = value; } }
List<XRBaseInteractor> m_HoveringInteractors = new List<XRBaseInteractor>();
/// <summary>Gets the list of interactors that are hovering on this interactable; </summary>
public List<XRBaseInteractor> hoveringInteractors { get { return m_HoveringInteractors; } }
/// <summary>Gets whether this interactable is currently being hovered.</summary>
public bool isHovered { get; private set; }
[SerializeField]
[Tooltip("Called when an Interactor has deactivated this selected Interactable.")]
XRInteractableEvent m_OnDeactivate = new XRInteractableEvent();
/// <summary>Gets or sets the event that is called when an Interactor deactivates this Interactable.</summary>
public XRInteractableEvent onDeactivate { get { return m_OnDeactivate; } set { m_OnDeactivate = value; } }
protected virtual void Reset()
{
FindCreateInteractionManager();
}
protected virtual void Awake()
{
// if we have no colliders, add children colliders
if (m_Colliders.Count <= 0)
m_Colliders = new List<Collider>(GetComponentsInChildren<Collider>());
// setup interaction manager
if (!m_InteractionManager)
m_InteractionManager = FindObjectOfType<XRInteractionManager>();
if (m_InteractionManager)
RegisterWithInteractionMananger();
else
Debug.LogWarning("Could not find InteractionManager.", this);
}
}
Your answer
Follow this Question
Related Questions
Need help understanding a few c# concepts 1 Answer
Multiple PowerUps (One ItemBox) 0 Answers
Instantiation Of Abstract Classes 1 Answer
Write png image metadata with pngcs 1 Answer
Reading metadata from a file 0 Answers