Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DuplicateGadgetException for safety #361

Conversation

LeeTwentyThree
Copy link
Member

Changes made in this pull request

  • Add DuplicateGadgetException that is thrown when adding multiple gadgets of the same type without removing one beforehand.

Example of one exception in the log:

[Error  : Unity Log] DuplicateGadgetException: Cannot add Gadget of Type 'Nautilus.Assets.Gadgets.ScanningGadget' onto prefab of ClassID 'CopperClone' because a Gadget already exists on this prefab with the same type! Did you forget to call ICustomPrefab.RemoveGadget<TGadget>()?
Stack trace:
Nautilus.Assets.CustomPrefab.AddGadget[TGadget] (TGadget gadget) (at <2d6c53b33c57449cbcd48bf3b63cc3b1>:0)
Nautilus.Examples.CustomPrefabExamples.Awake () (at <136feb4898744685a66659a924b5e09c>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.Application:.cctor()
UWE.GameApplication:AppAwake()

@EldritchCarMaker
Copy link
Contributor

Some more explicit mentions of it in the add gadget method could help, but overall seems fine

@LeeTwentyThree LeeTwentyThree merged commit 182f6a5 into SubnauticaModding:master May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exception when using AddGadget to override an existing Gadget
2 participants