Quantcast
Channel: Questions in topic: "assemblies"
Viewing all articles
Browse latest Browse all 145

How to put script assemblies into asset bundles and preserve public values?

$
0
0
Hi, I've searched on this question and found a lot of info related, but some inconsistencies, and no clear answer. I'm creating asset bundles with gameobjects that have scripts. I've learned how to do that. And it works. My problem is, I ultimately need to preserve the values of the public variables in the scripts that were assigned before building the asset bundle. That is, my prefab has a script with public variables. I instance it many times with different public values for each instance. I need all that to survive the trip through the asset bundle. My current process is thus: 1) Remove scripts from their game objects. 2) Build the scripts into assemblies 3) Pack game objects and assemblies into asset bundles 4) Download the bundles to new project 5) unpack the asset bundles and Instantiate the game objects 6) Attach script assemblies to game objects with AddComponent() The issue is step 1. I remove the scripts from the game objects before bundling because if I dont, it complains when unpacking that the referenced script is missing. And also, since step 6 uses AddComponent to attach it, I cant really do that if that script is already an attached component. So removing them before bundling solves those problems. What am I missing? Where is my method at fault? I read that the public values are saved in the script reference on the game object when bundled, but of course I lose that when I remove the script components. So, please, how do I maintain public values thru the asset bundling process? Should I NOT be removing script components before bundling? If so, how should I be managing the scripts differently? Would I need to bundle both the script assemblies AND source files? (I currently only bundle the assemblies), and wouldnt that create a redundancy when attaching the assembly? All help is appreciated. Thanks.

Viewing all articles
Browse latest Browse all 145

Trending Articles



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