Generating script runtime

Hi again. I wonder if it’s possible to make script runtime(C# script via C#)? I want to make gun crafting system in my game. It’l be working like all parts will have variables like:

float fireRate = 0.15f;

So this part will ‘give’ our new weapon +0.15 fire rate.



This question isn’t clear, but creating scripts at runtime hardly would be the solution for whatever you want to do. If you want to customize weapons, there are other solutions: you could for instance have a weapon prefab with all the possible accessories childed to it, and activate only the desired ones with gameObject.SetActive. If you want to define properties like fire rate, caliber etc. at runtime, use the GUI system to display buttons and text fields where the player can change these items.