-
-
Notifications
You must be signed in to change notification settings - Fork 0
StrangeToggle
Fynn9563 edited this page Jan 28, 2026
·
1 revision
StrangeToggle is an interactive component that creates toggleable objects with optional state persistence.
Video Tutorial
Coming soon - video tutorial placeholder
Use StrangeToggle for:
- Light switches
- Doors and gates
- Interactive displays
- Any on/off interaction
| Property | Type | Description |
|---|---|---|
| persistenceID | string | Unique identifier for state saving |
| usePersistence | bool | Enable/disable state saving |
| defaultOn | bool | Starting state (when no saved state) |
| sceneHub | StrangeHub | Reference to the scene's hub |
| Property | Type | Description |
|---|---|---|
| toggleObjects | GameObject[] | Objects to activate/deactivate |
| emissionRenderers | Renderer[] | Renderers with emission to toggle |
| emissionOnColor | Color | Emission color when ON |
| emissionOffColor | Color | Emission color when OFF |
| animators | Animator[] | Animators to sync with toggle state |
| animatorBoolParam | string | Bool parameter name to set |
| Property | Type | Description |
|---|---|---|
| soundSource | AudioSource | AudioSource for feedback sounds |
| onSound | AudioClip | Sound when toggled ON |
| offSound | AudioClip | Sound when toggled OFF |
Called by VRChat when a player interacts with the object.
// Automatically called by VRChat
public override void Interact()
{
Toggle();
}Toggles between ON and OFF states.
// Can be called from other scripts
toggle.Toggle();Applies the current state to all visual targets.
// Force visual refresh
toggle.UpdateVisuals();Loads saved state from the hub. Called on player join.
// Restore saved state
toggle.RefreshPersistence();- State flips (ON → OFF or OFF → ON)
- If persistence enabled, saves to hub
- Plays appropriate sound (if configured)
- Updates all visuals
For each target type:
Toggle Objects:
-
SetActive(state)on each GameObject
Emission Renderers:
- Sets
_EmissionColorto on/off color - Calls
DynamicGI.SetEmissive()for lighting update
Animators:
- Sets bool parameter to current state
In the Unity editor, StrangeToggle displays:
- Yellow sphere at toggle position
- Cyan line to StrangeHub
- White lines to toggle objects
- Magenta lines to emission renderers
- Green lines to animators
This visualization helps verify connections without selecting the object.
persistenceID: "room_light"
usePersistence: true
defaultOn: false
toggleObjects: [LightObject]
onSound: switch_click.wav
offSound: switch_click.wav
persistenceID: "neon_sign"
usePersistence: true
defaultOn: true
emissionRenderers: [SignRenderer]
emissionOnColor: (1, 0, 0.5, 1) // Pink glow
emissionOffColor: (0, 0, 0, 1) // No glow
onSound: buzz_on.wav
offSound: buzz_off.wav
persistenceID: "front_door"
usePersistence: false
defaultOn: false
animators: [DoorAnimator]
animatorBoolParam: "IsOpen"
toggleObjects: [DoorCollider] // Disable collider when open
onSound: door_open.wav
offSound: door_close.wav
persistenceID: "control_panel"
usePersistence: true
defaultOn: false
toggleObjects: [Light1, Light2, FanObject]
emissionRenderers: [ButtonRenderer, IndicatorRenderer]
emissionOnColor: (0, 1, 0, 1) // Green
emissionOffColor: (1, 0, 0, 1) // Red
animators: [PanelAnimator]
animatorBoolParam: "Activated"
onSound: panel_activate.wav
offSound: panel_deactivate.wav
- Use descriptive names:
kitchen_light,garage_door - Keep unique across the entire world
- Don't change after publishing (breaks saved states)
- Limit toggle objects to necessary items
- Use animators for complex state changes
- Keep sounds short (< 1 second)
- Set AudioSource to 3D spatial blend for positional audio
- Keep volume reasonable
- Test sound distances in VRChat
- Create a simple bool parameter
- Make transitions with conditions
- Avoid complex state machines for toggles
- Verify object has a collider for interaction
- Check that StrangeHub is assigned
- Ensure the object is on an interactable layer
- Check
usePersistenceis enabled - Verify
persistenceIDis not empty - Confirm StrangeHub reference is set
- Verify material uses Standard shader or has
_EmissionColor - Check emission is enabled on the material
- Ensure renderer is in the
emissionRenderersarray
- Check AudioSource is assigned
- Verify AudioClips are assigned
- Test AudioSource plays in isolation