---
agentTools:
  projectIndex: https://vrtoolkit.readme.io/llms.txt
---

# VRTK_ObjectAppearance

> extends [VRTK\_InteractableListener](https://vrtoolkit.readme.io/docs/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 the `Object To Monitor` parameter.

**Script Usage:**

* Place the `VRTK_InteractObjectAppearance` script on either:
  * The GameObject of the Interactable Object to detect interactions on.
  * Any other scene GameObject and provide a valid `VRTK_InteractableObject` component to the `Object To Monitor` parameter of this script.
* Optionally provide a GameObject to the `Object To Affect` parameter 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 Affect` will be an active GameObject when the script is enabled. If it's unchecked then it will be disabled. This only takes effect if `Affect Interacting Object` is unticked.
* **Renderer Visible By Default:** If this is checked then the `Object To Affect` will have visible renderers when the script is enabled. If it's unchecked then it will have it's renderers disabled. This only takes effect if `Affect Interacting Object` is unticked.
* **Game Object Active On Near Touch:** If this is checked then the `Object To Affect` will be an active GameObject when the `Object To Monitor` is 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 Affect` will have visible renderers when the `Object To Monitor` is 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 Affect` after the near touch and near untouch event.
* **Game Object Active On Touch:** If this is checked then the `Object To Affect` will be an active GameObject when the `Object To Monitor` is touched. If it's unchecked then it will be disabled on touch.
* **Renderer Visible On Touch:** If this is checked then the `Object To Affect` will have visible renderers when the `Object To Monitor` is 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 Affect` after the touch/untouch event.
* **Game Object Active On Grab:** If this is checked then the `Object To Affect` will be an active GameObject when the `Object To Monitor` is grabbed. If it's unchecked then it will be disabled on grab.
* **Renderer Visible On Grab:** If this is checked then the `Object To Affect` will have visible renderers when the `Object To Monitor` is 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 Affect` after the grab/ungrab event.
* **Game Object Active On Use:** If this is checked then the `Object To Affect` will be an active GameObject when the `Object To Monitor` is used. If it's unchecked then it will be disabled on use.
* **Renderer Visible On Use:** If this is checked then the `Object To Affect` will have visible renderers when the `Object To Monitor` is 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 Affect` after 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 the `Object To Affect` is enabled.
* `GameObjectDisabled` - Emitted when the GameObject on the `Object To Affect` is disabled.
* `RenderersEnabled` - Emitted when the Renderers on the `Object To Affect` are enabled.
* `RenderersDisabled` - Emitted when the Renderers on the `Object To Affect` are 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 `On` prefix. 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.