Search Unity

[Released] uMod 2.0 - Modding support made easy!

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

  1. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    I'm running into a problem with updating referenced mods, and I'm wondering if its my workflow or a limitation. Basically I have a mod that adds Trees, and then another mod that adds Apples to the trees. The apple mod has a reference to the tree mod via Tools -> Umod -> Umod settings -> Mod References. The problem is, when I update the Tree mod (writing new code and building/exporting it) the changes don't show up in the apple project, which is expected, but when I force the apple mod to refresh its mod references via Tools -> umod -> Reference Engine -> Force Rebuild Cache, any Tree components in the scene become "missing script".

    I thought I had a workaround by saving the scene into JSON first, force rebuild cache, then go through the JSON text and replace the old umod-compiled-5564c370-d7bb-4287-8c9c-7257c186dccc reference in the types with the newly created assembly, but I realize that only works if there's one referenced mod.
     
    Last edited: Apr 23, 2019
  2. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    I assume that the tree script is one you created and is built into the tree mod? If that is the case then I think I may have an idea why this is occurring. When the cache is rebuilt (which also happens when some export settings are changed) it causes the referenced mods to be loaded and then any assemblies in the mods are written into the Unity project folder so that you can now access the types and namespaces from that mod. I suspect that each time the cache is rebuilt Unity is assigning the assembly a different GUID which then causes scripts to be missing.

    You can test this theory by:
    1. Rebuild the cache
    2. Go to the folder 'Assets/UModExporter/Resources/AssemblyCache/' and you should see an assembly like 'umod-compiled-xxx...'. Right click on this assembly and select 'Show In Explorer/Finder'. You should see a meta file with a very similar name. Open this file in a text editor of choice.
    3. Take note of the 'guid' value in the meta file
    4. Rebuild the cache again
    5. Repeat steps 2-3 to see if the guid has changed.
    I would appreciate if you could try this and let me know whether the value has changed. If this is the problem then I do not know how we will be able to fix it but we wont get into that for the moment.
     
  3. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    It is like you say, the guid changes after rebuilding the cache. But only if the referenced mod has had a substantive change before being rebuilt and exported. Ie simply re-exporting the tree mod, then rebuilding the cache in the apple project, didn't cause a problem.

    Replacing the old guid with the new one in the .unity scene file seems to work, but feels a little dangerous
     
    Last edited: Apr 23, 2019
  4. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Thanks for checking this. I have done some quick tests to see how we could get around this issue and it looks like we may be able to include the .meta files for assemblies into mods when building them and then write those to the assembly cache instead of allowing Unity to generate them. We are just finishing off a big update and after that is done we will look into adding this.
     
    BackgroundMover likes this.
  5. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.0 has been submitted to the asset store for review and should be available for download within a couple of days.

    This is a major update and contains breaking changes. Backwards compatibility with mods built on older version is not possible and import errors on upgrading are unavoidable.

    The uMod Exporter package which you will have previously used to build mods is now obsolete and is no longer used by this version. Instead you will use a new tool called the 'Mod Tools Package Builder' to create your own tailored mod tools package that you can then distribute to your modders. The uMod Exporter will remain on the asset store to support older versions but will no longer be updated or maintained.

    ModToolsBuilderPackageScreenshot.png

    Another major change is that we have now mover over to a single mod file instead of the mod folder approach previously used. This has a number of benefits but does mean that backwards compatibility for mods created with the uMod exporter has been dropped.

    This version also introduces remote launching of mods. This will be useful mainly for developers and essentially means that you can have a game Unity project and a mod Unity project open and setup build and run to work using TCP. You can then click a single build and run button in the mod Unity project to build the mod and the mod will be launched in the current scene of the game Unity project automatically.

    We have also included the source code for the UMod Exporter so you can create or modify the editor windows to better suit your game. The source code should allow you to see how most modding tasks are achieved including invoking the build engine and we encourage developers to create their own tools. The code is fully commended but does make use of our own Unity ImGUI plugin.

    There are a number of breaking changes to the code base so you may receive import errors if upgrading. You should backup your project as a precaution before importing. Some of the changes include:
    • Mod.Initialize is removed and no longer required.
    • ModPath has been removed in favour of 'System.Uri'
    • Introduced new API for mod tools to use 'UMod.BuildEngine.ModToolsUtil'
    • Custom build engine processors will need to use the new attribute 'UMod.BuildPipeline.UModBuildProcessorAttribute'
    • Changes to the structure of 'UModSettings'. Mostly implementing property replacements for the fields to avoid unwanted behaviour of various UI elements.
    • Many other types have been removed, replaced or moved to a different namespace. Take a look at the API scripting reference for details.
    There are many other changes and bug fixes in this update also but I have listed the biggest changes.
     
    BackgroundMover and Rotary-Heart like this.
  6. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
  7. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi again,
    I believe we have now fixed this problem by packaging the meta files for managed assemblies into the mod. The assembly reference engine then uses those meta files when rebuilding the cache instead of allowing Unity to generate them which means that the Guid stays the same and your script references should now work correctly. This fix will be included in uMod 2.4.1 but in the meantime feel free to contact us at info(at)trivialinteractive.co.uk if you want the patch files before then.This will however require that you upgrade to uMod 2.4 which as previously mentioned contains breaking changes.
     
    BackgroundMover likes this.
  8. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Some users have reported an import issue with version 2.4.0 where some of the scriptable object assets used by uMod have lost their scripts on import in later unity versions. We have reproduced this issue and it will be fixed asap as it may prevent the mod tools builder wizard from opening correctly in some cases. if anyone is facing this issue then you can contact us at info(at)trivialinteractive.co.uk and we can provide a temporary fix so that you can open the mod tools builder wizard.
     
  9. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.1 has been submitted to the asset store for review and should be available for download within a day or two. This version fixes the import issues mentioned in the above post. Additionally the assembly reference cache will now use the same asset guid when generating assembly assets so that script references will not be lost.
     
  10. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    The asset store team are on form. Version 2.4.1 is already live :)
     
    BackgroundMover likes this.
  11. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.2 has been submitted to the asset store for review. This version includes:
    • Fixed a bug where the generated mod tools package could be corrupted due to incorrect guids. This would then cause many other errors including random exceptions and being unable to open any tool windows.
    • Fixed a bug where Unity would report multiple identical assemblies in the project after building a mod tools package.
    • Fixed a bug where importing the mod tools package for the first time would cause a null reference exception
    • Fixed a TCP socket error when reloading assemblies
     
  12. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.3 has been submitted to the asset store for review. This version includes:
    • Fixed a bug in Unity 2019 where compiler references were not added correctly causing script compilation to fail
    • Fixed a bug where loading 2 mods that were created by the same project simultaneously would cause memory bundle errors
    • Fixed a warning about a missing meta file when switching between mod export profiles
    • Fixed a bug where creating a new mod via the mod tools menu will fail if the export settings have not yet been created
    • Fixed a bug in 2018.3 and newer where prefabs would generate errors about not being editable.
    • Fixed a bug where certain file paths would cause the build engine to handle asset cleanup incorrectly which could cause assets to be left in a bad state
    • Fixed a bug where uMod specific assets that are generated by the build engine were created in an incorrect location.
    Stay tuned for some more cool features in the upcoming weeks.
     
    Last edited: May 26, 2019
    Rotary-Heart likes this.
  13. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
    Hi, trying to build a test mod for my game but I'm getting this error:
    This is the only script/thing I have in the mod's folder.
    Code (CSharp):
    1. using UnityEngine;
    2. using UMod;
    3.  
    4. public class TestScript : ModScriptBehaviour
    5. {
    6.     // Start is called before the first frame update
    7.     void Start()
    8.     {
    9.        
    10.     }
    11.  
    12.     // Update is called once per frame
    13.     void Update()
    14.     {
    15.        
    16.     }
    17. }
    I tried compiling just a scene in the mod folder instead and that seems to work fine, so assuming it's a script-related thing.
     
  14. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    Thanks for reporting this problem however we are already aware of this and are working to fix it. It appears to be an issue in Unity 2019 only where some compiler references are not being added.
     
  15. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    This bug has now been fixed in uMod 2.4.3 which is currently being approved.
     
  16. RadioactiveXP

    RadioactiveXP

    Joined:
    Nov 6, 2013
    Posts:
    69
    After importing in to a Fresh project with Unity 2018.4.3, I am greeted with these 3 errors. How Do I resolve them, they look inter-related.
    ----
    Code (CSharp):
    1. Assembly 'Assets/UModRawPackages/Runtime C# Compiler/UMod-RuntimeCompiler.dll' will not be loaded due to errors:
    2. Unable to resolve reference 'mcs'. Is the assembly missing or incompatible with the current platform?
    3. Reference validation can be disabled in the Plugin Inspector.
    ----
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.DockArea.GetTruncatedTabContent (System.Int32 tabIndex) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:954)
    3. UnityEditor.DockArea.DrawTab (UnityEngine.Rect tabRegionRect, UnityEngine.GUIStyle tabStyle, System.Int32 tabIndex, System.Single xPos) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:982)
    4. UnityEditor.DockArea.DragTab (UnityEngine.Rect tabAreaRect, System.Single scrollOffset, UnityEngine.GUIStyle tabStyle) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:933)
    5. UnityEditor.DockArea.DrawTabs (UnityEngine.Rect tabAreaRect) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:372)
    6. UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:317)
    7. UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:266)
    8. UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:438)
    9. UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent () (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:412)
    10. UnityEngine.Experimental.UIElements.ImmediateStylePainter.DrawImmediate (System.Action callback) (at C:/buildslave/unity/build/Modules/UIElements/ImmediateStylePainter.cs:113)
    11. UnityEngine.Experimental.UIElements.IMGUIContainer.DoRepaint (UnityEngine.Experimental.UIElements.IStylePainter painter) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:98)
    12. UnityEngine.Experimental.UIElements.VisualElement.Repaint (UnityEngine.Experimental.UIElements.IStylePainter painter) (at C:/buildslave/unity/build/Modules/UIElements/VisualElement.cs:862)
    13. UnityEngine.Experimental.UIElements.VisualTreeRepaintUpdater.PaintSubTree (UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, System.Boolean shouldClip, System.Boolean shouldCache, UnityEngine.Rect currentGlobalClip) (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeRepaintUpdater.cs:310)
    14. UnityEngine.Experimental.UIElements.VisualTreeRepaintUpdater.PaintSubTreeChildren (UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, System.Boolean shouldClip, System.Boolean shouldCache, UnityEngine.Rect textureClip) (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeRepaintUpdater.cs:328)
    15. UnityEngine.Experimental.UIElements.VisualTreeRepaintUpdater.PaintSubTree (UnityEngine.Experimental.UIElements.VisualElement root, UnityEngine.Matrix4x4 offset, System.Boolean shouldClip, System.Boolean shouldCache, UnityEngine.Rect currentGlobalClip) (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeRepaintUpdater.cs:314)
    16. UnityEngine.Experimental.UIElements.VisualTreeRepaintUpdater.Update () (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeRepaintUpdater.cs:35)
    17. UnityEngine.Experimental.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:70)
    18. UnityEngine.Experimental.UIElements.Panel.Repaint (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:507)
    19. UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:230)
    20. UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:68)
    21. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
    ---
    Code (CSharp):
    1. Assembly 'Assets/UModRawPackages/Runtime C# Compiler/UMod-RuntimeCompiler.dll' will not be loaded due to errors:
    2. Unable to resolve reference 'mcs'. Is the assembly missing or incompatible with the current platform?
    3. Reference validation can be disabled in the Plugin Inspector.
     
  17. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    It looks like your project contains a uMod development only folder 'UModRawPackages' which should not be included. Which uMod version are you using? You can find out by going to 'Tools -> uMod 2.0 -> About'. I would suggest that you delete the folder at 'Assets/UModRawPackages' to see if that fixes the problem or delete all UMod folders and then re-import the latest version from the asset store.
     
  18. RadioactiveXP

    RadioactiveXP

    Joined:
    Nov 6, 2013
    Posts:
    69
    I am running the package I downloaded from the asset store last night. however, it says v2.2.2 in the about page.

    When I go to the asset store from inside unity, I just have the import button, not a download; so I am guessing I have what is in the store - right?

    These errors are just after an import, I've not started to use the package as of yet.
     
  19. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    It looks like you have a much older version of uMod as the store version is up to 2.4.3 with major changes. I have seen this sort of thing before where Unity will cache a downloaded asset locally and will then default to that version instead of using the latest version. I will see if I can find any more information about this.
     
  20. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    @RadioactiveXP I have found a similar thread relating to this issue although for a much older Unity version and it sounds like clearing the local cache may help. I am sure I have read about the same sort of issues on newer Unity versions but I can't seem to find any information on it.
     
  21. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.4 has been submitted to the asset store for review and should be available for download within the next day or two. This version includes new features and changes:
    • Added new code validation system with improved performance and memory usage
    • Added provisional support for .mdb and .pdb debug symbol usage by the code validation engine meaning that we may be able to provide source file, line and column information for code validation errors in the near future
    • Added support for code validation on members. You can now mark individual members of a type as allowable or illegal
    • Added support for whitelisting and blacklisting code validation entries. You can now choose to allow or deny assembly references, namespaces, types and members
    • Added default code validation rule for unlisted entries. If the entry is not specified in a whitelist or blacklist then the default rule will be applied
    CodeVerification.png

    We have also added a new experimental feature called 'Asset Sharing' which aims to make it easier for your modders to make use of your game assets when creating mod scenes.

    How it works
    Asset sharing allows you to select assets (Currently only prefabs are supported) when building your mod tools package that you want your modders to be able to use. uMod will then build these assets into an asset bundle to be distributed with the mod tools package. uMod will then allow modders to add these assets to the scene using the 'Mod Assets' window where they can be moved and rotated. (Scaling is not yet supported)

    When the user wants to build the mod the uMod build engine will examine the scene for any traces of shared assets where each occurrence will be replaced by a shared asset guid before continuing to build the mod. When the mod is then loaded at runtime uMod will relink these shared assets using the shared asset guid and everything looks as it did when created.

    An important thing to note is that once you make one of your game assets available to modders via asset sharing then you will need to ensure that it remains in the game project. Deleting the asset after sharing it will mean that mod scenes with references to the asset will have link errors upon loading.

    Why use asset sharing?
    • Its an ideal solution if you want your modders to build new levels without actually providing the raw assets for the game.
    • Modders will never have full access to the raw assets, only a scene representation of the game object so it can be considered much safer in terms of copyrighting if you never provide the raw asset files
    • Each shared asset used in a mod only requires a guid to be serialized. This means that the file size and load time of mods are hardly affected no matter how many shared assets you use.
    The asset sharing window which is part of the mod tools package builder wizard:
    AssetSharingWindow.png

    The mod assets window that modders will be presented with:
    GameAssetsWindow.png

    Note that asset sharing is currently an experimental feature and may not be fully stable. Please report any issues you encounter.
     
    BackgroundMover and Rotary-Heart like this.
  22. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    Really good to see the asset sharing! I will be playing around with this soon.
     
    scottyboy805 likes this.
  23. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Glad you like it :). Let me know how you get on.
     
  24. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.5 has been submitted to the asset store and will be available for download within a day or two. This version includes minor bug fixes:
    • Fixed a bug where Game Locking would use an incorrect project id in some cases causing game lock checking to fail even with correct credentials.
    • Fixed a bug where including assembly content via the mod tools builder wizard would cause a FileLoadException for assemblies located inside the 'Assets' folder.
    • Fixed a bug where assemblies in certain sub folders would not be detected by the mod tools builder window meaning that you could not add these assemblies to the mod tools package.
     
    BackgroundMover likes this.
  25. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.6 has been submitted to the asset store and will be available for download soon. This version includes:
    • Fixed a bug where building a mod tools package would not use the correct settings if they were changed without closing the window.
    • Fixed a bug where specifying an empty export path for the mod tools output path would throw an exception.
    • Added 'Mod Include' section to the content part of the mod tools builder wizard. You can now add C# scripts in this section of the wizard which will be included in the mod tools package and automatically referenced by all mods. This makes it easier to include additional runtime functionality that can be shared across all mods without needing to pre-compile the scripts into a managed assembly.
     
    BackgroundMover likes this.
  26. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod 2.4.7 has been submitted to the asset store for review. This version contains a minor bug fix on linux platforms where the mod assets folder specified in the export settings would be modified after a mod build has comleted causing the path to become invalid.
     
  27. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    Is there an alternative way to add scripts to a Mod Tools package? My Mod Tools Builder -> Content -> Mod Include Content is super laggy, taking 3-4 seconds to select each item, and I've got dozens of items to include, and the list seems to reset when I build mod tools in a different project. I'm wondering if listing all the items in Packages is whats making it lag (which, I get an exception when trying to build a mod tools package that contains scripts from a Package). In the meantime I'm wondering if theres a textfile or .asset I can paste lines into manually
     
  28. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    The only other way to get around this would be to invoke the mod tools builder manually using an editor script. The full build API is exposed although not documented but it is not complicated to use. Here is a quick example script:

    Code (CSharp):
    1. using UnityEditor;
    2. using UMod.ModTools;
    3. using UMod.BuildTools;
    4. using UMod.Shared;
    5.  
    6. public class ManualToolsBuilder
    7. {
    8.     [MenuItem("UMod/Manual Build Mod Tools")]
    9.     public static void ManualBuildModTools()
    10.     {
    11.         string outputPath = "ModTools.unitypackage";
    12.  
    13.         // Any additional scripts you want to include in the package
    14.         string[] scriptPaths = {/*...*/};
    15.  
    16.         // Create the build servce to create the mod tools package
    17.         BuildToolsService buildService = new BuildToolsService();
    18.  
    19.         // Load the tool settings - This contains all other export information such as company info, build engine options and much more
    20.         ModToolsSettings toolSettings = ModToolsSettings.Active.Load();
    21.  
    22.         // Add extra content - The mod content page of the wizard generates this data so specifying content via script will eliminate the lag
    23.         BuildToolsContent additionalContent = new BuildToolsContent();
    24.         foreach(string scriptPath in scriptPaths)
    25.         {
    26.             if (FileSystemUtil.IsDirectoryNameInPath(new System.IO.FileInfo(scriptPath), "Editor") == true)
    27.                 additionalContent.AddAdditionalScript(BuildToolsContent.IncludeExecutableType.Editor, scriptPath);
    28.             else
    29.                 additionalContent.AddAdditionalScript(BuildToolsContent.IncludeExecutableType.Runtime, scriptPath);
    30.         }
    31.         //additionalContent.AddAdditonalContent(...);
    32.         //additionalContent.AddAdditionalAssembly(BuildToolsContent.IncludeExecutableType.Runtime, ...);
    33.  
    34.         // Use this to specify assets which will be shared using asset bundles - This is the equivilent of the 'Asset Sharing' page
    35.         BuildToolsSharedContent sharedContent = new BuildToolsSharedContent();
    36.         //sharedContent.AddAdditionalSharedContent(...);
    37.  
    38.         // Include the project settings assets so that tags and layers and other thigs are setup correctly in the modders project
    39.         BuildToolsProjectSettings projectSettings = new BuildToolsProjectSettings();
    40.         projectSettings.GatherProjectSettings();
    41.  
    42.         // Build the package
    43.         buildService.BuildModTools(outputPath, toolSettings, additionalContent, sharedContent, projectSettings);
    44.     }
    45. }
    Note that the 'ModToolsSettings' are loaded from the project. This means that you can still use the mod tools wizard to edit most settings, skipping the mod include content to avoid lag. The project settings page in the wizard will also have no effect as this example code automatically includes all project settings and the 'Asset Sharing' page will also have no effect as this code will always specify no shared assets but all other pages should work fine.

    In the meantime we will look into the performance of the content page and see if we can find out what makes it laggy. Also as you noticed the mod include content is saved on a per project basis using editor prefs but we can change this so that the settings are consistent between different projects if preffered.
     
    Last edited: Aug 14, 2019
  29. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    Thank you for the rich example! It was very easy to understand. But I've been struggling a couple days to try and get it to work. Using the code above, I can make a basic mod tools package containing an NPC.cs, with a second project that imports the tools.unityPackage. If I make a new script in the second/mod project (say, Merchant.cs) that references the script brought in by the tools package:
    Code (CSharp):
    1. public class Merchant :NPC{}
    or
    Code (CSharp):
    1. public class ModClass{
    2. public NPC MyNPC;
    3. }
    building the mod fails at around 18%. However, when building the tools package using the wizard, and using that package to create the mod, it can be built successfully. Interestingly it throws up an "API update needed" window at the same progress % as where the manually-built package fails.
     
  30. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    HI,
    Do you get any errors in the console about NPC being a missing type?
    It sounds like you may be using the 'AddAdditionalScript' method to include this script into the mod tools package but if this is the case then it will not work because that method is only intended to include scripts which add extra editor functionality or tools such as custom editors etc. Instead you should use another method called 'AddIncludeScript' which will cause the specified script to be built into the mod tools package and compiled into each mod when exporting.

    As for the API Update Error: I do not know why that would appear mid build. The only thing I could suggest is to go to 'Assets -> Run API Updater' (If it is not greyed out) prior to building the mod to see if that eliminates the warning.

    Hopefully that should fix the problem but let me know if you are still having trouble.
     
  31. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.8 has been submitted to the asset store. This version fixes a bug in Unity 2019 versions where accessing certain core types such as HashSet would cause a compiler error when building a mod.
     
    BackgroundMover likes this.
  32. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    We have resubmitted uMod 2.4.8 to the asset store due to a submission error that caused the mod tools builder wizard to be unusable. When attempting to open the mod tools builder window a read only exception would be thrown due to an invalid configuration for one of the included data assets.This update corrects that problem and should be available within a day or two. in the meantime if you are in urgent need of the update then you can email your invoice number to us at info(at)trivialinteractive.co.uk and we can send the fix direct.
     
    BackgroundMover likes this.
  33. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.9 has been submitted to the asset store. This version fixes a performance issue in the mod tools builder wizard where the content page could become unusable on larger projects. The performance may not be 100% smooth in this version but it will be a whole lot better than it was and should certianly be usable now in projects of all sizes. We will also be working to improve the performance of this window further to make it as smooth as you would expect.
     
    BackgroundMover likes this.
  34. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    Hi,
    I just bought this asset and am trying to figure it out.
    I created 2 projects (2019.2.0f1, API Level: .NET 4.x, Backend: Mono).
    1)
    Game:
    Imported asset. Assembled the package (Mode Tool Builder) with standard settings. The only thing I changed was adding my .dll to Include Assemblies.
    ModProject:
    Imported the package. Created mod. Created a scene with a cube. Added a Spinner script to the cube. Saved the scene and moved the scene and script to a folder with the name of the mod. Build mod.
    Game:
    I downloaded the mod through the demo scene. The cube appeared successfully, but the script was not imported (Missing).
    upload_2019-10-13_11-41-32.png upload_2019-10-13_11-40-4.png upload_2019-10-13_11-40-19.png
    There were no errors during export / import.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. namespace UMod
    5. {
    6.     public class Spinner : ModScriptBehaviour
    7.     {
    8.         void Update()
    9.         {
    10.             transform.Rotate(0, 180 * Time.deltaTime, 0);
    11.         }
    12.     }
    13. }
    If I do not add my dll, the result is the same.

    2) If I create a prefab, I get an error when exporting: Disconnecting is no longer implemented
    3) I could not load the demo mods, because they were made on the old version of Unity. Moreover, the only video on the Asset Store page is not available, and the documentation does not answer many questions.
    4) Asset Bundles Unity allow AB download of old versions to new Unity versions. As I understand it, UMod creates a restriction within only one version. Does this mean that I can never update the version of Unity without losing the mods created by the community (I saw several settings with the word Version, but haven’t checked everything yet)?

    Thanks.
     
  35. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    I just randomly passing by, noticed video on first OP post is dead.
     
  36. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    HI,
    Thanks for purchasing our asset.
    1. I assume that the spinner script is compiled into the assembly that you created and added to the mod tools package? If that is the case then do you also have the assembly included in your main project where you will load the mods? Adding the assembly to the mod tools will only allow a reference to that assembly and will not include it on a per mod basis.
    2. We have not seen that error before but we will look into it and fix it in an update.
    3. You will need to rebuild those mods using your mod tools package (The raw assets for those mods are included under 'UMod/Examples/ExampleModsRaw/') or downgrade to Unity 2017.1.0 to load them as that is the version they were created with. We will fix the video link and feel free to suggest any parts of the documentation where you would like to see more information or indeed suggest additional topics that are not already covered.
    4. This is true but from our experience there is often material and shared issues when loading older asset bundles in newer Unity versions and we were getting quite a few rports about this behaviour even though it was out of our hands. For this reason we decided to lock the Unity versions for the game and the mod tools project to avoid these types of issues. If you update the Unity version for your game then you will no longer be able to load the olders mods. If this is something you would really like then we could possibly add an option with a disclaimer in the settings to disable Unity version locking. Let me know your thoughts on this.
     
  37. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    1. The Spinner.cs script was created in ModProject (Create => C # Script). I did not include it in assemblies. It is not part of .dll
    upload_2019-10-13_13-16-46.png
    I understand correctly that the mod allows users to create their own scripts, which are not originally in the game project?

    I conducted tests with an example of SpinningCubeMod.
    I imported the same asset in GameProject, which is also in ModProject (Mod Tools Builder). Created a mod, moved the SpinningCubeMod folder to the mod folder. Build mod. The mod loaded successfully, the cube rotates. File size: 373 KB
    I moved this folder to ModProject. Build mod. The mod loaded successfully, the script is present on the cube, but the cube does not rotate, there is no log when loading (This is a message from spinning cube mod). File size: 365 KB It is also strange that the size of the mods is different. The assembly of Mod Tools is the same in both projects. Also, I added the Update function. It is also not called when loading a mod from another project.

    3. At the moment, there are really not enough current video demonstrations.

    4. In fact, it is very sad. I want to add a modding tool to an already released game. Now the community is already adding Asset Bundles to it through my plugin, and recently I updated version 2018.1 => 2019, which greatly increased the development speed. At the same time, users do not experience problems loading old ABs. It will be a pity to refuse the functionality of new versions. How severe is this problem?

    UPD:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UMod;
    5.  
    6. public class SpinningCube : ModScriptBehaviour
    7. {
    8.     // Public
    9.     public float rotateSpeed = 2f;
    10.  
    11.     // Methods
    12.     public override void OnModLoaded()
    13.     {
    14.         ModDebug.LogMessage("This is a message from spinning cube mod");
    15.     }
    16.     private void Update()
    17.     {
    18.         transform.Rotate(Vector3.up, rotateSpeed * Time.deltaTime);
    19.     }
    20.     public override void OnModUpdate()
    21.     {
    22.         transform.Rotate(Vector3.up, rotateSpeed * Time.deltaTime);
    23.     }
    24. }
    25.  
     
  38. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    In that case it sounds like a bug specific to 2019 versions possibly related to the second issue you raised and we will look into it as soon as possible. Yes you should be able to include scripts into your mods and they should load without issue. It sounds like the script is not being processed by our linking engine for some reason which possibly due to Unity API changes. If possible could you send us the exporter log for the mod project which on a windows machine can be found at 'C:\Users\<username>\AppData\LocalLow\<unitycompanyname>\<unityprojectname>\uMod Exporter 2.0\Build.log

    We will work on better documentation over the next few weeks although it looks like our youtube account has been deleted without warning so there may be some delays.

    We will add in the option to disable Unity version locking so that you have the choice to support older Unity versions aswell. From our experience everything loads just fine but materials and shaders can be missing or unlinked or simply not work correctly on different Unity versions. We would often get objects rendered in that default magenta color even though everything appeared to be setup correctly.
     
    Elfinnik159 likes this.
  39. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    Well, I tried to record a video and created two new projects for clarity. And ... It worked. It’s strange. The only difference is that the ModProject in which I tested earlier was initially on version 2018.2, but before the test I changed the version to 2019.2 (opened in the new version of the editor) for compatibility.


    Scripts from dll are also successfully imported (checked by AddComponent).
    However, my main project was also originally on version 2018.2, and now it has version 2019.2, although I recently did Reimport All.
    Thanks for the help, I will try to create a mod for the main project, and I will write about the results.

    Wish: During the tests, when I tried to include the dll in the assembly, the checkmark was unchecked as soon as I moved to the next menu. It seems that by putting the dll in the uMod folder the problem disappears. It would be nice to have a warning, since I did not immediately notice that the problem is a disappearing checkmark.
     
  40. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi again,
    So everything appears to be working correctly now? We just tested this using 2019.2 with the spinning cube mod and did not get any errors or warnings and the mod loaded correctly and worked as expected. Let me know if the problem returns although we would likley need a repro project.

    When you tick the checkbox and move to the next page are you saying that the checkbox becomes unchecked? If you tick the checkbox and then close the window, is the tick box checked upon re-opening as it should remember your selections.
     
  41. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    Yes, at the moment everything works on test projects, thanks.

    It really is not the location of the dll file.
    1. Import the plugin.
    2. Import the dll.
    3. When assembling tools, check the box next to the dll.
    4. Go to any other section except Export
    5. Go back.
    Bottom line: the state of the switch is not remembered.
    If, after the change, go to the Export tab, the state is saved successfully. This ... can be a little confusing.
     
  42. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    OK thanks for clarfying. We will get that sorted.
     
  43. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.4.9b has been submitted to the asset store. This small update fixes a bug in the mod tools package exporter where adding assets via the content section could cause dependencies located inside the library folder to be referenced. This would then cause the export to fail silently. The exporter will now generate a warning about library content if referenced and skip over it. There is also better error handling so that you will always get an error message if the export fails. We also fixed a bug on the asset sharing page where the selected assets would sometimes be cleared.
     
  44. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    Super happy to report that Umod works with at least the basics of the new ECS system! As in, a mod can define an IComponentData, and a ComponentSystem, as well as a scene with gameobjects (and ConvertToEntity scripts), and, after one weird trick, the UMod runtime can load the mod file and things just work. I'm only a few hours into it but so far its really promising.

    There is one thing you have to do though, which is ensure you call Mod.Load() "[before] TypeManager.Initialize calls a method InitializeAllComponentTypes". A hugely helpful post is here:
    https://forum.unity.com/threads/all-componenttype-must-be-known-at-compile-time.766322/#post-5104754

    Right now I'm using the
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    attribute to trigger a function to run early in the process, before InitializeAllComponentTypes. There also might be a way to delay the automatic World creation using
    #UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP_RUNTIME_WORLD

    https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/world.html
    if mod loading needs to occur later.
     
  45. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    I appreciate you taking the time and reporting your findings on this. We will be sure to add this information to the uMod documentation so future users can benefit from it. Also if there are any features that dont appear to work correctly with uMod then let us know and we can look for possible solutions as I am sure many users would like to be able to use ECS.
     
    Rotary-Heart likes this.
  46. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.5.0 has been submitted to the asset store for review. This version includes:
    • Added 'UModBuildToolsAssetProvider' attribute which can be used in conjunction with 'BuildToolsAssetProvider' to specified additional mod tools content via an editor script.
    • Redesigned the way that selected items on the mod tools content page are serialized for better reliability. In some cases the selected items would not be remembered making the whole process tedious.
    • Redesigned and optimized the GUI rendering for the mod tools content page to ensure that there is no lag at all when displaying a large number of assets.
    • Added a new option in the settings menu 'Allow Older Unity Versions'. When enabled, this option will allow mods created with older Unity versions to be loaded. This is disabled by default and is not recommended for the average user as it can cause issues relating to materials and shaders in some cases.
     
    Last edited: Oct 31, 2019
    BackgroundMover likes this.
  47. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    uMod version 2.5.1 has been submitted to the asset store and should be available for download within a few days. This version fixes a code security verification issue where static references to types would not be detected meaning that static methods and members could be accessed even if they are declared in an illegal type.
     
    BackgroundMover likes this.
  48. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    I'm trying to make a test mod that runs a script. This:

    using UMod;
    using UnityEngine;

    public class OnStartMod : ModScriptBehaviour
    {
    public override void OnModLoaded()
    {
    ModDebug.LogMessage("OnModLoaded");
    }
    }


    This file is in the mod folder.
    I then build the mod.
    I then move this mod into the correct place to be loaded.

    When I run my scene and load the mod, the mod is loaded but OnModLoaded is not logged.

    According to the docs By default, any code that is included within the mod is automatically activated allowing the mod code to run as soon as a mod is loaded.

    upload_2020-1-9_14-21-3.png

    What am I doing wrong?

    Thanks
     
  49. scottyboy805

    scottyboy805

    Joined:
    Apr 10, 2013
    Posts:
    1,193
    Hi,
    The script is all setup fine but since you are inheriting from 'ModScriptBehaviour' then the script should be attached to a game object in order for the mod events to fire. The 'OnModLoaded' event of the 'ModScriptBehaviour' class will run delayed in this scenario (just after Start is called) and not actually when the mod has been loaded because the scene must be loaded or a prefab instantiated in order for the script to exist.
    If you don't want to attach the script to a game object then you should inherit from 'ModScript' or implement the 'IMod' interface and the event will fire immediatley after the mod has loaded.

    I hope this helps you. Let me know if you have any more questions.
     
  50. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    Hi, thanks for the quick reply.

    Okay, I have inherited from ModScript and I see the message being displayed. Great.

    I now have another problem. I have made an interface assembly, which contains the interface IAction.

    I have made a class that implements this interface. Like so:

    Code (CSharp):
    1. public class TestAction : IAction
    2. {
    3.     public void Execute(object relevantState)
    4.     {
    5.         Debug.Log("TestAction");
    6.     }
    7. }
    And made another mod.

    However this new mod fails to load. An exception is thrown. Like so:

    ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
    System.Reflection.Assembly.GetTypes () (at <567df3e0919241ba98db88bec4c6696f>:0)
    UMod.Scripting.ScriptAssembly.FindAllSubtypesOf (System.Type baseType) (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.Scripting.ScriptAssembly.FindAllSubtypesOf[T] () (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.Scripting.Runtime.ScriptExecutionContext.ActivateAssembly (UMod.Scripting.ScriptAssembly assembly) (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.Scripting.ScriptDomain.TryLoadAndActivateAssemblyWithSymbols (System.Byte[] bytes, System.Byte[] mdbSymbols, UMod.Scripting.ScriptAssembly& assembly, System.Byte[] securityHash) (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.ModHost.InitializeScripting () (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.ModHost.Activate () (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.ModHost.Load (System.Uri path, System.Boolean activate) (at <95570ac08924468f85115b320d8d891e>:0)
    UMod.Mod.Load (System.Uri path, System.Boolean autoActivate) (at <95570ac08924468f85115b320d8d891e>:0)
    Skippy.LoadMod.Start () (at Assets/Vampire/Code/Modding/LoadMod.cs:27)