top of page
Rahul Chandra

Tips to Make Games Fast(Unity Engine Edition)




--------------------------------------------

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
  1. Extension methods allow to add new methods to existing classes or interfaces without modifying the original class or creating a new derived class.

  2. Allow to 'extend' the functionality in a reusable manner.

  3. Extension methods are defined as static methods but are invoked as if they were instance methods.

  4. 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:

Transform Extensions
Gameobject Extensions

---------------------------------------------------

Extending Unity Editor

  1. Menu extension tools in unity allows to add custom functionalities to Unity Editor's menus.

  2. These tools enhance productivity by automating repetitive tasks, improving workflows, and adding functionality.

  3. It requires the [MenuItem] attribute in unity and UnityEditor header file.

Examples:


Reset Transform

Reload Scene

Comments


bottom of page