unity-ugui-development
Skill1 starsChanged 5 months agoMITView on GitHub
Conventions for Unity UGUI development. ALWAYS Auto-loaded when writing UI code for Unity Projects using UGUI.
In this repository9 other files it gives its agents.
- unity-architecture-conventionsSkill
- unity-coding-conventionsSkill
- unity-folder-conventionsSkill
- unity-mcp-toolsSkill
- unity-performanceSkill
- unity-testingSkill
- unity-ugui-listSkill
- writing-testsSkill
- zenject-conventionsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Instead, reference the button in a script field and subscribe to its OnClick event in code:
- Distinctive: line 96
When external access to UI state is needed, components provide methods to load and export their state:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Unity UGUI Development
Conventions for developing UI with Unity's UGUI system.
Button Event Handling
Do NOT use Unity UGUI's button OnClick configuration in the inspector.
Instead, reference the button in a script field and subscribe to its OnClick event in code:
public class MyUIController : MonoBehaviour
{
[SerializeField] private Button _submitButton;
private void Start()
{
_submitButton.onClick.AddListener(HandleSubmitClicked);
}
private void HandleSubmitClicked()
{
// Handle click
}
private void OnDestroy()
{
_submitButton.onClick.RemoveListener(HandleSubmitClicked);
}
}Reason: Inspector-configured button events are easy to accidentally break and harder to track in code.
Class Naming Conventions
| Suffix | Purpose | Example |
| UIPanel | Container | SettingsUIPanel, InventoryUIPanel |
| UIComponent | Container with specific functionality | ListUIComponent, TabUIComponent |
| UIItem | Item that is part of a list | PlayerListUIItem, InventorySlotUIItem |
Property-Based Data Binding
Bind uGUI text elements through properties for clean data access:
[SerializeField] private TMP_Text _titleText;
public string Title
{
get => _titleText.text;
set => _titleText.text = value;
}Dependency Inversion via Delegates
Smaller components should NOT reference their containing elements. Use events/delegates to communicate upward:
// UIItem does NOT know about its container
public class PlayerListUIItem : MonoBehaviour
{
public event Action<PlayerListUIItem> OnSelected;
public event Action<PlayerListUIItem> OnDeleteRequested;
[SerializeField] private Button _selectButton;
[SerializeField] private Button _deleteButton;
private void Awake()
{
_selectButton.onClick.AddListener(() => OnSelected?.Invoke(this));
_deleteButton.onClick.AddListener(() => OnDeleteRequested?.Invoke(this));
}
}
// Container subscribes to item events
public class PlayerListUIComponent : MonoBehaviour
{
private void SetupItem(PlayerListUIItem item)
{
item.OnSelected += HandleItemSelected;
item.OnDeleteRequested += HandleItemDeleteRequested;
}
}Memento Pattern (State Persistence)
When external access to UI state is needed, components provide methods to load and export their state:
public class CharacterCreationUIPanel : MonoBehaviour
{
// Load state into UI
public void SetData(CharacterData data)
{
Name = data.Name;
Class = data.Class;
Level = data.Level;
}
// Export current UI state
public CharacterData ExportData()
{
return new CharacterData
{
Name = Name,
Class = Class,
Level = Level
};
}
// Refresh UI from stored data source
public void RefreshFromDataSource()
{
SetData(_currentDataSource);
}
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

