Hello,
I've just started fiddling with making mods. Is it true that mods can only be made in the editor if you build them? If so... why?? The modding code is compiled alongside all of the other code in the editor, right? Building after every tweak makes things super slow...
Am I missing something?
Thank you,
Josh
Why do mods need to be built when playing in the editor?
- joshcamas
- Posts: 87
- Joined: Mon Sep 21, 2020 7:01 am
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Why do mods need to be built when playing in the editor?
You don't need to build after every tweak.
Follow this to place the files and build the mod so it interacts correctly with the Unity editor and the master code.
How to build a mod:
1: Open the master files in Unity.
2: Create a new folder with the name of your intended mod in Assets/Game/Mods.
3: Create a script file containing your mod script. Put this in the folder you just made.
4: Click "Daggerfall Tools"->"Mod Builder"
5: Click "Create A New Mod". Select the folder you created in Assets/Game/Mods.
6: Fill in the name, version etc fields in the Mod Builder window.
7: Select the script file you made in step 3. Click "Add selected assets"
8: Click "Save Mod settings to file"
10: Click “Build Mod”. Select a folder outside the project folders.
11: Give Unity about 5 minutes to build the mod.
After you have built the mod the first time, you now have a dfmod.json file and your asset files (scripts, textures models whatnot) that the dfmod.json file refers to.
If you now load up the startup scene in the unity editor, your mod will appear in the modlist. This is the loose files, not the compiled mod build. So any changes you make to the files will be in effect when you load up the scene.
When you have a version of your code you want to compile into a proper mod file, that's when you use the mod building tool again.
Follow this to place the files and build the mod so it interacts correctly with the Unity editor and the master code.
How to build a mod:
1: Open the master files in Unity.
2: Create a new folder with the name of your intended mod in Assets/Game/Mods.
3: Create a script file containing your mod script. Put this in the folder you just made.
4: Click "Daggerfall Tools"->"Mod Builder"
5: Click "Create A New Mod". Select the folder you created in Assets/Game/Mods.
6: Fill in the name, version etc fields in the Mod Builder window.
7: Select the script file you made in step 3. Click "Add selected assets"
8: Click "Save Mod settings to file"
10: Click “Build Mod”. Select a folder outside the project folders.
11: Give Unity about 5 minutes to build the mod.
After you have built the mod the first time, you now have a dfmod.json file and your asset files (scripts, textures models whatnot) that the dfmod.json file refers to.
If you now load up the startup scene in the unity editor, your mod will appear in the modlist. This is the loose files, not the compiled mod build. So any changes you make to the files will be in effect when you load up the scene.
When you have a version of your code you want to compile into a proper mod file, that's when you use the mod building tool again.
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Why do mods need to be built when playing in the editor?
Your folders in unity should look like this:
Note: the "Climtes & Calories.dfmod" you see there is actually the file "Climates & Calories.dfmod.json". File extensions are not shown.
Note: the "Climtes & Calories.dfmod" you see there is actually the file "Climates & Calories.dfmod.json". File extensions are not shown.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Why do mods need to be built when playing in the editor?
By the way you don't need to do steps 10&11 - until you're ready to build a dfmod package for releasing of course. Once you have the .dfmod.json file saved it will run virtual.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Why do mods need to be built when playing in the editor?
Yes and no. It builds the dfmod.json file for you. I've found it's easier than doing it by hand. Also, you make sure you're actually able to build the mod
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Why do mods need to be built when playing in the editor?
Once the json file is saved you're good to go for running mod virtual is my point.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- joshcamas
- Posts: 87
- Joined: Mon Sep 21, 2020 7:01 am
Re: Why do mods need to be built when playing in the editor?
Oh good, I'm glad there's virtual mode!! I see now that it does indeed show up in the mod menu
I got it to work! My issue was I was playing in the "DaggerfallUnityGame" scene, which doesn't have mods, I guess? Playing from the startup scene works
I got it to work! My issue was I was playing in the "DaggerfallUnityGame" scene, which doesn't have mods, I guess? Playing from the startup scene works