Quantcast
Channel: Latest Questions by Flynn
Viewing all articles
Browse latest Browse all 48

Unity 3 access Script component (not the script its self)

$
0
0
**Explanation of my situation:**
Okay, so this situation is a little weird. I'm working on a game that started in Unity 2. Back then we had a ton of users create a bunch of worlds using asset bundling. Now we have finally upgraded to U3, and those asset bundle imports are... buggy to say the least. I've managed to fix a ton of bugs (including shader incompatibilities) but I am rather stuck on script incompatibility. The old version of the game had world creators attach a special data-containing script to their objects to give their objects custom data. However in the new version, due to a strange bug, all of these scripts are showing up as components in the editor, but with a blank file icon. The are being imported as blank scripts with data! The actual script files from the new version are not replacing the imported script files from the U2 exports... And therefore the data scripts are no accessible by the new version! I actually ran into this problem with shaders, my solution was to create a script that ran through all of the materials in the scene, read the names of the shaders and then replaced the shaders with a project shader of the same name. I am trying to do the same with the scripts. **What I actually want to know:**
Basically, I need to access the actual ScriptComponent of a MonoBehaviour (not just the instance of the MonoBehaviour's class) and then switch the script out for another script with all of the same variables -- without losing any data. Is this possible?

Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>