Unity Snippets for Zed
A comprehensive collection of Unity C# snippets for the Zed editor, designed to accelerate Unity game development with quick access to commonly used Unity classes, methods, and patterns.
Inspired by VSCode Unity Code Snippets by Kleber Silva
Features
This extension provides 100+ code snippets covering:
Core Unity Classes
- MonoBehaviour - Complete class template with using statements
- ScriptableObject - Class template with CreateAssetMenu attribute
- StateMachineBehaviour - Animator state machine behavior template
- NetworkBehaviour - Unity networking class template
Unity Editor Extensions
- Editor - Custom inspector editor template
- EditorWindow - Custom editor window template
- PropertyDrawer - Custom property drawer template
- ScriptableWizard - Custom wizard template
- Editor with Reorderable List - Advanced editor with reorderable list support
MonoBehaviour Lifecycle Methods
Complete coverage of all Unity MonoBehaviour callback methods:
- Core lifecycle:
Awake,Start,Update,FixedUpdate,LateUpdate - Object lifecycle:
OnEnable,OnDisable,OnDestroy,OnValidate,Reset - Collision detection:
OnCollisionEnter,OnCollisionStay,OnCollisionExit(2D variants included) - Trigger detection:
OnTriggerEnter,OnTriggerStay,OnTriggerExit(2D variants included) - Mouse events:
OnMouseDown,OnMouseUp,OnMouseEnter,OnMouseExit, etc. - Rendering:
OnPreRender,OnPostRender,OnRenderObject,OnDrawGizmos, etc. - Animation:
OnAnimatorIK,OnAnimatorMove - Physics:
OnJointBreak,OnControllerColliderHit,OnParticleCollision - Networking:
OnPlayerConnected,OnPlayerDisconnected,OnServerInitialized - And many more...
StateMachineBehaviour Methods
OnStateEnter,OnStateExit,OnStateUpdate,OnStateMove,OnStateIK
Editor Window Methods
OnFocus,OnLostFocus,OnSelectionChange,OnProjectChange,OnInspectorUpdate
Debug Utilities
Debug.Log,Debug.LogError,Debug.LogWarning,Debug.LogException- Formatted logging:
Debug.LogFormat,Debug.LogErrorFormat,Debug.LogWarningFormat - Visual debugging:
Debug.DrawLine,Debug.DrawRay
Common Attributes
[SerializeField]- For private field serialization[RequireComponent]- Component dependency enforcement
General C# Templates
- Generic class template
- Interface template
Installation
- Open Zed editor
- Open the command palette (
Cmd+Shift+Pon macOS,Ctrl+Shift+Pon Windows/Linux) - Type "zed: extensions" and select it
- Search for "Unity Snippets"
- Click "Install"
Usage
Simply start typing any of the snippet prefixes in a C# file and press Tab to expand the snippet. The snippets are context-aware and will work best in .cs files.
Examples
Type MonoBehaviour and press Tab:
using UnityEngine;
public class YourClassName : MonoBehaviour {
}Type Start and press Tab:
private void Start() {
}Type OnTriggerEnter and press Tab:
private void OnTriggerEnter(Collider other) {
}Type Debug.Log and press Tab:
Debug.Log();Snippet Prefixes
All snippets use intuitive prefixes that match Unity's naming conventions:
- Classes:
MonoBehaviour,ScriptableObject,StateMachineBehaviour, etc. - Methods:
Start,Update,OnTriggerEnter,OnCollisionEnter, etc. - Debug:
Debug.Log,Debug.LogError,Debug.DrawLine, etc. - Attributes:
SerializeField,RequireComponent
Contributing
Contributions are welcome! If you have suggestions for additional snippets or improvements, please:
- Fork the repository
- Create a feature branch
- Add your snippets to
snippets/csharp.json - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
0.0.1
- Initial release with 100+ Unity C# snippets
- Complete MonoBehaviour lifecycle methods
- Unity Editor extension templates
- Debug utilities
- Common attributes and general C# templates
Support
If you encounter any issues or have feature requests, please open an issue on GitHub.