Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    530
    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).