How ureishi/qvpen works
1. What this repo is
- A Unity-based VRChat world pen system called QvPen.
- The code is organized as a reusable Unity package under Assets/QvPen, with runtime prefabs, Udon scripts, shaders, meshes, materials, and a sample/world scene.
2. Primary runtime boundary
- The core runtime lives in Assets/QvPen/Runtime.
- C# source is split into Udon scripts and UI/World scripts, indicating this is meant for VRChat Udon/UdonSharp-style execution rather than a conventional Unity MonoBehaviour app.
- The compiled/runtime Udon assets are stored separately in Runtime/UdonAsset and SerializedUdonPrograms, which is the generated layer that the scene/prefabs actually reference.
3. Main system split: pen, eraser, manager
- The central interaction model is split into:
- Pen: QvPen_Pen, QvPen_PenManager
- Eraser: QvPen_Eraser, QvPen_EraserManager
- Top-level orchestration: QvPen_Manager
- This suggests a hierarchy where the manager coordinates tool modes and tool state, while pen/eraser components do the actual drawing/removal behavior.
4. User interaction and UI layer
- The Runtime/UdonScript/UI folder contains the user-facing control scripts:
- clear button / clear-all button
- reset-all button
- show/hide button
- toggle-mode button
- interact button
- These likely act as thin event-driven controllers that call into the main pen/eraser managers, forming the main input-to-action boundary.
5. World/player behavior and local state
- Runtime/UdonScript/World/QvPen_PlayerMods.cs suggests per-player or world-level behavior customization.
- QvPen_Settings.cs and QvPen_LateSync.cs indicate there is a configuration/state layer and a synchronization layer, likely handling delayed propagation of tool state or ownership-related updates in a multiplayer VRChat context.
6. Rendering pipeline for strokes
- The visual stroke system is backed by a custom shader: Shader/rounded_trail_for_qv_pen.shader.
- Materials are separated by target/environment:
- Ink_PC.mat and Ink_Quest.mat
- multiple pen colors in Material/Pen
- eraser materials in Material/Eraser
- pointer/reticle materials in Material/pointer
- a wood.mat likely used for the physical pen or scene props
- This indicates the pen’s appearance is not just script-driven; it has a dedicated rendering/material layer with PC/Quest compatibility.
7. Physical/scene assets
- Mesh/qv_pen.fbx and Mesh/qv_eraser.fbx are the main 3D models.
- Prefabs such as PenManager.prefab, EraserManager.prefab, QvPen.prefab, and QvPen(grad).prefab are the primary composition units.
- QvPen.unity is the scene-level integration point where the full system is assembled and tested.
8. State and configuration assets
- The many .asset files in Runtime/UdonAsset appear to be serialized Udon program assets for each logical component.
- QvPen.asset, QvPen.version.txt, and QvPen.asmdef indicate the package has a defined assembly boundary, versioning, and a distributable package identity.
- The architecture clearly separates editable source from generated runtime data.
9. Editor/tooling boundary
- Packages/com.vrchat.core.vpm-resolver is a bundled editor dependency for VRChat package resolution.
- This is infrastructure for authoring/building the world package, not part of the in-world runtime.
- The project also includes standard Unity project settings and VRChat-related package settings under ProjectSettings.
10. Likely end-to-end data flow
- Player interacts with UI or tool objects in the world.
- UI events go to the relevant Udon script controller.
- Controllers delegate to manager components, which route to pen or eraser behavior.
- Pen actions produce rendered trail/stroke output through the shader/material/mesh layer.
- Eraser and clear/reset actions mutate or remove those stroke objects.
- Sync/state scripts help keep behavior consistent across players in the VRChat world.
Main entry points: QvPen_Manager.cs Manager · UI UI controls · Runtime Runtime core · Prefab Prefabs
Components 20
QvPen package
Reusable Unity package content for the pen world system.
- QvPen package · Package boundary and distributable identity for the system.
Assets/QvPen/package.json - Assembly · C# assembly boundary for the package.
Assets/QvPen/QvPen.asmdef
Runtime
In-world Udon runtime scripts and generated program assets.
- Runtime core · Main in-world execution boundary for the pen system.
Assets/QvPen/Runtime - Udon assets · Generated Udon program assets referenced by prefabs and scene objects.
Assets/QvPen/Runtime/UdonAsset - Manager · Top-level coordination for tool modes and shared state.
Assets/QvPen/Runtime/UdonScript/QvPen_Manager.cs - Pen manager · Coordinates pen tool behavior and state.
Assets/QvPen/Runtime/UdonScript/QvPen_PenManager.cs - Pen · Core drawing behavior that creates strokes and ink output.
Assets/QvPen/Runtime/UdonScript/QvPen_Pen.cs - Eraser manager · Coordinates eraser behavior and state.
Assets/QvPen/Runtime/UdonScript/QvPen_EraserManager.cs - Eraser · Core erase behavior for removing strokes.
Assets/QvPen/Runtime/UdonScript/QvPen_Eraser.cs - Settings · Shared configuration and runtime options for the system.
Assets/QvPen/Runtime/UdonScript/QvPen_Settings.cs - Late sync · Delayed synchronization layer for multiplayer/world state updates.
Assets/QvPen/Runtime/UdonScript/QvPen_LateSync.cs - Player mods · Per-player or world-level behavior customization hooks.
Assets/QvPen/Runtime/UdonScript/World/QvPen_PlayerMods.cs - UI controls · World UI scripts that forward user actions into tool managers.
Assets/QvPen/Runtime/UdonScript/UI
Visual assets
Meshes, materials, shader, and textures used by the pen system.
- Stroke shader · Custom trail shader used to render pen strokes.
Assets/QvPen/Shader/rounded_trail_for_qv_pen.shader - Materials · Ink, pen, eraser, pointer, and wood materials for visual variants.
Assets/QvPen/Material - Meshes · Main physical models for the pen and eraser props.
Assets/QvPen/Mesh
Scene/prefabs
Prefab and scene assembly points that compose the runtime.
- Prefabs · Reusable prefab compositions for pen and eraser managers and world objects.
Assets/QvPen/Prefab - QvPen prefab · Primary assembled world object for the pen system.
Assets/QvPen/QvPen.prefab - Sample scene · Scene-level integration and test assembly for the full system.
Assets/QvPen/QvPen.unity
Editor tooling
Bundled VRChat package resolver/editor infrastructure.
- VPM resolver · Bundled VRChat package resolution and authoring support.
Packages/com.vrchat.core.vpm-resolver
Connections 27
- QvPen package → Assembly: defines · Package boundary is implemented through a dedicated assembly.
- QvPen package → Runtime core: contains · Package includes the runtime execution layer.
- QvPen package → Prefabs: contains · Package ships prefab composition units.
- Runtime core → Udon assets: generated assets · Source scripts are paired with serialized Udon program assets.
- Runtime core → Manager: hosts · Runtime root contains the main orchestration script.
- Runtime core → UI controls: hosts · Runtime root contains user-facing control scripts.
- Manager → Pen manager: routes tool mode · Top-level manager delegates pen mode control.
- Manager → Eraser manager: routes tool mode · Top-level manager delegates eraser mode control.
- Pen manager → Pen: controls · Pen manager coordinates drawing behavior.
- Eraser manager → Eraser: controls · Eraser manager coordinates removal behavior.
- UI controls → Manager: events · UI actions forward into orchestration/state changes.
- UI controls → Pen manager: mode/actions · Tool buttons interact with pen controls.
- UI controls → Eraser manager: mode/actions · Tool buttons interact with eraser controls.
- UI controls → Settings: toggles · UI can adjust shared configuration/state.
- Late sync → Manager: syncs state · Synchronization layer keeps shared runtime state consistent.
- Player mods → Manager: customizes · Player/world behavior hooks affect orchestration.
- Pen → Stroke shader: renders via · Stroke output depends on the custom trail shader.
- Pen → Materials: uses · Pen drawing relies on ink and color materials.
- Eraser → Materials: uses · Eraser visuals rely on eraser materials.
- Prefabs → Meshes: composes · Prefabs assemble the pen and eraser meshes.
- Prefabs → Materials: composes · Prefabs bind visual material variants.
- Prefabs → Udon assets: references · Prefab instances reference serialized Udon programs.
- QvPen prefab → Manager: includes · Primary world prefab includes the orchestration component.
- QvPen prefab → Pen manager: includes · Primary world prefab includes pen management.
- QvPen prefab → Eraser manager: includes · Primary world prefab includes eraser management.
- Sample scene → QvPen prefab: assembles · Scene composes the full world object for testing/integration.
- VPM resolver → QvPen package: supports authoring · Editor tooling supports package resolution and packaging.