Desktop Mascot Maker - DirectComposition Edition#
A Unity asset for creating desktop mascots (desktop accessories) on Windows.
Table of Contents#
- About This Asset
- System Requirements
- New Features (v3.0.0)
- Getting Started
- MascotMakerDComp Component Reference
- MascotMakerDComp API Reference
- Event Callbacks
- Example Scenes
- Troubleshooting
- Performance and Optimization
- Known Limitations
- Contact
About This Asset#
Desktop Mascot Maker - DirectComposition Edition is a Unity asset that allows you to display characters and animations created in Unity as Windows desktop mascots (desktop accessories).
Key Features#
- High-Performance Rendering: GPU hardware acceleration using DirectComposition + Direct3D 11
- Zero-Copy Texture Sharing: Direct sharing of Unity RenderTexture on GPU, eliminating CPU transfer
- Significant CPU Load Reduction: 70-90% reduction in CPU usage compared to the previous version (v2.2.0 GDI/WinForms edition)
- Two Window Modes:
- Rectangle Window: Fast and lightweight rectangular window mode
- Alpha Mask Window: Cell-based window shape formation mode
- Context Menu Support: Display custom menus with right-click
- IL2CPP Support: Supports both Mono and IL2CPP build backends
- Rich Event System: Handle mouse and window events with UnityEvent
Differences from Previous Version#
The previous version (v2.2.0) used WinForms + GDI/UpdateLayeredWindow, but this version (v3.0.0) adopts DirectComposition to solve the following problems:
❌ Previous Version Issues:
- High CPU load (texture copy from GPU→CPU every frame)
- GDI/GDI+ is not GPU accelerated
- Issues with DPI scaling in high-DPI and multi-monitor environments
- Only Mono build backend supported (no IL2CPP support)
✅ DirectComposition Edition Improvements:
- 70-90% CPU usage reduction (zero-copy processing on GPU)
- Hardware acceleration via DirectComposition
- Full support for high-DPI and multi-monitor environments
- IL2CPP build backend support
If you wish to use the previous version (v2.2.0), please import and use DesktopMascotMakerV220.unitypackage.
System Requirements#
Required Environment#
| Item | Requirement |
|---|---|
| OS | Windows 10 (1803 or later) or Windows 11 |
| Unity Version | Unity 2020.3 LTS or later recommended |
| Graphics API | Direct3D 11 only |
| Build Backend | Mono or IL2CPP |
| Architecture | x86 (32-bit) or x86_64 (64-bit) |
Important Settings#
1. Set Graphics API to Direct3D 11#
Steps:
Edit→Project Settings→PlayerOther Settingssection- Remove all except Direct3D 11 from
Graphics APIs for Windows - Ensure Direct3D 11 is at the top (priority)
Note: Direct3D 12, Vulkan, and OpenGL are not supported.
2. When Using IL2CPP#
IL2CPP build backend is fully supported. No additional settings required.
New Features (v3.0.0)#
Significant Performance Improvements with DirectComposition#
- 70-90% CPU usage reduction: Significant reduction in CPU load through zero-copy texture sharing on GPU
- Hardware Acceleration: GPU rendering via DirectComposition
- High-DPI Support: Resolved scaling issues in multi-monitor and high-DPI environments
Two Window Modes#
Alpha Mask Window Mode#
- Divides the rendering area into cells and forms a window only with cells containing opaque pixels
- ✓ Transparent cells allow click-through
- ✓ Draggable (opaque cells only)
- △ Performance (window shape update cost)
- Recommended use: Complex-shaped mascots, when click-through is required
Rectangle Window Mode (Default)#
- Simple rectangular window
- ✗ No click-through (entire window accepts clicks)
- ✓ Draggable (choose “anywhere” or “opaque regions only” with Draggable Area)
- ✓ Good performance (no window shape updates, alpha mask only used for DragOpaqueOnly)
- Recommended use: Simple mascots, performance-critical applications
Context Menu#
- Display custom menus with right-click
- Dynamically add/remove custom items
- Built-in “Close” and “Exit Application” menu items
- Automatic separator insertion
IL2CPP Support#
- Previous version (v2.2.0) only supported Mono
- v3.0.0 fully supports IL2CPP build backend
Allow 'unsafe' Codeoption is not required (was required in previous version)
Other Improvements#
- No .NET Framework Required: DirectComposition native plugin uses only Windows API
- Clean Code: Minimized debug logs, well-commented for users
- Source Code Distribution: C++ DLL source code and detailed build documentation included
Getting Started#
1. Project Setup#
Graphics API Settings#
Edit→Project Settings→PlayerOther Settings→Graphics APIs for Windows- Remove all except Direct3D 11
2. Basic Usage#
Step 1: Prepare Camera#
- Create a camera to capture the character you want to display as a desktop mascot
- Set camera’s
Clear FlagstoSolid Color - Set
Backgroundcolor alpha value to 0 (fully transparent)
Step 2: Attach MascotMakerDComp Component#
- Attach
MascotMakerDCompcomponent to the camera - Adjust settings in Inspector (see next section for details)
Step 3: Verify in Play Mode#
- Run Unity Editor Play mode
- Mascot window will appear on desktop
- Drag the mascot to move it
3. Minimal Example#
| |
MascotMakerDComp Component Reference#
Basic Settings#
| Item | Description | Default Value |
|---|---|---|
| Mascot Window Size | Window size in pixels Note: Cannot be changed after initialization | (480, 640) |
| Play On Awake | Automatically initialize and show window on Start | true |
| Draggable | Enable window dragging with mouse | true |
Window Position#
| Item | Description | Default Value |
|---|---|---|
| Left | Horizontal window position (screen coordinates, top-left origin) | 100 |
| Top | Vertical window position (screen coordinates, top-left origin) | 100 |
Appearance#
| Item | Description | Default Value |
|---|---|---|
| Background Color | Background color (automatically converted to Premultiplied Alpha format) | (0, 0, 0, 0) |
| Opacity | Window opacity (0.0-1.0) | 1.0 |
| Top Most | Always keep window on top | true |
| Anti Aliasing | Anti-aliasing qualityNone / TwoSamples / FourSamples / EightSamples | FourSamples |
Window Mode#
| Item | Description | Default Value |
|---|---|---|
| Window Mode | RectangleWindow: Rectangular window mode (fast)AlphaMaskWindow: Cell-based window shape formation | RectangleWindow |
Rectangle Window Settings (Used in Rectangle Window mode)#
| Item | Description | Default Value |
|---|---|---|
| Draggable Area | Draggable regionDragAnywhere - Can drag from anywhere in the windowDragOpaqueOnly - Can only drag from opaque regions (uses alpha mask) | DragOpaqueOnly |
Alpha Mask Settings (Used in Alpha Mask Window mode)#
| Item | Description | Default Value |
|---|---|---|
| Precision | Alpha mask precisionLow (12x16 grid) - FastestMedium (24x32 grid) - RecommendedHigh (48x64 grid) - Highest accuracy | Low |
| Update Mode | Alpha mask update timingEveryFrame - Update every frame (for animations, high load)Periodic - Periodic update (recommended)Manual - Manual update only (best performance) | Periodic |
| Alpha Threshold | Transparency threshold (0.0-1.0) Pixels with alpha value greater than this threshold are considered opaque | 0.5 |
| Periodic Update Interval | Update interval in seconds (0.016-1.0) Only shown in Periodic mode | 0.1 |
Context Menu Settings#
| Item | Description | Default Value |
|---|---|---|
| Context Menu Items | List of custom menu items Each item has Label (display text) and OnSelected (action on selection) | Empty |
| Context Menu Show Close | Show built-in “Close” menu item | false |
| Context Menu Show Exit | Show built-in “Exit Application” menu item | false |
How to add custom menu items:
- Increase size of
Context Menu Items - Enter menu display text in
Labelfor each item - Set up processing for when selected in
OnSelectedevent
MascotMakerDComp API Reference#
Window Show/Hide#
void Show()#
Shows the window (also initializes if not yet initialized).
| |
void Hide()#
Hides the window (window is not destroyed).
| |
bool IsVisible { get; }#
Gets whether the window is currently visible.
| |
Window Position#
int Left { get; set; }#
int Top { get; set; }#
Gets or sets the window position (screen coordinates, top-left origin).
| |
Window Size#
Vector2 MascotWindowSize { get; set; }#
Gets or sets the window size (in pixels).
| |
Important: Window size cannot be changed after initialization. Only set before initialization (before Awake/Start). Even if you change the size at runtime, the initial value will continue to be used.
Context Menu#
void AddContextMenuItem(string label, UnityAction onSelected = null)#
Adds a context menu item at runtime.
| |
void ClearContextMenuItems()#
Clears all custom context menu items.
| |
Window Mode#
WindowMode Mode { get; set; }#
Gets or sets the window mode.
| |
Alpha Mask Settings#
float AlphaThreshold { get; set; }#
Gets or sets the alpha mask threshold (0.0-1.0).
| |
HitTestPrecision Precision { get; set; }#
Gets or sets the alpha mask precision. Generally, Low is sufficient.
| |
HitTestUpdateMode UpdateMode { get; set; }#
Gets or sets the alpha mask update mode.
| |
void UpdateAlphaMask()#
Manually updates the alpha mask (used when Update Mode is Manual).
| |
Mouse State Query#
Vector2 GetMousePosition()#
Gets the mouse position within the mascot window.
| |
bool IsMouseOver()#
Gets whether the mouse is over the mascot window.
| |
bool IsLeftButtonPressed()#
bool IsRightButtonPressed()#
bool IsMiddleButtonPressed()#
Gets whether each mouse button is pressed.
| |
Other#
void Shutdown()#
Closes the window and releases resources (normally called automatically).
| |
Event Callbacks#
MascotMakerDComp can handle mouse and window events with UnityEvent.
Mouse Events#
Left Mouse Button#
- OnLeftMouseDown: When left mouse button is pressed (receives
Vector2 mousePos) - OnLeftMouseUp: When left mouse button is released (receives
Vector2 mousePos) - OnLeftDoubleClick: When left mouse button is double-clicked (receives
Vector2 mousePos)
| |
Right Mouse Button#
- OnRightMouseDown: When right mouse button is pressed (receives
Vector2 mousePos) - OnRightMouseUp: When right mouse button is released (receives
Vector2 mousePos) - OnRightDoubleClick: When right mouse button is double-clicked (receives
Vector2 mousePos)
| |
Middle Mouse Button#
- OnMiddleMouseDown: When middle mouse button is pressed (receives
Vector2 mousePos) - OnMiddleMouseUp: When middle mouse button is released (receives
Vector2 mousePos) - OnMiddleDoubleClick: When middle mouse button is double-clicked (receives
Vector2 mousePos)
| |
Mouse Wheel#
- OnMouseWheel: When mouse wheel is scrolled (receives
int delta)
| |
Window Events#
- OnMove: When window is moved (receives
Vector2 windowPos)
| |
- OnDestroyed: Just before MascotMakerDComp component is destroyed
| |
Context Menu Events#
- OnContextMenuOpening: Just before context menu opens (allows dynamic menu item addition/removal)
| |
Note: Selection events for custom menu items are handled in each ContextMenuItem’s OnSelected event.
Example Scenes#
Demo01_Event
- Demo to verify mouse events, window events, and context menu events
- Context menu demo
Demo02_MultipleMascot
- Demo displaying multiple mascot characters
- AI script that automatically moves windows
- Rectangle Window Mode
Demo03_AlphaMaskWindow
- Demo to verify Alpha Mask Window shape (Alpha Mask Window Mode)
- Character Orbital View
- Context Menu Close
Troubleshooting#
Window Does Not Appear#
Causes and Solutions:
Graphics API is not Direct3D 11
- Check
Project Settings→Player→Graphics APIs for Windows - Enable only Direct3D 11
- Check
DLL Not Found
- Check for
DllNotFoundExceptionerror in Unity Console - Verify that
Assets/DesktopMascotMaker/Plugins/x86_64/DCompMascot.dll(64-bit) orAssets/DesktopMascotMaker/Plugins/x86/DCompMascot.dll(32-bit) exists
- Check for
Play On Awake is Disabled
- Check if
Play On Awakeis checked in Inspector - Or call
mascot.Show()from script
- Check if
Window Click Detection is Strange#
For Rectangle Window mode:
- In Rectangle Window mode, the entire window is the hit detection area
- Transparent parts are also clickable (affects underlying windows)
- If you need cell-based transparency detection, switch to Alpha Mask Window mode
For Alpha Mask Window mode:
Adjust Alpha Threshold
- Pixels with alpha value greater than this threshold are considered opaque
- Default: 0.5 (0.0-1.0)
Adjust Precision
Low: 12x16 grid (fastest, lower accuracy)Medium: 24x32 grid (recommended, balanced)High: 48x64 grid (high accuracy, somewhat heavy)
Poor Performance (Low FPS)#
Solutions:
Use Rectangle Window mode
- Alpha Mask Window mode has higher load than Rectangle Window
Lower Precision
- When using Alpha Mask Window mode, change Precision from
Medium→Low
- When using Alpha Mask Window mode, change Precision from
Set Update Mode to Periodic or Manual
EveryFrameupdates every frame, causing high load- For static mascots,
Manualis recommended
Increase Periodic Update Interval
- Increasing update interval from 0.1s → 0.2s or more will reduce load
Reduce Window Size
- Larger windows increase load
Check Camera Settings
- Disable unnecessary Post-Processing effects
Performance and Optimization#
Performance Improvements with DirectComposition#
Compared to the previous version (v2.2.0 GDI/WinForms), the DirectComposition edition (v3.0.0) achieves the following improvements:
- 70-90% CPU usage reduction: Zero-copy texture sharing on GPU
- Frame rate stabilization: Stable rendering with GPU hardware acceleration
- Memory bandwidth reduction: Elimination of texture copy between CPU↔GPU
Performance by Window Mode#
| Mode | CPU Load | GPU Load | Use Case |
|---|---|---|---|
| Rectangle Window | Minimal | Minimal | Simple shapes, performance priority |
| Alpha Mask Window | Somewhat high | Somewhat high | Complex shapes, cell-based transparency detection required |
Optimization Tips#
Window Mode Selection
- Use Rectangle Window mode unless you have a specific reason
- Use Alpha Mask Window only when click-through is required
Precision Adjustment
Lowprovides sufficient accuracy (12x16 grid, 192 cells)- For more complex shapes, try
Medium(24x32 grid, 768 cells)
Update Mode Selection
- Static mascots: Use
Manualand callUpdateAlphaMask()only when needed - Animations: Use
Periodicwith Interval set to 0.2s or more - Real-time changes: Use
EveryFrame(highest load)
- Static mascots: Use
Optimization for Multiple Mascots
- Randomize
Periodic Update Intervalfor each mascot (automatically offset) - Unify Precision to
Low - Hide unnecessary mascots with
Hide()
- Randomize
Known Limitations#
Supported Platforms#
- Windows 10/11 only: DirectComposition is a Windows-exclusive API
- macOS, Linux, mobile platforms not supported
Graphics API#
- Only Direct3D 11 supported: Direct3D 12, Vulkan, OpenGL not supported
- Must use Direct3D 11 in both Unity Editor and Standalone Build
Window Features#
- Window size cannot be changed after initialization: Runtime resizing is not supported
- No minimize/maximize buttons: Borderless window for desktop mascot purposes
- Not shown in taskbar: By design as a desktop accessory
Multi-Monitor#
- Generally supported: Window can move between multiple monitors
- Initial position is on primary monitor:
Left/Topare based on primary monitor screen coordinates
Contact#
Technical Support#
If you encounter problems or have questions, please contact:
- Email: support@panzersoft.com
Bug Reports#
When reporting bugs, please include the following information:
- Unity version
- OS version (Windows 10/11)
- Steps to reproduce
- Error messages from Unity Console
- (If possible) Minimal reproduction sample project
Thank you for choosing Desktop Mascot Maker - DirectComposition Edition!