Mega Tree API
FAQ
Symptoms, and what actually causes them.
My plugin does not load at all, and the log says nothing
This is the first thing to check in this game, and it is almost always one of two things.
| Cause | How to tell |
|---|---|
| BepInEx 6 instead of 5 | Megastore is Mono. If you installed the IL2CPP build - the one Supermarket Simulator uses - nothing loads, including Mega Tree itself. |
| Your plugin is built for IL2CPP | You inherited BasePlugin and overrode Load(). In Mono it is BaseUnityPlugin and Awake(). |
Both fail silently: no exception, no line in the log, nothing in the plugin list. It reads exactly like a broken mod. Project setup has the csproj that works.
Supermarket Simulator is IL2CPP with BepInEx 6. Megastore Simulator is Mono with BepInEx 5. The names are similar, the mods are not interchangeable in either direction, and no amount of renaming a folder changes that.
Nothing appears in the tree
Read the log. Open BepInEx/LogOutput.log and search
for [api]. Every registration, rejection and reason is written there
with your plugin guid.
| Log line | Fix |
|---|---|
id must be in 'prefix.name' form |
Ids need a dot: bigboxes.capacity, not capacity. |
invalid character '...' |
Lower case only, plus digits, _, - and dots. |
DescribeLevel is required |
Set it. It is the text the player reads. |
already belongs to ... |
Another mod claimed that id. Pick another. |
Nothing at all under [api] |
Your Awake() never ran, or never reached the registration. Log something at the very top of it. |
An empty sub-tab is never drawn, and the Mods tab does not exist until a mod registers something - so if all your registrations failed, there is no tab at all, which looks like Mega Tree ignoring you.
BepInEx logs a duplicate guid error for MegaTree
Two copies of MegaTree.dll are installed - almost always because a
mod shipped it inside its own folder. BepInEx loads one and drops the other, so the player may be
running a different version from the one they installed. Set
<Private>false</Private> on the reference and re-publish.
Project setup
The node is there but does nothing
You registered it and never wrote the effect. Mega Tree stores a number; what that number means is always your code. Events covers the three shapes an effect can take.
The effect works, then stops
You are writing a field the game rewrites on its own schedule. Patch the getter instead - the
game asks, you answer, and nothing can undo it. If there is no getter, re-apply on
Apply, always computing from a remembered base value rather than
adding to the current one.
I patched the getter and the timing did not change
Look for a cached WaitForSeconds. A coroutine that yields on an
object built once keeps the old interval no matter what your getter returns - the duration was
baked in when that object was created. Write the field holding it instead.
This is exactly what made Mega Tree's own cashier upgrade do nothing for a while, so it is not a hypothetical.
The effect grows forever
Apply runs about twice a second and you used
+=. Compute absolutely: value = base * factor,
never value += step. Details
The player's money went up (or down) twice as fast
You called AddSoftCurrency and notified
ADD_SOFT_CURRENCY. In this game the event is the
payment - EconomyManager subscribes to it and moves the balance. No game
code calls the methods directly, and neither should you.
EventManager.NotifyEvent(EconomyEvents.ADD_SOFT_CURRENCY, bonus); // this line alone paysThe icon is invisible, or the wrong colour
Mega Tree tints icons through Image.color, and tinting multiplies.
Ship white artwork on a transparent background, or pass
whiteSilhouette: true. A dark icon multiplied by anything stays dark.
Icons
My node is locked forever
Your IsUnlocked returns false, or it throws - in which case the node
is treated as unlocked and there will be a warning in the log naming it. Also check
ComingSoon: that one can only be cleared by a mod update, never by the
player. Requirements
A player says my node is grey and wants a store level
That is RequiredStoreLevel, and it only touches your node if
you set it. If you never did, your node has no level requirement and something else is
locking it - check IsUnlocked first.
Players can also turn the whole mechanic off with
StoreLevelRequirements = false in
BepInEx/config/MegaTree.cfg, and that ignores your requirement along
with everyone else's. Node definition
Levels vanished after I updated my mod
You changed an id. The id is the save key: renaming it starts that line from zero and parks the
old level in the kept block. Change the name, the price, the icon, the effect - never the id. If
you must, list the old one in LegacyIds and the level comes with it.
Versioning
A player uninstalled my mod and lost their upgrades
They should not have. Unknown ids are kept in the slot file under a comment and come back when
your mod returns. If it really happened, ask for
BepInEx/config/MegaTree/slotN.dat - it is plain text, and the kept block
is at the bottom. Persistence
How do I change the sell-back rate for my node?
Set SellBackRate on your definition. It takes 0 to 1 and affects
only your node - the built-in upgrades stay at 50%, and there is no player-facing
setting for it.
SellBackRate = 0.8f, // this node refunds 80%; everything else stays at 50%Anything outside 0..1 is clamped, with a warning in the log. Above 1 the player would profit by buying and selling in a loop.
Straying far from 50% costs you something, though. Near 1.0 the upgrade becomes a piggy bank - buy to park money, sell when you need it, for free. Near 0 it punishes anyone who experiments. And a player looking at one node that refunds 90% next to one that refunds 50% has no way to know why. Use it when your line genuinely needs it, not by default.
Can I add my own top-level tab?
No. There are three fixed categories plus Mods, and everything registered through the API lives in Mods, in your own sub-tab. That is what keeps the header readable with ten mods installed. The Mods tab
Can I pick my node's colour?
No. The Mods branch is violet for everyone. A tree where each mod picks its own palette stops reading as one tree.
Can I read or change another mod's node?
You can read any level with MegaTreeApi.GetLevel, which is
what gating on another mod is built on. You cannot change or unregister a node you do not own -
Unregister checks the owner guid and returns false.
Can I give the player a level for free?
No. Levels change through the player buying or selling them, and that is deliberate: an API that could hand out levels would also be an API that could take them away, and both belong to the player. If you want a free effect, apply it in your own code without a node.
Is my code the same as a Tech Tree mod's?
The registration is, almost exactly - swap TechTree.Api for
MegaTree.Api and the class names follow. The
project is not: different target framework, different BepInEx, different base class, no
Il2CppInterop. The API reference ends with a table of every
difference.
Does registering many nodes slow the game down?
No. Lookups are dictionary-based, and Mega Tree measures its own per-frame cost into the log
(search for [perf]) so you can check rather than guess. The
64-per-plugin limit is there to stop a runaway loop, not because 30 nodes would be slow.
Where do I ask something not on this page?
The Posts
tab on Nexus. Include the [api] lines from your log - they usually
contain the answer already.