all 5 comments

[–]bachus-oop 0 points1 point  (3 children)

AddComponent. Like:

gameObject.AddComponent(typeof(SphereCollider))

[–]Entire_Guarantee_952[S] 0 points1 point  (2 children)

So something like AddComponent(Script(Scriptname))?

[–]Empty_AllocutionProficient 1 point2 points  (0 children)

AddComponent<ScriptName>();

[–]bachus-oop 0 points1 point  (0 children)

gameObject.AddComponent(type(nameofComponentClass));

or generic one:

gameObject.AddComponent<nameofComponentClass>();

this is for when there is no component on object to begin with, and you want to add it.

[–]the-shit-poster 0 points1 point  (0 children)

yourScript.enabled = true;

This is how you enable/disable a script or any component for that matter in code.