Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

how to bring back destroyed script file

Discussion in 'Scripting' started by verderveremem, Jun 2, 2014.

  1. verderveremem

    verderveremem

    Joined:
    May 11, 2014
    Posts:
    52
    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<drag2d>());

    }
     
  2. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    548
    Why don't you disable it instead of destroying it?

    Also GameObject.Find is expensive.
     
  3. Falin

    Falin

    Joined:
    Sep 29, 2009
    Posts:
    242
    verderveremem likes this.
  4. verderveremem

    verderveremem

    Joined:
    May 11, 2014
    Posts:
    52
    thank you @Falin, is is working :)
     
unityunity