Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Open Source] ModTool - Mod Support for Unity

Discussion in 'Assets and Asset Store' started by HelloMeow, Nov 21, 2016.

  1. SolidJuho

    SolidJuho

    Joined:
    Oct 23, 2016
    Posts:
    11
    Thank you so much for helping me out on that API Assembly problem.
    After playing around while I started noticing when importing package all of these stuff under C: which are not selectable, what are those or are those about that unity 2018.2 complications with runtime scripts?
     
  2. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Since Unity 2017.1 the generated packages have been a bit bloated. For some reason Unity includes all kinds of unnecessary stuff when you tell it to include the project settings. I'm going to have to include the project settings manually.
     
  3. geigi

    geigi

    Joined:
    Sep 5, 2018
    Posts:
    4
    Hey,
    is it possible to call mod exporting from code? I'd like to integrate my project into GitLab CI.
    Thanks for this awesome library :)
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    Did you log a bug with them? I'll back you up
    What's the status on that? 2018.3 has loads of changes regarding asset loading and I wonder if maybe this was fixed, or broken further.
     
  5. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    I haven't heard from them other than that they could reproduce the issue. I'll try to ask them again soon.

    Do you mean how to start exporting a mod from code? You can do that with ModExporter.Export(exportSettings). Both ModExporter and ExportSettings are singletons.
     
    laurentlavigne likes this.
  6. geigi

    geigi

    Joined:
    Sep 5, 2018
    Posts:
    4
    Yes, thanks a lot. To get it working I had to manually move the DLLs from
    Assets/ModTool/Editor
    to
    Assets/ModTool
    . Otherwise Unity didn't include them in the csrpoj references. I guess this might cause problems when updating the
    Mod.unitypackage
    . Maybe you could consider moving them?
     
  7. geigi

    geigi

    Joined:
    Sep 5, 2018
    Posts:
    4
    I came across some more issues: I need to change the
    outputDirectory
    because it is different on the build bot, but it is only readable from code.

    Also I created a script
    BuildCommand
    which setups and starts the build process. But because this script (and also the csproj) is referencing
    ModToolExporting.Editor
    it is not possible to export the mod. So this turned out to be a bigger problem than I thought. A solution would be
    ModTool
    supporting some kind of a Script blacklist that will not be included in the build. But it propably also needs to take care of the csproj references as these are required for the
    BuildCommand
    script to work.

    What are your thoughts on this?
     
  8. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Is it an option to place whatever is using ModExporter in an editor folder? Because that's how it is supposed to be used.

    Otherwise it will be included in the Assembly-CSharp dll, which won't have access to UnityEditor outside of the editor.
     
  9. geigi

    geigi

    Joined:
    Sep 5, 2018
    Posts:
    4
    Ahh I see! Thanks for the clarification, that was the solution :) I ran into another issue I could resolve. You can run Unity in batchmode so that it closes itself after a specifiec static method is executed and finished. As
    ExportMod
    finishes before the export is complete, Unity quit mid process. You can disable the automatic exit but then I need to detect that the export has finished somehow in order to close Unity myself.

    I tried to implement a
    ExportFinished
    event similar to the
    ExportStarted
    event but the event handler in my static
    BuildCommand
    class was never called. The Event was fired in
    StopExport
    . I think this might have something to do with ModExporter moving the Script files on export?

    My current solution is a bool
    ExitOnFinish
    member in ModExporter which can be set before export. ModTool quits Unity by itself if this bool is set.

    I'd like to implement this in a more proper way if you have any idea how to do this with an event. You can find my changes to ModTool here if you're interested: https://github.com/geigi/ModTool
     
    catherineomega likes this.
  10. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Yeah it does a couple of assembly reloads during the exporting process. So any initial state is lost unless it is serialized.

    You might be able to subscribe to the ExportFinished event in a static method with the InitializeOnLoadMethod attribute, or use EditorPrefs in some way.
     
    geigi likes this.
  11. GaborL

    GaborL

    Joined:
    Oct 31, 2015
    Posts:
    6
    Hi!
    Can I export classes to the mod pack?
    For example I have a "Weapon" class and I want to export it for the modder, so the modder could create new weapons.
     
  12. SolidJuho

    SolidJuho

    Joined:
    Oct 23, 2016
    Posts:
    11
    So, is there any update of editor runtime scripts not working?
    We have 2018.3 released and 2019.1 in alpha/beta, Has anyone tried these yet?
     
  13. GattaiGames

    GattaiGames

    Joined:
    Apr 16, 2015
    Posts:
    9
    I just tested with Unity 2018.2.0f2 (64-bit) and am getting a .meta error while trying to export the scripts.

    upload_2019-1-8_12-50-19.png

    Which I believe is causing the scripts to not be loaded when trying to run them

    upload_2019-1-8_12-52-6.png

    Did I miss out something? Thanks for the time!
     

    Attached Files:

  14. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    This appears to be fixed in Unity 2019.
     
  15. finaldrace

    finaldrace

    Joined:
    Dec 27, 2015
    Posts:
    2
    upload_2019-2-2_1-35-26.png
    I can use older Mods, but when i try to use "Export Mod" with the Unity 2019 compiled exporter, then it shows these errors and warnings
     
  16. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
  17. finaldrace

    finaldrace

    Joined:
    Dec 27, 2015
    Posts:
    2
    Thank you now it works :)

    do you think there is a chance for future IL2CPP support?
     
  18. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Unfortunately not, because IL2CPP does not support Assembly.Load. This means it can't load DLLs at runtime.
     
  19. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    111
    Hi there,
    very cool asset! Do you plan to add support for IOS and WebGl too?
     
  20. kiwiboys

    kiwiboys

    Joined:
    Oct 6, 2013
    Posts:
    12
    Hey HelloMeow

    I was taking a look at the mod tool and it's very intuitive and can be very powerful. I was wondering if there was a way to create a white list of certain namespaces methods and class's for the code validation as there are quite a few to go through, its always easy to miss something so if everything was blocked at the start say for a few of the main ones, it might be easier to prevent certain mods getting out that may have malicious code and such.
    Is there any functionality like that currently?
     
  21. gvergidis

    gvergidis

    Joined:
    Apr 5, 2018
    Posts:
    11
    Hello. I have a problem if you could please help me. I have created a mod which included a script. This script derives from an interface which interface was passed as dll assembly from main project. When I add the mod to the main project, I can not understand how will I load the script based on interface type? How can we load scripts from mod?
     
  22. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    You can do this with Mod.GetInstances().

    Nope, unfortunately not. This sounds like a good thing to have.

    No. These platforms have restrictions that make it impossible.
     
    Last edited: Sep 24, 2019
  23. DrScatmanOTH

    DrScatmanOTH

    Joined:
    Nov 24, 2019
    Posts:
    1
    Hello,

    I am having an issue where when importing the mod tool from the asset store into Unity 2019.3 all scripts referencing assets in the 'Standard Assets' folder are throwing errors stating that they are missing assembly references/directives.

    Any help in resolving this issue would be very much appreciated
     
  24. cwxxc3

    cwxxc3

    Joined:
    Feb 1, 2017
    Posts:
    23
    Is IL2CPP supported if you're not adding scripts in the mods? So just assets and scenes
     
  25. Polemus

    Polemus

    Joined:
    Nov 14, 2016
    Posts:
    28
    How would one go about including a script in the export?

    I have Assets\Mods\Base\TerrainSettings.cs

    TerrainSettings looks as follow:

    Code (CSharp):
    1. namespace BlueMods
    2. {
    3.     public class TerrainSettings : MonoBehaviour //ModBehaviour
    4.     {
    5.         public float OceaLevel;
    6.     }
    7. }
    I would like to include this script for the modder to be able to add this component to their mod.

    I am able to include it if i create a separate C# project and then add the assembly to my project, but this is a massive pain if i have to make a change.

    It would be great if i could select scripts that could be exported.
     
  26. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Hi, is it possible to create a Unity application that will export a mod file that can be imported into my game. I don't want the modders to have to learn the Unity Editor. The mods would not include any code just updates to textures and changes to material settings etc.

    Thanks

    Glenn
     
  27. Polemus

    Polemus

    Joined:
    Nov 14, 2016
    Posts:
    28
    Not working in 2019.3.12f1
     
  28. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    It seems to be working for me on this version. What is the issue you are having?

    Hi Glenn,

    Since the exporter uses a lot of editor code, it can't work in any kind of standalone build. I think what you might need is some kind of in-game editor.
     
  29. modiohq

    modiohq

    Joined:
    Nov 15, 2019
    Posts:
    13
    Last edited: Jul 5, 2020
    FaberVi and one_one like this.
  30. bigclu

    bigclu

    Joined:
    Jun 25, 2013
    Posts:
    2
    can i use the Serializable ,such as
    Code (CSharp):
    1.  [Serializable]
    2.     public class TestData {
    3.             public int a = 0;
    4.             public string str = "a";
    5.     }
    when i use it in inspector ,and make mod . i will lost the data ,can u help me?
     
  31. AiDev123

    AiDev123

    Joined:
    Sep 7, 2016
    Posts:
    17
    Hey I emailed you but I just want to make sure I get a response as quick as possible, and I see you're responding pretty recently on here. I've developed an android app and implemented this mod tool, it works perfectly fine importing the mods into the editor but when I build a version on my phone it wont load up the maps when I hit the load button on the mod. Android is selected as the platform in the mod exporter. I have no clue what to do so any help would be appreciated
     
  32. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Does the mod show up and load on android? Are there any error messages you can see?

    You can try logging the mod's scenes to see if it even finds the scenes.
     
  33. AiDev123

    AiDev123

    Joined:
    Sep 7, 2016
    Posts:
    17
    Haha sorry kind of a back and forwards on email, I'll just talk to you on here. The mod shows up on android, but it doesn't load the map. I checked the log file (thats if the [modname].info is the log file) in it after already, but it didn't appear to show any errors. Do I need to change the log level in the mod exporter to see things like that?
     
  34. AiDev123

    AiDev123

    Joined:
    Sep 7, 2016
    Posts:
    17
    quick update I just re exported the mod with the logging level on error to see if that would show me errors and it didn't seem to do anything different
     
  35. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    193
    Awesome tool, thank you.
     
  36. ZombieMan_0901

    ZombieMan_0901

    Joined:
    Jan 21, 2020
    Posts:
    6
    Accidentally put on page 2, but im wondering if this has UWP support?
     
  37. Player11132

    Player11132

    Joined:
    Sep 25, 2020
    Posts:
    2
    Hello, I have a question regarding that API stuff. I may have understood wrong what it does. What I think it does is it enables the modder to use commands in a set namespace? For example I want the modder to be able to use the SpawnBot() by simply saying
    Code (CSharp):
    1. using game_mod_tools;
    or in namespace game_mod_tools for example, is that possible with this plugin? Also, does it check for duplicate prefabs already in the build? Or is there a way to do that?
     
  38. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    API Assemblies doesn't use namespaces, but assemblies. These are the compiled code you can get from building a C# project, or by using Asssembly Definitions in your unity project.

    ModTool doesn't check for duplicate prefabs. I think it would be a bit difficult to define what counts as a duplicate. There would have to be some kind of system that lets you include prefabs in the mod tools, which currently isn't there.
     
  39. Daar375

    Daar375

    Joined:
    Jul 4, 2013
    Posts:
    1
    Is there anyway to use an inherited classes from the main project when making mods? I would like to standardize the mod making process for ease to use, but i am not sure if the mod supports it
     
  40. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    You can include classes which the mod project can inherit from, if that's what you mean. You can add a .dll or Assembly Definition name to "API Assemblies" in ModTool's settings, which will then be included in the importer.

    In recent versions of Unity this is a bit buggy, because I haven't spent a lot of time updating ModTool. It should still work, but Unity will complain. I'm currently working on a big update for ModTool which makes all of this much easier.
     
  41. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    For the next update I'm overhauling the export process, adding support for addressables and adding shared assets between game and mod projects. Mod scripts used to be exported via a complicated process, which is now replaced with a much more streamlined and robust method using Assembly Definitions.



    Instead of having to fumble around with API assemblies, you will be able to select what you want to include in the exporter, including scripts, assembly definitions, prefabs and any other type of asset. You'll also be able to use addressables, which lets modders use any shared asset without making duplicates each time a mod is exported.

    If anyone is still following this thread and has any related or unrelated feature requests, please let me know.
     
    J2T and itsugamer like this.
  42. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Hi! I cannot figure out one thing. I had project on 2018.4 and lightmaps mods were working fine, since I upgraded project to 2019.4 , mods with lightmaps have broken light. Most of the materials are black. The weird thing is that when I change shader during runtime on these black assets, then lightmaps are back. For example if mod have diffuse shader and I switch in loaded mod to standard, then lightmaps are back, same opposite. If I switch from standard to diffuse (or any other) then lightmaps are back. Seems like changing shader refreshes this. Not sure if it's something with my project settings...still investigating, but maybe you will have some idea. Thanks for great tool! :)

    ps. I see that there are some updates on github, version in project is roughly 2 years old

    edit : I disabled all shader stripping, lightmap modes are custom set to all. Also they are black even if I test it in editor, not on build, so it wouldn't be lack of shaders I think
     
    Last edited: May 20, 2022
  43. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    I think I've never used lightmaps in Unity. Is there a specific way to set this up so I can test it?
     
  44. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Just create simple mod with couple static objects, turn on global illumination , set to shadowmask for example, set directional light to mixed or baked and bake it. Then load this mod and you will notice that materials are black, unless you will switch shader, then lightmaps will appear. Weird is that we had this working before migrating project to 2019, but somehow broke now. If I figure this out, I will post some update here
     
  45. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    Lightmaps seem to work for me in version 2019.4.39f1.

    All ModTool does to load a scene is load it from an asset bundle. If that doesn't work properly, I think it's probably an issue with Unity itself. I'm not sure what could be wrong, although I did find some other people having issues with lightmaps and assetbundles in Unity 2019.
     
  46. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Thanks for checking this. I'm going to investigate it more. Were your project settings default? It could be something there. Also do project settings in mod itself matters when exporting or it's just snapshot of editor scene?
     
  47. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    I tested this with a clean project and default settings.

    The main game's project settings are included when creating the exporter. The mod's project settings won't be exported.

    If there's a mismatch between the game's and mod's project settings it could cause some issues. Especially with tags and input settings. I don't know if it's causing the issues you're experiencing.
     
    roundyyy likes this.
  48. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Seems like problem solved. Mod project setting had to have manual lightmap modes selected, automatic was not working correctly
     
  49. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    280
    ModTool 2.0 here! This version brings many breaking changes. Redundant features have been removed and most other features have been completely reworked.

    Version 2.0 is now available on the Asset Store and gitHub:
    https://github.com/Hello-Meow/ModTool/releases/tag/2.0
    http://u3d.as/Diq

    Change log:
    -Added shared assets
    -Added shared packages
    -Improved exporter creation
    -Improved mod export process
    -Improved mod object management
    -Removed ModBehaviour and related classes
    -Simplified mod loading
    -Added Resource.errors
    -Removed API Assemblies
    -ModManager no longer refreshes by default
    -And more...
     
    Last edited: Jun 7, 2022
    J2T likes this.
  50. dre788

    dre788

    Joined:
    Feb 15, 2013
    Posts:
    52