Search Unity

Question Can't seem to delete cloned prefab

Discussion in 'Getting Started' started by mjcvbuan, Mar 1, 2022.

  1. mjcvbuan

    mjcvbuan

    Joined:
    Mar 1, 2022
    Posts:
    5
    So I'm trying to destroy the clone of the prefab that I instantiated but somehow it's not working


    Code (CSharp):
    1. public TextMeshProUGUI displayText;
    2. public Canvas renderCanvas;
    3.  
    4. TextMeshProUGUI tempText = Instantiate(displayText, transform.position, Quaternion.identity);
    5. tempText.transform.SetParent(renderCanvas.transform, false);
    6. Destroy(tempText,1f);