question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for virtual mods

See original GitHub issue

Some time ago @Nystul-the-Magician raised the need to simplify mod testing and use debuggers during mod development and came up with this solution:

/*  
*   used for debugging
*   howto debug:
*       -) add a dummy GameObject to DaggerfallUnityGame scene
*       -) attach this script (_startupMod) as component
*       -) deactivate mod in mod list (since dummy gameobject will start up mod)
*       -) attach debugger and set breakpoint to one of the mod's cs files and debug
*/
void Awake()
{
     initMod();
}

The issue is that mod functionalities like settings, loading resources or localization are not functional during debug. So i decided to further develop the idea with a concept of “virtual mod”, which relies on a folder inside Assets/Game/Mods instead of an assetbundle when running inside the Editor. This is a pratical example:

public class Test : MonoBehaviour
{
    static Mod mod;

    [Invoke(StateManager.StateTypes.Start)]
    private void Init(InitParams initParams)
    {
        mod = initParams.Mod;
        var go = new GameObject(mod.Title);
        go.AddComponent<Test>();
    }

    private void Awake()
    {
#if UNITY_EDITOR
        if (mod == null)
            mod = new Mod("Test/Test.dfmod.json");
#endif

        mod.IsReady = true;
    }

    private void Start()
    {
        var settings = mod.GetSettings();
        int number = settings.GetValue<int>("Configuration", "Number");

        var texture = mod.GetAsset<Texture2D>("Example_Tex");
        var shader = mod.GetAsset<Shader>("NewUnlitShader");
        var material = mod.GetAsset<Material>("Example_Material");
    }
}

All the code is shared for both testing and releases because the Mod class instance handles loading assets from assetbundle, if running from a released mod, or Assets/Game/Mods/Test/Resources/ if running from a virtual debug mod environment. Ideally, this means you can write and test a mod with the same comfort of writing core code, and only build an assetbundle for release.

I published this to a separate branch for testing and get some opinions 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Nystul-the-Magiciancommented, Aug 11, 2019

will have to test this out the next time I touch my mods 😉

0reactions
AsesinoBladecommented, Sep 29, 2019

hi all, I finally got around to testing how this works, and can confirm that I have it working now. It is quite slick, just drop the mod builder dfmod.json file into assets\game\mods and the mod shows up in mods. Nicely Done!! I can now debug my mod scripts!

thanks again for the very fast responses. A

Read more comments on GitHub >

github_iconTop Results From Across the Web

MOD Assistants: Personal, Business & Virtual Assistants
Maximize your free time with things that enhance you truly enjoy. Hire a MOD Personal, Business or Virtual Assistant to help with the...
Read more >
The Best Mods That Add VR To Regular Games
Want to play classics like Doom, Half-Life, and Zelda in VR? Try these mods.
Read more >
ModSquad
ModSquad provides on-demand customer support, content moderation, social media, and community management services globally.
Read more >
Do SteamVR game mods work on Quest 2 using Virtual ...
If I use Virtual Desktop for Quest 2 and play a game such as Blade and Sorcery, if I have mods installed, will...
Read more >
Virtual Atelier - Cyberpunk 2077
A framework for other modders, that allows them to add virtual stores in-game for their modded clothes items.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found