- Home /
Prefabs not finding MonoBehaviours moved into a plugin DLL
"From 3.0 you can use monobehaviours from dlls. The dll need to be added to any folder named Plugins inside the Assets folder.
Once there you can use the Project window at the Unity Editor to explore the DLL contents and drag and drop the monobehavior into any game object.
It works just fine!"
Well, not exactly fine... I have a lot of prefabs with various scripts as components attached to them, and none of them switch to finding the MonoBehaviour scripts that I moved to a DLL even though I can see the scripts in the assets browser (with a different icon than the ones with source code available). I was looking to set someone up for level editing without giving them everything including the script code, and this seemed like it might've worked. But it's a lot of work to go through every prefab and correctly update the monobehaviours to point to the new location in the dll. Can this be fixed in the future? Is there a workaround to programatically get the prefabs finding the scripts when they're moved to DLLs?
Well, managed code dlls don't have to be in the plugin folder. Just place them somewhere inside "Assets" just like a script file. Your problem is that the script assets are gone and the $$anonymous$$onoBehaviours inside the dll (from Unity's view) are completely new assets. Unity uses a hash to keep up the linkage. When Unity open the project and the old asset is gone Unity can't remember anything about the asset except that it was a $$anonymous$$onoScript. Unfortunately at the moment there is now way to retrieve the class-name that was inside the script. At least i guess. $$anonymous$$aybe we'll get an update one day.
What happens if you have both the script and the dll present at once -- is it possible to write an editor script that will go through all the prefabs and convert the script reference to a dll reference?
I have the same problem. In the past when I converted scripts from UnityScript to C# I was able to use meta files to search and replace the GUIDs so Unity would find the new scripts. However it appears that DLLs only get one GUID, so there isn't a way to set the GUIDs for all the scripts it contains. If anybody knows how to fix this, please post an answer!
Answer by Steven-Walker · May 15, 2013 at 12:32 AM
I found an answer to this problem, though it is fairly complicated and requires a lot of work. I haven't done this yet myself, but it looks promising. See the link below, part 3. Basically, it requires building a table to remap file and guids from the old loose scripts to the DLL and search-replacing meta and text files throughout the project. So each project would have to be done separately.
Your answer
![](https://koobas.hobune.stream/wayback/20220613113326im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Monobehaviours & Editors with Inheritance across DLL boundaries don't load into Unity 2 Answers
Is there a way to hide a dll MonoBehaviour, or disallow adding it? 1 Answer
Adding new code to built client 0 Answers
How to instantiate a MonoBehaviour from a downloaded DLL at runtime? 0 Answers
Can I distribute Unity's DLL with an open source project? 2 Answers