Search Unity

Unity UI Instanciante a GameObject from script and place it randomly into a panel

Discussion in 'UGUI & TextMesh Pro' started by xroba, Sep 18, 2017.

  1. xroba

    xroba

    Joined:
    Nov 19, 2016
    Posts:
    1
    Hello All,

    I try to instanciate a GameObject ( I mean a gameobject with a transform position, there is no canvas on it) => it's a dice Prefab for example :)

    And I do have in my project a Canvas (screen- space overlay) with a Panel => deviceContainer

    Si I do not have issue to instanciate dices from the prefab :

    diceClone = Instantiate(dice, new Vector3(x, y, 0), Quaternion.identity);

    But how I can be sure that my diceClone will be randomly inside the panel DeviceContainer (even if I change the resolution).

    Thanks for your help
    Xavier