namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard
{
///
/// Abstract class defining callbacks for key functionality. Allows users to extend
/// custom functionality of keys and keyboard.
///
public abstract class KeyFunction : ScriptableObject
{
///
/// Pre-process function when a key is pressed.
///
/// The current keyboard associated with .
/// The key that is being pressed.
public virtual void PreprocessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.PreprocessKeyPress(key);
}
///
/// Primary function callback when a key is pressed. Use this function to interface directly with a keyboard
/// and process logic based on the current keyboard and key context.
///
/// The current keyboard associated with .
/// The key that is being pressed.
public abstract void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key);
///
/// Post-process function when a key is pressed. This function calls on the keyboard.
///
/// The current keyboard associated with .
/// The key that is being pressed.
public virtual void PostprocessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.PostprocessKeyPress(key);
}
///
/// Uses keyboard and key context to determine if this key function should override the key's display icon.
///
/// Current keyboard context.
/// Current keyboard key.
/// Returns true if this key function should override the display icon.
public virtual bool OverrideDisplayIcon(XRKeyboard keyboardContext, XRKeyboardKey key)
{
return false;
}
///
/// Returns display icon for this key function based on the context of the key and keyboard.
///
/// Current keyboard context.
/// Current keyboard key.
/// Returns display icon for this key.
public virtual Sprite GetDisplayIcon(XRKeyboard keyboardContext, XRKeyboardKey key)
{
return null;
}
///
/// Allows this key function to process when a key is refreshing its display.
///
/// The current keyboard associated with .
/// The key that is refreshing the display.
public virtual void ProcessRefreshDisplay(XRKeyboard keyboardContext, XRKeyboardKey key)
{
}
}
}