Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Get the Instantiate parameters by instantiated object

Discussion in 'Prefabs' started by MikeyJY, Feb 19, 2020.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    529
    I have this part of a script:
    Code (CSharp):
    1. Item = hit.transfrom.gameObject;
    2. NewItem = Instantiate(Item, new Vector3(x, y, x), new Quaternion(x, y, z, w));
    As you can see, the Item GameObject is an existent gameObject from hierarchy.
    After executing this lines of code, I have a new gameObject in the hierarchy named exactly as the Item but with "(Clone)" at the end.

    In other script, I want to get the Item gameObject in a variable using NewItem.
    Basically I want to get the gameObject which was used to Instantiate another gameObject(Clone).