Can't access one Mod from another Mod through the recommended method?

Discuss modding questions and implementation details.
Post Reply
DFIronman
Posts: 84
Joined: Sat Aug 24, 2019 12:48 am

Can't access one Mod from another Mod through the recommended method?

Post by DFIronman »

So I broke up the next version of my mod into two .dfmods, and I needed to access one of them from the other via Reflection. I got information on how I'm supposed to do it here, but the method listed doesn't seem to work? The type string is definitely correct. Is it because I'm calling from a different assembly and need to account for that somehow?

Code: Select all

                    // For some reason, this will be null.
                    IronmanType = mod.GetCompiledType("DaggerfallWorkshop.Game.Mods.Ironman.Ironman");

                    // This will be null as well. IronmanGO is a GameObject with the Ironman Component
                    // that I need to access attached.
                    IronmanComponent = IronmanGO.GetComponent("DaggerfallWorkshop.Game.Mods.Ironman.Ironman");
However, this code works and I was able to communicate with the other mod.

Code: Select all

                    // This works and I can get data from the Component.
                    foreach (Component c in IronmanGO.GetComponents<Component>())
                    {
                        if (c.GetType().ToString() == "DaggerfallWorkshop.Game.Mods.Ironman.Ironman")
                            IronmanComponent = c;
                    }
Edit: Not sure why the Mod.GetCompiledType() function doesn't seem to work (I'm calling it from the OnStartMenu() event), but after finding the component, you can just do the following to get access to the type itself:

Code: Select all

IronmanType = Type.GetType(IronmanComponent.GetType() + ", " + IronmanComponent.GetType().Assembly.GetName());

Post Reply