Search Unity

Hibzz.DefineManager - A Tool to Manage Scripting Defines across Packages

Discussion in 'Assets and Asset Store' started by sliptrixx, May 15, 2022.

  1. sliptrixx

    sliptrixx

    Joined:
    Mar 24, 2016
    Posts:
    12
    Today I launched the Beta for Hibzz.DefineManager, an open-source tool that provides an interface to easily manage scripting defines in a Unity project and other supporting packages. Please check it out on Github.

    Why do I need this?
    Scripting defines helps keep the code clean and provides a clean interface to your custom packages. For example, if the package has an optional feature to add autocomplete to a console plugin, but if the user doesn't need that feature, none of the code needs to be included in the project. If that section of the code is ignored using a Scripting Define, the IntelliSense in a user's IDE would not bring up related properties, functions, classes, etc.

    Using Scripting Defines can also help manage sections of code an if/else statement can't reach such as attributes, variables, and more.

    Interface

    To open the interface, navigate to Windows -> Define Manager and click it to open the window.

    It provides an interface similar to Unity's package manager that helps users navigate through a familiar interface. The left tab contains a list of available defines that were registered by developers with collapsible categories. When a define is clicked, it provides more information on what the define would do. The install button would add the define to the project (and if already installed, helps remove it from the project).

    How to register a Scriptable Define using Hibzz.DefineManager?
    Code (CSharp):
    1. #if ENABLE_DEFINE_MANAGER
    2. using Hibzz.DefineManager;
    3.  
    4. public class DemoScript
    5. {
    6.     static DefineRegistrationData DemoRegisterFunction()
    7.     {
    8.          DefineRegistrationData data = new DefineRegistrationData();
    9.  
    10.          data.Define = "DEMO_DEFINE";
    11.          data.DisplayName = "Demo Feature";
    12.          data.Category = "Random Category";
    13.          data.Description = "Detailed description goes here";
    14.          data.EnableByDefault = false;
    15.  
    16.          return data;
    17.     }
    18. }
    19. #endif
    If a user doesn't have this package installed, will it cause issues if I register Defines for this package?
    No. I was very careful about this when I designed this tool. Users shouldn't be forced to install this tool to keep another package functional. As long as you have the registration code wrapped up in #if ENABLE_DEFINE_MANAGER, users who don't have the tool installed should have a smooth experience.

    Furthermore, if a user wants to enable any registered optional features, they may add the Scripting Defines manually under the Player settings.

    Have more thoughts or questions?
    Feel free to contact me, either here, or in github issues. Or tweet at me @hibzzgames.
     
    DragonCoder likes this.