Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

comparing clicked object with a list

Discussion in 'Getting Started' started by skeleton-king, Mar 29, 2015.

  1. skeleton-king

    skeleton-king

    Joined:
    Nov 10, 2014
    Posts:
    63
    I have a list of game object. I want to compare clicked object with 1st position of the list.
    If the compared objects are the same destroy it.

    I got a gamemanager script

    public List<Transform> Objs = new List<Transform> ();

    I got another script called items which has this

    GM = GameObject.Find ("items").GetComponent<GameManager>();
    }

    void OnMouseDown()
    {

    Destroy(gameObject);
    }

    how to check in item script if clicked object == Objs (1)
     
  2. skeleton-king

    skeleton-king

    Joined:
    Nov 10, 2014
    Posts:
    63
    Nevermind got it working. Unity was acting weird and my code wasnt working, had to restart unity.