VRTK_ObjectAppearance
extends VRTK_InteractableListener
Overview
Determine whether the Object To Affect should be visible or hidden by default or on interaction (near touch, touch, grab, use).
Required Components:
VRTK_InteractableObject- The Interactable Object component to detect interactions on. This must be applied on the same GameObject as this script if one is not provided via theObject To Monitorparameter.
Script Usage:
- Place the
VRTK_InteractObjectAppearancescript on either:- The GameObject of the Interactable Object to detect interactions on.
- Any other scene GameObject and provide a valid
VRTK_InteractableObjectcomponent to theObject To Monitorparameter of this script.
- Optionally provide a GameObject to the
Object To Affectparameter to determine which GameObject to affect the appearance of.
Inspector Parameters
- Object To Affect: The GameObject to affect the appearance of. If this is null then then the interacting object will be used (usually the controller).
- Game Object Active By Default: If this is checked then the
Object To Affectwill be an active GameObject when the script is enabled. If it's unchecked then it will be disabled. This only takes effect ifAffect Interacting Objectis unticked. - Renderer Visible By Default: If this is checked then the
Object To Affectwill have visible renderers when the script is enabled. If it's unchecked then it will have it's renderers disabled. This only takes effect ifAffect Interacting Objectis unticked. - Game Object Active On Near Touch: If this is checked then the
Object To Affectwill be an active GameObject when theObject To Monitoris near touched. If it's unchecked then it will be disabled on near touch. - Renderer Visible On Near Touch: If this is checked then the
Object To Affectwill have visible renderers when theObject To Monitoris near touched. If it's unchecked then it will have it's renderers disabled on near touch. - Near Touch Appearance Delay: The amount of time to wait before the near touch appearance settings are applied after the near touch event.
- Near Untouch Appearance Delay: The amount of time to wait before the previous appearance settings are applied after the near untouch event.
- Valid Near Touch Interacting Object: Determines what type of interacting object will affect the appearance of the
Object To Affectafter the near touch and near untouch event. - Game Object Active On Touch: If this is checked then the
Object To Affectwill be an active GameObject when theObject To Monitoris touched. If it's unchecked then it will be disabled on touch. - Renderer Visible On Touch: If this is checked then the
Object To Affectwill have visible renderers when theObject To Monitoris touched. If it's unchecked then it will have it's renderers disabled on touch. - Touch Appearance Delay: The amount of time to wait before the touch appearance settings are applied after the touch event.
- Untouch Appearance Delay: The amount of time to wait before the previous appearance settings are applied after the untouch event.
- Valid Touch Interacting Object: Determines what type of interacting object will affect the appearance of the
Object To Affectafter the touch/untouch event. - Game Object Active On Grab: If this is checked then the
Object To Affectwill be an active GameObject when theObject To Monitoris grabbed. If it's unchecked then it will be disabled on grab. - Renderer Visible On Grab: If this is checked then the
Object To Affectwill have visible renderers when theObject To Monitoris grabbed. If it's unchecked then it will have it's renderers disabled on grab. - Grab Appearance Delay: The amount of time to wait before the grab appearance settings are applied after the grab event.
- Ungrab Appearance Delay: The amount of time to wait before the previous appearance settings are applied after the ungrab event.
- Valid Grab Interacting Object: Determines what type of interacting object will affect the appearance of the
Object To Affectafter the grab/ungrab event. - Game Object Active On Use: If this is checked then the
Object To Affectwill be an active GameObject when theObject To Monitoris used. If it's unchecked then it will be disabled on use. - Renderer Visible On Use: If this is checked then the
Object To Affectwill have visible renderers when theObject To Monitoris used. If it's unchecked then it will have it's renderers disabled on use. - Use Appearance Delay: The amount of time to wait before the use appearance settings are applied after the use event.
- Unuse Appearance Delay: The amount of time to wait before the previous appearance settings are applied after the unuse event.
- Valid Use Interacting Object: Determines what type of interacting object will affect the appearance of the
Object To Affectafter the use/unuse event.
Class Variables
public enum ValidInteractingObject- The valid interacting object.Anything- Any GameObject is considered a valid interacting object.EitherController- Only a game controller is considered a valid interacting objcet.NeitherController- Any GameObject except a game controller is considered a valid interacting object.LeftControllerOnly- Only the left game controller is considered a valid interacting objcet.RightControllerOnly- Only the right game controller is considered a valid interacting objcet.
Class Events
GameObjectEnabled- Emitted when the GameObject on theObject To Affectis enabled.GameObjectDisabled- Emitted when the GameObject on theObject To Affectis disabled.RenderersEnabled- Emitted when the Renderers on theObject To Affectare enabled.RenderersDisabled- Emitted when the Renderers on theObject To Affectare disabled.
Unity Events
Adding the VRTK_InteractObjectAppearance_UnityEvents component to VRTK_InteractObjectAppearance object allows access to UnityEvents that will react identically to the Class Events.
- All C# delegate events are mapped to a Unity Event with the
Onprefix. e.g.MyEvent->OnMyEvent.
Event Payload
GameObject affectingObject- The GameObject that is being affected.VRTK_InteractableObject monitoringObject- The Interactable Object that is being monitored.VRTK_InteractableObject.InteractionType interactionType- The type of interaction initiating the event.
Example
VRTK/Examples/008_Controller_UsingAGrabbedObject shows that the controller can be hidden when touching, grabbing and using an object.
Updated less than a minute ago
