86 lines
3.3 KiB
Markdown
86 lines
3.3 KiB
Markdown
# XUniWindowController
|
|
|
|
**XUniWindowController** is a Unity native plugin that provides comprehensive **standalone application window control** for Windows and macOS builds.
|
|
|
|
It allows you to control window transparency, click-through, topmost/bottommost z-order, maximize, file drop, native file dialogs, and multi-monitor window fitting — all from C# scripts through a simple Unity component.
|
|
|
|
## Features
|
|
|
|
- **Window Transparency** — Alpha blending or ColorKey-based transparency
|
|
- **Click-Through** — Make the window ignore mouse events
|
|
- **Z-Order Control** — Set window topmost, bottommost, or normal
|
|
- **Maximize / Restore** — Themed maximize and restore
|
|
- **Borderless Mode** — Hide the title bar and border
|
|
- **Window Position & Size** — Get/set window position and size
|
|
- **Multi-Monitor Support** — Fit window to any connected display
|
|
- **File Drop** — Receive file paths from drag-and-drop
|
|
- **Native File Dialogs** — Open and save file dialogs (Windows/macOS native)
|
|
- **Drag Move** — Drag the window by any UI element
|
|
|
|
## Requirements
|
|
|
|
- Unity 2022.3 or later
|
|
- Windows or macOS standalone build target
|
|
|
|
## Installation
|
|
|
|
### Via Package Manager
|
|
|
|
1. Open **Window > Package Manager**
|
|
2. Click the **+** button > **Add package from git URL**
|
|
3. Enter the repository URL
|
|
|
|
### Via disk (local package)
|
|
|
|
1. Copy the `com.lrss3.xuniwindowcontroller` folder to your project's `Packages/` directory
|
|
2. Package Manager will automatically pick it up
|
|
|
|
## Getting Started
|
|
|
|
1. Add a **UniWindowController** component to any GameObject in your scene (or use the prefab from samples)
|
|
2. Configure the Inspector properties:
|
|
- **Is Transparent** — Enable window transparency
|
|
- **Is Topmost** — Keep window on top
|
|
- **Hit Test Type** — Choose opacity-based or raycast-based click-through detection
|
|
3. Call methods or toggle properties at runtime:
|
|
|
|
```csharp
|
|
var winc = UniWindowController.current;
|
|
winc.isTransparent = true; // Enable transparency
|
|
winc.isTopmost = true; // Keep on top
|
|
winc.isClickThrough = false; // Disable click-through
|
|
```
|
|
|
|
## Samples
|
|
|
|
The package includes 5 sample scenes:
|
|
|
|
| Sample | Description |
|
|
|--------|-------------|
|
|
| **Menu** | Navigation menu for browsing all samples |
|
|
| **SimpleSample** | Minimal window control setup |
|
|
| **UiSample** | Full UI with toggles, sliders, dropdowns for all features |
|
|
| **Fullscreen** | Fullscreen mode + right-click context menu + 3D scene |
|
|
| **FileDialog** | Native open/save file dialog demonstration |
|
|
|
|
Import samples via **Package Manager > XUniWindowController > Samples**.
|
|
|
|
## How It Works
|
|
|
|
On **Windows**, the plugin uses `LibUniWinC.dll` (C++ Win32 API) to call:
|
|
- `SetWindowLong` — modify window styles
|
|
- `SetWindowPos` — control z-order and position
|
|
- `DwmExtendFrameIntoClientArea` — DWM transparency
|
|
- `SetLayeredWindowAttributes` — layered window transparency
|
|
- `DragAcceptFiles` / window subclassing — file drop handling
|
|
|
|
On **macOS**, the plugin uses `LibUniWinC.bundle` (Swift / Cocoa) to call:
|
|
- `NSWindow.styleMask` — borderless mode
|
|
- `NSWindow.level` — z-order control
|
|
- `NSWindow.isOpaque` / `backgroundColor` — transparency
|
|
- `NSDraggingDestination` protocol — file drop
|
|
- `NSOpenPanel` / `NSSavePanel` — native dialogs
|
|
|
|
## License
|
|
|
|
This package is based on [UniWindowController](https://github.com/kirurobo/UniWindowController) by Kirurobo, licensed under the MIT License. |