https://github.com/qqw1584913629/autouibinder
Unity UI Auto Binder - A powerful editor extension that automatically binds UI components through visual icons in the Hierarchy window, eliminating manual drag-and-drop operations. Generate type-safe references with a single click.
https://github.com/qqw1584913629/autouibinder
csharp game game-development unity unity2d unity3d
Last synced: 3 months ago
JSON representation
Unity UI Auto Binder - A powerful editor extension that automatically binds UI components through visual icons in the Hierarchy window, eliminating manual drag-and-drop operations. Generate type-safe references with a single click.
- Host: GitHub
- URL: https://github.com/qqw1584913629/autouibinder
- Owner: qqw1584913629
- License: mit
- Created: 2025-07-01T08:35:30.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-28T06:20:39.000Z (11 months ago)
- Last Synced: 2025-07-28T08:25:01.595Z (11 months ago)
- Topics: csharp, game, game-development, unity, unity2d, unity3d
- Language: C#
- Homepage:
- Size: 2.3 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AutoUIBinder
The Ultimate Unity UI Development Tool
---
> **Stop writing repetitive UI binding code!** AutoUIBinder revolutionizes Unity UI development with visual component binding and automatic code generation.
## What You'll Get
**Transform your UI development workflow from this:**
```csharp
// Manual binding - tedious and error-prone
public Button startButton;
public Text titleText;
public Image backgroundImage;
void Awake() {
startButton = transform.Find("Button_Start").GetComponent();
titleText = transform.Find("Text_Title").GetComponent();
// ... manual binding for every component
}
```
**To this simple workflow:**
```csharp
// Just inherit and generate - that's it!
public partial class MyUIPanel : AutoUIBinderBase
{
void Start() {
// All components auto-generated and ready to use
Button_Start.onClick.AddListener(OnStartClick);
Text_Title.text = "Welcome!";
}
}
```
## Quick Start (5 Minutes)
### 3 Steps to Success
#### 1. Create Your UI Script
```csharp
public class MainMenuPanel : AutoUIBinderBase
{
// That's it! No manual component declarations needed
}
```
#### 2. Visual Binding
- Attach script to your prefab root
- Enter prefab edit mode
- **Click the component icons** in Hierarchy - they'll highlight when bound!
- Real-time visual feedback shows binding status
#### 3. Generate & Use
```csharp
// Click "Generate UI Code" in Inspector
// Then use your components immediately:
void Start() {
Button_Play.onClick.AddListener(() => StartGame());
Text_PlayerName.text = PlayerPrefs.GetString("name");
Slider_Volume.value = AudioListener.volume;
}
```
## Visual Demonstration
### Visual Component Binding
Click component icons in Hierarchy to bind them instantly - see the visual feedback in real-time!
> Generated Code:
Comprehensive component references and bindings generated automatically
Component instances retrieved via dictionary, maintaining O(1) efficiency
## User Interface
## Key Features
- **Visual Binding** - Click component icons in Hierarchy to bind instantly
- **One-Click Generation** - Generate all component references automatically
- **Smart Naming** - Handles conflicts and invalid characters intelligently
- **Zero Configuration** - Works out of the box with sensible defaults
## Project Structure
```
Assets/
├── AutoUIBinder/ # Core tool
│ ├── Core/ # Core implementation
│ │ ├── Runtime/ # Runtime code
│ │ │ ├── Attributes/ # Custom attributes
│ │ │ ├── Base/ # Base classes
│ │ │ └── Utils/ # Utility classes
│ │ └── Editor/ # Editor code
│ │ ├── Config/ # Configuration
│ │ ├── Core/ # Core editor functionality
│ │ └── Drawers/ # Custom drawers
│ └── Examples/ # Example code
├── Scripts/ # Your project scripts
│ └── Gen/ # Generated code (auto-created)
└── Resources/ # Resource files
└── GlobalConfig.asset # Global configuration
```
## Configuration
### Global Settings
Configure code generation path in `Resources/GlobalConfig.asset`:
1. Click "Select Folder" in Inspector
2. Choose your script directory (usually `Assets/Scripts`)
3. Generated code will be saved in `{path}/Gen/{className}/`
### Code Generation Rules
- **Generated file naming:** `{className}Gen.cs`
- **Uses partial class pattern** - won't overwrite your main code
- **Component property naming:** `{NodeName}_{ComponentType}`
## Interface Features
### Enhanced Hierarchy Window
- **Background Color Coding** - Different colors for different AutoUIBinderBase types
- **Component Icons** - Visual indicators for all UI components
- **Binding Status** - Special highlighting for bound components
- **Interactive Binding** - Click icons to bind/unbind instantly
### Improved Inspector Panel
- **Component Reference Table** - Clean overview of all bound components
- **One-Click Generation** - Prominent "Generate UI Code" button
- **Real-time Validation** - Automatically detects and reports invalid references
- **Binding Statistics** - Shows bound/total component counts
## Advanced Features
### Smart Naming System
AutoUIBinder intelligently handles:
- **Duplicate Detection** - Auto-adds numeric suffixes for duplicate names
- **Invalid Characters** - Auto-replaces spaces and special characters
- **C# Keyword Conflicts** - Avoids using reserved keywords as variable names
- **User Confirmation** - Interactive dialogs for naming conflicts
### Performance Optimizations
- **Event-Driven Architecture** - Responsive to Unity's event system
- **Memory Efficient** - Minimal runtime overhead
### Robust Error Handling
- **Graceful Recovery** - Auto-recovers binding state after editor restart
- **Validation Checks** - Prevents common binding errors before they occur
- **User-Friendly Messages** - Clear, actionable error descriptions
## Best Practices
### Component Organization
- Keep UI hierarchies clean and organized
- Use empty GameObjects as containers for logical grouping
- Name GameObjects consistently across different panels
### Code Structure
- Keep your main UI class focused on game logic
- Use the generated partial class for component references
- Organize methods clearly for clean separation of concerns
## Contributing
**We welcome community contributions!**
- **Report Bugs** - Help us improve by reporting issues
- **Suggest Features** - Share your ideas for new functionality
- **Submit Pull Requests** - Contribute code improvements
- **Star the Project** - Show your support and help others discover AutoUIBinder
## License
MIT License - see [LICENSE](LICENSE) for details.
---
AutoUIBinder - Making Unity UI Development a Breeze!