Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Released] uMod 2.0 - Modding support made easy!

Discussion in 'Assets and Asset Store' started by scottyboy805, Jan 6, 2017.

  1. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Hi, There are no plans at this time to support mobile platforms. We could possible support mobile in the future for content only mods (No scripts), but that would be quite a way off.
     
  2. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    I was looking forward to learning from your tanks example, however I am receiving errors on play indicating that the mods are not loadable by the tanks game.

    For example: [ModHost (UMod.ModHost)]: The mod ' Canyon Level ' is not loadable by this game


    Does the example project still work? Perhaps something changed in the tank demo. Any help would be much appreciated!
     
  3. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Hi,
    The mods that we created for the tanks demo game are game locked meaning that they can only be loaded by the project/game that created the mod tools package (Project id information is compiled into the mod). To load the mods in your game you will need to disable game locking for your project which is quite simple. You will need to go to 'Tools -> uMod 2.0 -> Mod Tools Builder' and select the security tab. From there you can disable the 'Allow Game Locking' option and build the mod tools package via the 'Export' tab. Note that the resulting mod tools package is not required but the build process will update various uMod settings assets. After the build is complete, you should then be able to load the mods in your game as game locking checks will no longer run.

    Let me know if you have any difficulty or if you have any more questions.
     
    Graham-B likes this.
  4. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    Thank you, I'll try this. You can disregard my email.
     
  5. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    So I tried your suggestion. (for reference I am using Unity 2019.4.10)

    First I used "Export in Current Project" and the result was the same console errors as before.

    Second I specified a directory outside of the Assets folder and exported there. Result, same errors.

    Third I specified a directory inside of the assets folder. Result, same errors on play, and now I can no longer open the mod tools builder window.
     
  6. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Thanks for trying those steps.
    Exporting in assets folder looks like it has corrupted the tools setting asset. It can be fixed easily by reimporting the asset 'Assets/UMod/Resources/Editor/ModToolsSettings.asset' from the asset store. Exporting in the assets folder should not be allowed in the first place though (A path check should prevent this) so we will look into why that happended.

    As for the mod load errors: We are currently trying a test project and will get back to you shortly.
     
  7. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    I have looked into the mod load errors you reported and it is indeed caused by game locking. After speaking with my colleague, it turns out that game locking can no longer be disabled in the game by modifying the build tools settings. As a result, the only way to get around the issue was for us to rebuild all mods for the game with game locking disabled. This means that you can now load them from any project. I have attached the updated mod files for you but we will also be submitting an update shortly with the changes.

    As a side note: When loading the 'Canyon Level' mod, you may receive a number of warnings such as:

    'Failed to relink game asset with guid...'

    If this occurs, you will need to rebuild the mod tools package like you did in your second step. This will cause a resource database to be generated which is required for the asset sharing feature.

    Let me know if you have any more issues.
     

    Attached Files:

  8. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    Thanks for your prompt responses! This fixes the initial errors, but now when I choose any single mod and then select "Play Game" I am met with a new wall of console errors. (these occur for all mods)


    I tried rebuilding the mod tools package as you suggested, but this didn't resolve these errors.
     
  9. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    On a side note, I am unable to use the example scenes included with uMod either, they appear to be affected by the same issue. (the mod is not loadable by this game)
     
  10. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    uMod 2.0 - Moddable Tanks Example Game 1.0.1 has been submitted to the asset store. All mods have been rebuilt with game locking disabled so that any project/game can load them.
    Ok, It looks like the mods are now loading atleast.
    These new errors you are getting mean that the various moddable elements in the scene have not had their naming scheme generated which is used to map moddable content onto a specific object. If you go to 'Tools -> uMod 2.0 -> Settings', then switch to the 'Moddable' tab, then click the 'Edit' button next to 'Asset Naming Scheme', you should see the following entries:

    NamingScheme.png

    If those are missing then you may need to open the scene at 'Assets/uMod 2.0 - Moddable Tanks/Game/CompleteGame.unity' and hopefully this will update the naming scheme.

    It is strange that we did not have the same issue when we tested earlier, although now I think about it, I had to open that scene to add to the build settings so maybe that fixed it without me knowing.

    Yes, those mods are still game locked. We will address that in the next update for the main asset.
     
  11. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    Thanks! Opening the CompleteGame scene updated the naming scheme, and I no longer get those errors.

    Now the only problem I have is loading the 'Canyon Level' mod, I am getting the 'Failed to relink game asset with guid...' warnings you mentioned. However after rebuilding the mod tools package as per your suggestions, I still get the console warnings, and the level loads empty. Any other ideas?

    Not sure if it's related, but I also encounter this popup sometimes when rebuilding the mod tools.

    Where should I be building them to? I'm still confused as to whether I should enable "Export in Current Project" or not.
     
  12. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Glad the naming scheme issue is fixed.

    Can you check that the asset sharing options in the mod tools builder wizard are setup as shown here:

    AssetSharingSettings.png

    These should be setup automatically when importing the 'uMod 2.0 - Moddable Tanks' asset but maybe that is not the case for you.

    With those options selected, it should just be a case of exporting the mod tools package which will create the necessary resources for asset sharing. You should see a message like' Generating shared asset database' in the progress window.

    As for the export path: It can be anywhere you like. Just enter a valid file name or file path such as 'ModTools.unitypackage' and that will be fine. As long as the tools builder runs, the necessary settings assets in the game project will be updated.
     
    Last edited: Sep 24, 2020
  13. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    Everything was disabled under asset sharing options. Enabling them and rebuilding the mod tools seems to have fixed it, I can load the canyon level now!

    Thanks for the help!
     
  14. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    No problem, glad it is all working now.
    I’m not sure why those options did not import correctly but we will look into that.

    Let me know if there is anything else.
     
  15. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    uMod 2.0 - Moddable Tanks Example Game 1.0.1 has been submitted to the asset store. All mods have been rebuilt with game locking disabled so that any project/game can load them.
     
    vestigial and Graham-B like this.
  16. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    I am extremely confused by the "Hangars To Circus Tents" example. Where do we define what parts of an asset can be overridden?

    Building01 has it's material color modified. But the Moddable Content scripts don't seem to support this the way they are set up. Is the example configured properly? (the model is named material, material is named texture, texture is named animator? The asset type is also set to model )

    Strangely we are able to supply a material and it works in this example.

    I am just confused as to how and why this is working, and cliff is setup this way too. Why it doesn't work if I change the names to match Building02 example which has names that seem to make more sense.

    Thanks again for all the help!
     
    Last edited: Sep 24, 2020
  17. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Hi again,
    It looks like the configuration is all wrong which is likley why you are so confused. I suspect it is related to a recent update where we added support moddable meshes that may have caused the configuration to become out of sync. We will resubmit the whole project shortly with the correct configuration but if you are interested in fixing the problem yourself then here is what you need to do:

    1. Open the naming scheme window 'View / Edit Naming Scheme' and expand the 'Asset Type Naming Scheme' foldout. Ensure that each asset type has the correct name:

    Mesh Asset : 'mesh'
    Model Asset : 'model'
    Material Asset : 'material'
    Texture Asset : 'texture'
    AnimatorController Asset : 'animator'


    Some of those were incorrect when we investigated.

    2. Go to the folder 'Assets/uMod 2.0 - Moddable Tanks/Game/Modding/Sharedprefabs' and select the prefab named 'Building01'. Find the 'ModdableContent' component and ensure that 'AssetType' is set to 'Material'. Make sure that the 'Target Moddable Component' is also set to 'Building01 (Mesh Renderer)'.

    Find the 'Moddable Content Naming Scheme Override' component and remove it. Then go to 'Add Component -> Scripts -> UMod.Moddable -> Moddable Content Naming Scheme Override'. This will add the naming scheme component with a fresh configuration. Setup the names like so:

    Moddable Override Content Folder : 'Overrides'
    Moddable Override Content Name : 'Building01'


    Hit the 'Apply Naming Overrides' button to update the naming scheme.

    3. In the same folder, select the prefab named 'Building02'. Make sure the 'Asset Type' is set to 'Model' for this object and that the 'Target Moddable Component' is set to 'Building02 (Transform)'.

    Remove and re-add the 'Moddable Content Naming Scheme Override' component again and ensure that the component has the following names:

    Moddable Override Content Folder : 'Overrides'
    Moddable Override Content Name : 'Building02'


    Hit the 'Apply Naming Overrides' button to update the naming scheme.

    4. In the same folder, select the prefab named 'Cliff'. Make sure the 'Asset Type' is set to 'Material' and that 'Cliff (Mesh Renderer)' is assigned as the 'Target Moddable Component'.

    Remove and re-add the 'Moddable Content Naming Scheme Override' component again and ensure that the component has the following names:

    Moddable Override Content Folder : 'Overrides'
    Moddable Override Content Name : 'Cliff'


    Hit the 'Apply Naming Overrides' button to update the naming scheme.

    5. Run the game and all moddable content should be applied correctly. Hopefully the setup will make alot more sense now that the correct asset names and types are used.


    I suspect the reason it was working with an invalid configuration was that only the UI elements were out of sync. I believe that the saved configuration was valid but was being displayed incorrectly as the 'Asset Type' enum had a new value added. It likley shifted all the asset names by 1 index when displaying the UI leading to all the confusion.
     
  18. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    277
    Thanks for the clarification, makes more sense now.

    Can multiple Moddable Content components be added to a single prefab? Lets say I want to allow modding of the model, material and animator simultaneously.
     
  19. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    No problem and sorry you are facing all of these issues. An update is on the way.

    Yes, you can have multiple 'Moddable Content' components on the same game object. You just need to make sure that each component has a unique 'Asset type'. Note that you can only have one 'Moddable Content Naming Scheme Override' component though but it contains naming options for all supported asset types.
     
    Graham-B likes this.
  20. mifanfeed

    mifanfeed

    Joined:
    Feb 23, 2019
    Posts:
    15
    Hi! Can someone please help? I bought both UMOD2.0 and UMOD2.0 Roslyn C# extension. So I imported both of them, solved the error with Plugin Conflicts.
    And now, I tried to follow the example
    Code (CSharp):
    1. using UnityEngine;
    2. using RoslynCSharp;
    3. using UMod.Scripting;
    4. public class Example : MonoBehaviour
    5. {
    6. private ScriptDomain domain = null;
    7.  
    8. // The C# source code we will load
    9. private string source =
    10. "using UnityEngine;" +
    11. "class Test : MonoBehaviour" +
    12. "{" +
    13. " void SayHello()" +
    14. " {" +
    15. " Debug.Log(\"Hello World\");" +
    16. " }" +
    17. "}";
    18.  
    19. void Start()
    20. {
    21. // Create the domain - We are using C# code so we need the
    22. //compiler
    23. domain = ScriptDomain.CreateDomain("MyTestDomain", true);
    24.  
    25. // Compile and load the source code
    26. ScriptType type = domain. CompileAndLoadMainSource(source);
    27. }
    28. }
    29.  
    But Unity gives me and error saying that ScriptDomain.CreateDomain() method doesn't exist. So what to do now?
     
  21. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    Hi,
    Thanks for purchasing our assets.
    Using Roslyn C# with uMod 2.0 is a little different to the standalone Roslyn C# asset because ScriptDomains can only exist when a mod is loaded (Each mod has their own script domain which is created automatically and accessed via the 'ModHost.ScriptDomain' property).

    If you want to compile source code without a mod loaded then you will need to use the compiler directly. Here is a quick example:

    Code (CSharp):
    1. using UnityEngine;
    2. using UMod.Scripting;
    3. using RoslynCSharp.Compiler;
    4.  
    5. class Example : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.         // Create the compiler
    10.         RoslynCSharpCompiler compiler = UModCompilerFactory.CreateCompilerServiceFromSettings();
    11.  
    12.         // Compile the source code
    13.         CompilationResult result = compiler.CompileFromSource(...);
    14.  
    15.         if (result.Success == true)
    16.         {
    17.             // Load the assembly and now you can use the same API to find types and execute methods etc.
    18.             ScriptAssembly assembly = new ScriptAssembly(result.LoadCompiledAssembly());
    19.         }
    20.     }
    21. }
    You can find some more code examples in the folder 'Assets/UMod-AddOns/UMod-RoslynCSharp/Examples/ExampleScripts/'.

    I hope that helps you. Let me know if there is anything else.
     
  22. mifanfeed

    mifanfeed

    Joined:
    Feb 23, 2019
    Posts:
    15
    Thank you a lot! It works like charm!
     
    scottyboy805 likes this.
  23. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    uMod 2.7.3 has been submitted to the asset store. This version includes minor bug fixes:
    • Fixed a bug in the moddable content system where some scene objects and prefabs could be unregistered from the naming scheme causing moddable content to not be applied.
    • Fixed a bug in the moddable content system where the moddable target override path could become invalid in some cases.
     
  24. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    856
    uMod 2.7.4 has been submitted to the asset store. This version fixes a bug in the script interface system where calling one of the 'GetComponentProxy' methods on a gameobject would not work correctly. Passing a base type to these methods would return a script proxy of the same type, meaning that calling virtual or abstract methods could fail with a target exception.
     
    vestigial likes this.
unityunity