Search Unity

Question Need help transitioning between prefabs using a Ui button inside one of the prefabs

Discussion in 'AR' started by dseengal, Jun 22, 2021.

  1. dseengal

    dseengal

    Joined:
    Jul 16, 2020
    Posts:
    15
    I m working on an AR app.. with ARfoundation and ARkit... I have two prefabs in the AR app.. Prefab 1: Library and Prefab 2: Corridor... Inside prefab 1 (library) there is a UI button (set to Screen Space Overlay) .. I want a script (a way) attached to the UI button that OnClick makes the Prefab 1(library) setactive to false and in place of prefab 1, to instantiate prefab 2 (corridor)..

    I have tried a few ways..

    (1) Script attached to UI button sets the prefab1 set active to false but doesn't instantiates the prefab 2..

    (2) A transition script attached to the prefab, which works if I set it with timer to automatically set the prefab 1 to false and instantiates prefab 2 in its place using coroutines but I m not able to figure out how to connect this script attached to the prefab 1 to the UI button inside the prefab 1...

    I m new to unity and C# and not able to figure out how to get this done.. any help would be greatly appreciated..