TUTORIAL – Gaia modding using Unity

Home Forums Mods TUTORIAL – Gaia modding using Unity

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #1759

    So… I heard you’d like to make a Gaia mod. This thread has 3 posts: The first is to show you how to set up your modding environment in Unity, the second is a basic tutorial on how to add a basic item in Gaia and the third is an advanced tutorial showing you how to add a turret building in Gaia. The advanced tutorial also teaches you about every single other type of building.

    Programs you need to mod Gaia

    1. Unity 3D and a free Unity account

    2. A text editor that should come with the Unity installation, such as Visual Studio or MonoDevelop. Using anything else, such as notepad, might not work!

    3. An asset called uModExporter to actually turn your mod into something recognizable by Gaia.

    First, setting up your environment

    1. Download Unity 2018.1.6 from https://unity3d.com/get-unity/download/archive. It is important you use that version of Unity, otherwise your mods will not work.

    2. Install The Unity free version.

    3. Once it’s done installing, open Unity and create a new project while making sure it’s set to 3D. You can call it whatever you want.

    5. Go to Edit->Project Settings->Player. Then in the inspector on the right side, choose ‘.NET 2.0’ under ‘Api Compatibility Level’

    4. Now Download the uModExporter. This is where you’ll need your Unity account. Go to the Window->Asset Store then search for ‘uMod Exporter’, download and import from inside the Unity Editor. Here is the link which you can view in a browser to make sure you’re downloading the right stuff.


    5. Navigate to Gaia’s installation folder (for me, it’s here C:\Program Files\Steam\steamapps\common\Gaia), then go in the folder called ‘gaia_Data’ and then into the folder ‘Managed’

    6. From here, you need to copy some files into the right location and you’re done.

    6.1 Copy and paste the file ‘Assembly-CSharp.dll’ into the ‘Assets’ folder. You can’t paste a folder directly in Unity but you can drag and drop OR right click on your ‘Assets’ folder and click on ‘Show in explorer’. You can now paste the .dll in here. Go back to your project and wait for the editor to import the dll, which might take a few minutes.

    You will probably get an error saying ‘Unloading broken assemblies’. That’s okay, it will go away soon.

    7. Download all the stuff we need for the basic mod and for setting up your environment at


    7.1. Now we have to categorize everything we just downloaded. Extract the zip and you’ll find 2 folders: ‘Potato’ is the folder with our 3D potato model and WorkshopUploader, which allows to upload our mod to the Steam Workshop if we want to.

    7.2. Move the ‘Potato’ folder into the ‘Assets’ folder of your project.

    7.3. Open the ‘WorkshopUploader’ folder and move the ‘Uploader’ folder into the ‘Assets’ folder of your project.

    7.4. Move everything else in the ‘WorkshopUploader'(WorkshopContent, steam_appid.txt and config.json) into the folder containing your ‘Assets’ folder, which should be called whatever name you gave to your project. You can find this folder by right clicking on the ‘Assets’ folder in your project view and click ‘Show in explorer’

    8. One last thing. Go to Tools->umod Exporter->Exporter Settings->Build tab and check ‘Compile Mod Scripts Only’. This is required, otherwise there’s a very good chance
    you’ll run into issues later on, such as running 2 mods in one mod by accident.

    9. You’re done! You can now begin coding and you have access to all of Gaia’s base code. Now that your project is set up, you can create multiple mods from this
    one single project if you’d like.


    Creating your own modded item

    1. Create your own mod. You can do so by going in the Tools menu top left->uModExporter->Create->New Mod and give your mod a name! For this tutorial,
    we’re going to be creating a magic potato, so I’m going to name my mod ‘Magic Potato Mod’. Leave the rest on default.

    2. You now have a new folder in your assets folder, called ‘Magic Potato Mod’. This is where everything related to your mod should go, including images or scripts.
    Move the ‘Potato’ folder into this newly created folder.

    3. Optional: To view your potato, navigate to the ‘Prefab’ subfolder of the ‘Potato’ folder and drag the prefab into the scene to look at it. Looks cute eh? If
    you select it, you can change its color on the right side as well as other properties.

    4. Now, to the fun coding part. Create a new C# script in the Magic Potato Folder called ‘Main’ (Can be called whatever you want) by right clicking on the folder then ->Create->C# Script. Open the script.

    5. Delete both the Start() and Update() methods from the script. At the top, write ‘using UMod;’ and make the class inherit from ModScript instead of MonoBehavior.
    We’ll also put our mod into its own namespace to reduce the likelyhood of colliding with other mods. We’ll call out namespace PotatoMod. This is quite important!

    6. Write the following piece of code inside your Main class:

    public void OnModEnableMainMenu() {
    public void OnModPreLoadGame() {
    public void OnModPostLoad1() {
    public void OnModPostLoad2() {
    public void OnModPostLoad3() {

    Each of those methods are called at different times in the base code. The OnModPreLoadGame() method is called when
    the player starts a new game, but before any other Gaia initialization is done. This is where we need to add items and buildings to the Gaia database. Any other place WILL NOT work.

    7. Time to add the magic potato! Create a new method, which we shall call ‘createThePotato’ and call it from the OnModPreLoadGame method.

    public void createThePotato() {

    8. To create an item in Gaia, use the following template code. We will add this code and put it inside the createThePotato method.

                ModItem mi = new ModItem();
                mi.assemblerCategory = 0; // we don't want to craft a potato anywhere
                mi.canBeCrafted = true;
                mi.canBeStacked = true;
                mi.canBeConsumed = true;
                mi.craftedAmount = 2; // if we did want to craft it
                mi.icon = ModAssets.Load<Texture2D>("Assets/Magic Potato Mod/Potato/potatoIcon.psd");
                mi.prefab = ModAssets.Load<GameObject>("Assets/Magic Potato Mod/Potato/Prefabs/Potato.prefab");
                mi.canBeDropped = true;
                mi.stackLimit = 5;
                mi.startResearched = 1;
                mi.subIndexes = "none";
                mi.subItemOf = -1;
                mi.tradeCategory = Global.TradeCategory.Raw;
                mi.tradeChance = 50;
                mi.tradePrice = 1000;
                mi.tradeQuantityMax = 100;
                mi.tradeQuantityMin = 50;
                mi.wealth = 500;
                Global.ModLanguageData english = new Global.ModLanguageData();
                english.descriptionTranslation = "This magic potato tastes like rainbow. Wow!";
                english.language = "English";
                english.nameTranslation = "Magic potato";
                Global.ModLanguageData french = new Global.ModLanguageData();
                french.descriptionTranslation = "Cette pomme de terre magique a le goût de l'arc-en-ciel. Wow!"; // french potato
                french.language = "French";
                french.nameTranslation = "Patate magique";
                Global.ModLanguageData[] mld = new Global.ModLanguageData[2];
                mld[0] = english;
                mld[1] = french;
                mi.data = mld;
                Global.ModCustomValue hunger = new Global.ModCustomValue();
                hunger.id = 5;
                hunger.value = "5";
                Global.ModCustomValue thirst = new Global.ModCustomValue(); // yes our potato can quelch our thirst, so what?!
                thirst.id = 6;
                thirst.value = "5";
                Global.ModCustomValue[] mcv = new Global.ModCustomValue[2];
                mcv[0] = hunger;
                mcv[1] = thirst;
                mi.customValues = mcv;
                // if we wanted to be able to craft this material at an assembler, we'd set the required materials like so. We won't do it in this example though.
                Global.ModRequiredMaterial rand1 = new Global.ModRequiredMaterial ();
                rand1.requiredItemAmount = 2;
                rand1.requiredItemIndex = 3; // bloodstone
                Global.ModRequiredMaterial[] mrm = new Global.ModRequiredMaterial[1];
                mrm [0] = rand1;
                mi.requiredItems = mrm;
                // finally, add this new item to the Gaia database and we're done! As said before, items and buildings can only be added
                // to the Gaia database on preload and using the MapSpawner instance reference.
                // No other reference in the game exists at this stage. Use the OnModPostLoadX methods to mod other aspects of the game.
                int uniqueItemID = MapSpawner.thisInstance.player.gameHandler.addModdedItem(mi);
                // This new returned integer isn't useful to use for this tutorial. But if you'd like to have a reference to it, you would be
                // able to access it from the inventory by using its ID

    Here’s a link to the final script:

    9. We’re done! Make sure you save your edits. We now have a magic potato just ready to be eaten in Gaia. Now we need to export our mod. First off, go to Tools->uModExporter->Export settings and set your name as the author of this mod and the mod description. This description will appear in the game’s description when a player selects your mod, but it’s not required.

    10. Close the window from step 9. It is finally time to click the button. Go to Tools->uModExporter->Build Mod and your mod will now begin building. The mod is now
    in the same folder as the ‘Assets’ folder.

    11. Now we want to see our magic potato in game to make sure it works before we upload it to Steam’s workshop. Move the newly created mod folder ‘Magic Potato Mod’ to
    C:\Users\USERNAME\AppData\LocalLow\Gaia\Gaia\Mods. If the Mods folder is not there, create it yourself. If you can’t see the AppData folder, please google how to show hidden folders on Windows.

    12. Play the game and check the Cheat Sheet in Test Mode for the magic potato and it should be there. Congratulations!

    Uploading your mod to Steam workshop

    Before you get started, make sure you’ve agreed to Valve’s agreement on the workshop in steam, otherwise your mods won’t be visible to anyone and may also prevent you from uploading them.

    1. Make sure you’re logged into your Steam client with the account you wish to upload.

    2. Make sure that the steam_appid.txt file contains Gaia’s steam ID, which is 906790. This file should be right next to the ‘WorkshopContent’ folder

    3. Move or copy your mod into the ‘WorkshopContent’ folder
    4. If you haven’t done so already, create a picture for your mod, which will appear in the Steam workshop. Without a picture, your mod won’t upload. The picture
    should be a .png extension but other popular extensions should work as well. The pic HAS to be less than 1mb in size. The picture also HAS inside the ‘WorkshopContent’,
    beside your mod folder.

    5. Open your mod project in Unity, go to the ‘Uploader’ folder and open the ‘ModTool’ scene

    6. Press the ‘Play’ button at the top of your window. You should now see a list of all mod packs on the left side of the screen. If this is your first time uploading a mod this way, it will most likely be empty.

    7. In the ‘Enter item name’ field, make sure you enter the name of your mod, which should be the same as the mod folder, then press ‘Create Item’. I will be entering ‘Magic Potato Mod’

    8. Fill out the item fields as you see fit. Make sure to include the extension name of your image. You can leave the Tags field empty. The ‘Visibility’ dropdown specifies if anyone can see and download your mod or not. Once you’re satisfied, press on the ‘Submit’ button and your mod should begin uploading!

    9. Voila! Note: After uploading your mod, you should delete it from the /Mods folder if you intend to download it from Steam. Otherwise, your mod will appear twice in the mods list because Gaia will also look into the folder where steam downloads mods and that will most likely cause some unforeseen bugs. The /Mods folder should be used for testing purposes only.

    Note that it takes a while for Steam to cache the mods, which is usually between 5-15 minutes. Your mod won’t be visible on the Gaia workshop for that time, but you can still see it if you go to your own profile’s workshop page. If you can’t see it there either, try restarting your Steam client.


    Creating your own modded building

    This is an advanced tutorial meant to show you how to add a building into the game. We’ll be using everything we used in the basic tutorial + some assets to represent our building, which you can download here:


    We’ll be creating a potato launcher, which will act as a turret in Gaia. A turret is the most complex building you can make in Gaia, so if you manage to follow this tutorial through, not only you will know how to make turrets, but you’ll also know how to make any other type of building. We will use a progenitor turret model to represent our launcher.

    1. We will create a new mod called ‘Potato Launcher Mod’ in the same way we did in the previous post. Check the mod item tutorial to see how to do so. Please note that this is A DIFFERENT MOD and as such, you have to use a different folder. Therefore, in this new folder, we will be putting our PotatoLauncher folder downloaded from above and our Potato folder used in the last tutorial. We also want to write using UnityEngine.UI; at the top of our Main script this time, since we’ll be changing some UI text.

    2. We create our modded potato item in the same way we did in the mod item tutorial with a few modifications of course (file paths etc).

    3. We now create a new method, which we shall call ‘createTheLauncher(int magicPotatoIndex)’, where the magicPotatoIndex is the integer returned by the gameHandler.addModdedItem() method from step 2. This is that unique integer which we didn’t use in the first tutorial. Now we will be using it!

    4. In this new method, we create a new ModItem. This is our launcher. This is done in the exact same way as the potato, but with different parameters. For example, we don’t want to consume our launcher so we say launcher.canBeConsumed = false; and so on.

    5. After we created the item, we want to create a building. Here is the full code for this tutorial with comments. Don’t be afraid of the 500 lines of code. More than half of that are me commenting what’s going on as well some optional stuff explaining every single other type of building.



    That’s it. There is much more you can mod in the game and I encourage anyone to look through the code themselves to find out what you can do. You can play with the weather/day/night/light settings, textures, stats of AI and any other item and a lot more! Pros may even add their own AI or decorate the world. Check out the MapSpawner script to see how it’s done.

    As a general rule of thumb, you can start in the GameHandlerScript class and the Player class to have access to every other object in the world. The GameHandlerScript has direct or indirect references to every other object in the world and to access that, you can simply do Player.player.gameHandler.



    RESERVED Assembler categories ID’s:

    Ammo Assembler: 5
    Main Assembler: 7
    Component Assembler: 3
    Cooking range: 9
    Energy Assembler: 14
    Forge: 6
    Foundation Assembler: 12
    Furniture Assembler: 10
    Misc Assembler: 11
    Mixturizer: 13
    Ship Assembler: 16
    Turret Assembler: 1
    Ancient Assembler: 17

    RESERVED Item Custom values ID’s:

    Damage: 0
    Range: 1
    Fire rate: 2
    Level: 3
    Turn speed: 4
    Hunger: 5
    Thirst: 6
    Sanity: 7
    Health: 8
    Hygiene: 9
    Bladder: 10
    Leisure: 11
    Rest: 12
    Estimated harvest: 13
    Growth time: 14
    Flight speed: 15
    Flight time: 16
    Flight regen time: 17
    Shield energy: 18
    Clip size: 19
    Reload time: 20
    Biomass: 21
    Duration: 22

    RESERVED Item unique ID’s:

    Crysoprase: 0
    Diamond: 1
    Gold: 2
    Bloodstone: 3
    Bloodstone bar: 4
    Crysoprase bar: 5
    Diamond bar: 6
    Copper: 7
    Quantum Circuit: 8
    Atomic disk: 9
    Microcontroller: 10
    Minigun turret: 11
    Ammo assembler: 12
    Component assembler: 13
    Forge: 14
    Turret assembler: 16
    Battery: 17
    Generator: 18
    Aubergine: 20
    Carrrots: 22
    Chilli: 23
    Corn: 25
    Cucumbers: 26
    Leek: 27
    Lettuce: 28
    Onions: 31
    Cooking range: 32
    Copper bar: 33
    Gold bar: 34
    Minigun ammo: 35
    Main assembler: 36
    Foundation assembler: 37
    Furniture assembler: 37
    Misc assembler: 39
    Bed: 40
    Sink: 41
    Toilet: 42
    Basic floor: 43
    Basic ceiling: 44
    Basic pillar: 45
    Basic wall: 47
    Decorative floor 1: 48
    Decorative floor 2: 49
    Decorative L floor 2: 50
    Decorative floor 3: 51
    “Ant” missile: 52
    Cluster missile turret: 53
    Bottle(empty): 55
    Water bottle(1/3) = 56
    Water bottle(2/3) = 57
    Water bottle = 58
    Mixturizer: 59
    Meat(any): 60
    Cooked Meat(any): 61
    Bubble root: 62
    Gel pouch: 63
    Globosa: 64
    Glowtubes: 65
    Purple fungus: 66
    Spiky fruit: 67
    Decoder: 68
    Energy assembler: 69
    Solar paneL: 70
    Wind turbine: 71
    M23 ammo: 72
    Plasma turret: 73
    Shield turret: 74
    Beacon: 75
    Cabinet: 76
    Auvergine salad: 77
    Spicy stew: 78
    Plasma ammo: 80
    Bublium: 81
    Glowshade: 82
    Speedrunner: 83
    Nightstalker: 84
    Ceiling light: 85
    Decorative wall 1: 86
    Decorative wall 2: 87
    Decorative wall 3: 88
    Decorative wall 4: 89
    Decorative wall 5: 90
    Decorative ceiling 1: 91
    Hermes boot(L): 92
    Hermes boot(R): 93
    Hermes glove(L): 94
    Hermes glove(R): 95
    Door 1: 96
    Door 2: 97
    Door 3: 98
    Antirad: 99
    Raw onyx: 100
    Onyx: 101
    Hydrazine capsule: 102
    Shield battery double: 103
    Shield battery single: 104
    Ammo box: 105
    MKI 1x: 106
    MKI 3x: 107
    MKI 6x: 108
    MKV: 109
    MKIII: 110
    Nuclear missile launcher: 112
    Tempest: 113
    Hydrazine: 114
    MKI ammo: 115
    MKIII ammo: 116
    MKV ammo: 117
    “Eliminator” nuclear missile: 118
    “Pillow” missile: 119
    Ship assembler: 120
    Raw meat(bear): 121
    Raw meat(cow): 122
    Raw meat(deer): 123
    Raw meat(chicken): 124
    Raw meat(goat): 125
    Raw meat(boar): 126
    Raw meat(wolf): 127
    Raw meat(amarok): 128
    Raw meat(barghest): 129
    Raw meat(harpy): 130
    Raw meat(king scorpion): 131
    Raw meat(rompo): 132
    Raw meat(sand scorpion): 133
    Raw meat(weevil): 134
    Raw meat(human): 135
    Cooked meat(bear): 136
    Cooked meat(cow): 137
    Cooked meat(deer): 138
    Cooked meat(chicken): 139
    Cooked meat(goat): 140
    Cooked meat(boar): 141
    Cooked meat(wolf): 142
    Cooked meat(amarok): 143
    Cooked meat(barghest): 144
    Cooked meat(harpy): 145
    Cooked meat(king scorpion): 146
    Cooked meat(rompo): 147
    Cooked meat(sand scorpion): 148
    Cooked meat(weevil): 149
    Cooked meat(human): 150
    Rouladen: 151
    Wellington: 152
    Ship part: 153
    Ancient assembler: 154
    Ancient assembler piece 1: 155
    Ancient assembler piece 2: 156
    Ancient assembler piece 3: 157
    Defensive wall: 158
    Window: 159
    Corner window: 160
    Constantine: 161
    Song of love: 162
    Broken leg: 163
    Explosive paint: 164
    Angelfish telephone: 165
    Console: 166
    Chair: 167
    Plant: 168
    Desk plant: 169
    Sofa: 170
    Desk: 171
    Glass table: 172
    Pilot seat: 173
    Round table: 174
    Pod receiver: 175
    Aubergine(seed) = 176
    Carrots(seed): 177
    Chilli(seed): 178
    Corn(seed): 179
    Cucumbers(seed): 180
    Leeks(seed): 181
    Lettuce(seed): 182
    Onions(seed): 183
    WindowBlocker: 184
    WindowCorner: 185

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘TUTORIAL – Gaia modding using Unity’ is closed to new replies.