how to bring back destroyed script file

hi,

i am triying to destroy drag2d.cs script when ontriggerenter2d occured. But right after i want to bring back my drag2d.cs script…how can i do this?

void OnTriggerEnter2D(Collider2D col)

{

if (col.gameObject.name == “grafik”)

{

Debug.Log (“grafikdegdi”);

Destroy(GameObject.Find(“yuzukadam”).GetComponent());

}

Why don’t you disable it instead of destroying it?

Also GameObject.Find is expensive.

To add a script to a gameobject:

gameObject.AddComponent("ScriptName");
1 Like

thank you @Falin , is is working :slight_smile: