Unturned
评价数不足
Unity Setup and Master Bundle Guide (With multiplatform explanation)
由 BlazingFlame 制作
A comprehensive, up-to-date guide on setting up a Unity Project and defining and building master bundles, from installation to exporting.
   
奖励
收藏
已收藏
取消收藏
Unity Setup
Even if you have Unity installed, please read this section to make sure it was done correctly.

Unity Hub
Download Unity Hub for free from the official Unity website: Unity Hub[unity.com]. You may have to create a Unity ID, this is also free.

Once it's fully installed, locate the Installs tab and click Install Editor in the top right.

Unity Version
As of writing, the current unity version is 2021.3.45f2 LTS. Thanks to DiFFoZ's efforts on the Unturned Datamining project, you can check that at any time at this link: GitHub - Unturned-Datamining[raw.githubusercontent.com]

Download Unity
The easiest way to find the unity download is to browse to the unity archive downloads[unity.com] and clicking the Unity Hub launcher button on the right version.
If it asks to allow Unity Hub to open a link, click yes.

Important
The following prompt should appear in Unity Hub, you should uncheck Microsoft Visual Studio Community Edition 2019, and check Linux Build Support (Mono) and Mac Build Support (Mono).

Once you've done that, press Install and wait for it to download.

Creating a Project
Locate the Projects tab and click New Project in the top right.

Choose 3D (Core) as your template and ensure the correct version is selected at the top. Name your project and change it's location if desired.
Once you're done configuring your project, press Create Project.

Adding Sources
Import a package by going to Assets > Import Package > Custom Package....

Browse to your Unturned Installation Folder, then open Extras\Sources. By default this is located at C:\Program Files (x86)\Steam\steamapps\common\Unturned\Extras\Sources.
Project.unitypackage
First, select Project.unitypackage. This will import all the layers, tags, mod-hooks, shaders, and other settings for Unturned. If it warns you, ignore it by clicking Import, then click Import again on the Import Unity Package window.
I recommend re-importing Project.unitypackage every few months to keep your project updated.

ExampleAssets.unitypackage
Next, go back to Custom Package... and select ExampleAssets.unitypackage. This will import a selection of example assets from the base game. This is technically optional but highly recommended. Click Import on the Import Unity Package window. This could take a few minutes.

Your project is set up for modding.
Creating a Master Bundle
Set up Your Mod Folder
Create a folder in Unity for all your mod's files to go in. In my example, I am making a folder called TestBundleMod as a subfolder of Mods.

Asset Bundle Custom Data
This step is optional but makes stealing your mod a lot harder.
Open up your mod's folder, right-click, and create an Asset Bundle Custom Data file. Don't change the name.
If you haven't uploaded your mod yet then you won't know the ID, but before your next update complete this step.
Otherwise, type the Mod ID (which can be found in the mod page's URL) into the Owner Workshop File Id field. If this bundle will be in more than one mod, i.e. a test mod and a live mod, you can instead use the Owner Workshop File Ids field and put all allowed Mod IDs in the list. The game will not load bundles installed by mods not defined here.

Asset Label
Make sure the Inspector window is open somewhere, and that you can see the Asset Labels footer. If not, go to the menu bar and click Window > General > Inspector. Drag it where you want it.
Navigate to the parent of your mod folder (in my case Mods) and select your mod folder.
Open the dropdown in Asset Labels and select New...
Type a shorthand for your mod name, followed by ".masterbundle" and press enter. Your mod can have multiple bundles if desired, so keep this in mind while naming. This label must be unique to and within your mod. It should not contain spaces, underscores, capital letters, or special characters.
Some Unity versions have a bug where it can be difficult to type in the field, or it is just unresponsive. Try dragging the window around and retrying until it works.

Exported Mod/Map Folder
Create a folder outside Unity to export your assets into. This is also the root of where your .dat and .asset files will be. If you're doing this for a map, it must be in the Bundles folder (or a subfolder of it). Here you will create a folder named MasterBundle.dat. If you haven't already, enable file name extensions to allow you to create the file easier as shown below (on Windows).
Then just create a text file and rename it to MasterBundle.dat (do not leave the .txt when renaming).

MasterBundle.dat
Open the new file with a text editor of your choice and paste this into it, replacing testbundle.masterbundle with the name of your asset label, and Assets/Mods/TestBundleMod with the relative path to your Unity mod folder, up to the Assets folder. Right click your mod folder and click Copy Path to make this a bit easier.
Notice how, even on Windows systems, forward slashes are used.
Asset_Bundle_Name testbundle.masterbundle Asset_Prefix Assets/Mods/TestBundleMod Asset_Bundle_Version 5
Asset Bundle Version
  1. Unity 5.5
  2. Unity 2017.4 LTS
  3. Unity 2018.4 LTS
  4. Unity 2020 LTS
  5. Unity 2021 LTS
All other values are considered invalid and are clamped to the closest value.

Master Bundle Tool
If the master bundle tool is not open, open it via Window > Unturned > Master Bundle Tool. Drag it where you want, I usually put it in the bottom right under the inspector.

Expand the Asset Bundles section, and put a check mark on the asset label you just created. You can close the section back.
Expand the Master Bundles section and ensure Multi-platform is checked. Click the ... button on your new master bundle.
Navigate to the folder with your MasterBundle.dat file and hit Select Folder (on Windows).

Finally, you have set up your master bundle. For testing exports, you can uncheck Multi-platform, but before you upload your mod you should export with it checked.
Assets
Asset folders must be layed out with the same file structure as they are in Unity.

For example, using the asset bundle example above:
# Unity Assets/Mods/TestBundleMod (has asset label): AssetBundleCustomData.asset Items/Guns/NewEaglefire: Animations.asset Hammer.mp3 Item.prefab Reload.mp3 Shoot.mp3 # Mod Folder (Non-map) 21535312425: Items/Guns/NewEaglefire: English.dat NewEaglefire.asset (or NewEaglefire.dat or Asset.dat) MasterBundle.dat testbundle.masterbundle testbundle.masterbundle.hash testbundle.masterbundle.manifest testbundle.masterbundle testbundle_linux.masterbundle.hash testbundle_linux.masterbundle.manifest testbundle_linux.masterbundle testbundle_mac.masterbundle.hash testbundle_mac.masterbundle.manifest # Map Folder # Notice map content needs to be in Bundles 2246984729: Bundles: Items/Guns/NewEaglefire: English.dat NewEaglefire.asset (or NewEaglefire.dat or Asset.dat) MasterBundle.dat testbundle.masterbundle testbundle.masterbundle.hash testbundle.masterbundle.manifest testbundle.masterbundle testbundle_linux.masterbundle.hash testbundle_linux.masterbundle.manifest testbundle_linux.masterbundle testbundle_mac.masterbundle.hash testbundle_mac.masterbundle.manifest
Closing Notes
Unturned will likely completely use GUIDs in the future. Level Objects don't even need to have a numeric ID anymore.

Before uploading to the workshop, make sure each asset file (.asset or .dat) has a GUID.
Use a site such as GUID Generator[www.guidgenerator.com] to generate GUIDs. By default Unturned uses no hyphens for GUIDs, but it's not required.

This can either be in the form of:
# v1 GUID 4ff295fcaf3d479e902d8778e708253d Type Gun ...
or
# v2 Metadata { GUID 2459447d43b64d25b2f3ad262f4e1f70 Type SDG.Unturned.ItemGunAsset, Assembly-CSharp } ...

If you run the game and it loads an asset file without a GUID that isn't using the Metadata format, a random GUID will be appended to the front of the file. This can be very bad if a file is uploaded to the workshop without a GUID because each person will have a different GUID in their asset file.
2 条留言
Jdance 2023 年 5 月 29 日 上午 11:04 
'hyphens turned off' for the love of god, change this.
Michael 2023 年 5 月 15 日 下午 3:55 
true