--------------------------------------------
Utility Classes
Utility Classes are helper classes in unity to help with common functionalities that are often used which simplify repetitive tasks and improve code reusability.
These classes are static and often use static methods or properties and mainly used to encapsulate reusable logic.
While making unity projects, you can make a 'Utility' folder and put these classes in there.
NOTE : Classes and methods should be static and should not derive from Monobehaviour
Some common examples of Utility Classes
Debug Utility Class
Singleton Utility Class
Scene Management Utility Class
Input Utility Class
--------------------------------------------
Extension Methods
Extension methods allow to add new methods to existing classes or interfaces without modifying the original class or creating a new derived class.
Allow to 'extend' the functionality in a reusable manner.
Extension methods are defined as static methods but are invoked as if they were instance methods.
The first parameter of the method specifies the type it extends, and it is prefixed with the this keyword.
NOTE: Class should be static and the method itself should be static as well.
Example:
---------------------------------------------------
Extending Unity Editor
Menu extension tools in unity allows to add custom functionalities to Unity Editor's menus.
These tools enhance productivity by automating repetitive tasks, improving workflows, and adding functionality.
It requires the [MenuItem] attribute in unity and UnityEditor header file.
Examples:
Comments