Lets say i have an asset with some private methods for dragging, or whatever.
Outside of this I want to know when (asset.isDragging)
I can create that bool or event but either way i am opening and modifying that third party class directly.
What might be the best way to keep the original asset untouched in this scenario, where there are no events or public api…currently I usually just open and modify the source code
There’s no shame in just reaching in and messing with the library, tbh.
The alternative is reflection. It lets you access classes, methods, and fields by name at runtime. I don’t have any specific resources in mind, but you can have a look at the Microsoft docs for the topic.
1 Like
I like to leverage source control whenever I have to modify a third party library.
First I would add the entire library source to my project.
I would make sure (to the extent possible) that it lives entirely in its own folder.
I would commit it fully unmodified with nothing else in the commit.
All subsequent updates to it would be committed as pure changes to that folder, no other changes.
This has served me well: when the library gets updated I can just drop the new one in, commit it, and then hand-revert the changes in that commit that wiped out my changes, capturing those in a second commit.
This scales to a point but does require meticulous attention to commit purity.
1 Like
Ah, yes, you should give that some attention – in the past, I’ve been surprised when I discovered that my modifications weren’t getting source-controlled.
This is particularly annoying for paid assets that you don’t keep in your source tree.
Yes, you absolutely would need to “unpack and bake” a Package-Mangler-delivered asset, moving it from the package cache over to your Assets/ folder and removing it from your manifest.json
.
Then just keep a spare copy of the manifest.json file somewhere else in your repo so you can know positively which version you came from.
Ideally, don’t modify third party code, but sometimes you have no better choice.