My situation is very complex, but long story short I have a script component with no attached script, but attached data. There is no way around this situation, I CANNOT restore the script, and it is iMPOSSIBLE to change my strategy (this is a Unity bug to do with asset bundling). Unless you have a solution that involves hacking how the assets are imported so that script is attached properly, (instead of, for instance, a change to my underlying strategy), please take my word for this.
The bottom line is, I need to access data from this script component, as it DOES still have variable data, the script is just missing. My idea is to gather up the script’s data, and then add a new instance of the script, and finally put in all of the original data. The problem is that, even when using GameObject.GetAllComponents() the components with the missing scripts are being returned as null! Therefore it is IMPOSSIBLE to access the data! It’s very frustrating, because I can see within the editor that the component has successfully retained its data from the import, but Unity is not giving me any method of accessing this data! I even tried decompiling the Unity dlls to see if I could find any method of getting access to the components form there, but I found nothing that stood out…
Does anyone know how I can access the data from a script component which has a missing script?
EDIT: I am sorry, I just realized how vague this was. LEt me clear up a few things:
- The assets I refer to are asset bundles (a relative to packages, but these are importable at runtime)
- The asset bundles are user-made worlds made from an older version of Unity, I do not have access to the source.
- The script switch-out needs to be done at runtime when the player loads one of the custom made worlds.
- I know exactly what script to replace the current script with, but I currently have no way of returning the script, as, according to my code, the components in question are null (even though they have data)