Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

How can I render placeholders inside Text to allow drag n drop on them

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by mustafamagdy, Aug 9, 2018.

  1. mustafamagdy

    mustafamagdy

    Joined:
    Sep 11, 2015
    Posts:
    2
    I need to render a placeholder inside text to allow drag n drop behavior on those placeholders as shown in this image

    upload_2018-8-9_20-40-28.png
     
  2. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    309
    1. create the texture like you have above and import to unity as a 9 slices type.
    2. In your text object, make a new UI Image object with anchors of max stretch anchors.
    3. Change the left,right, top, bottom values to 5, or whatever you want the distance from the texture to be.
    4. Reference that object in your code and enable/disable through gameObject.SetActive(bool)
    5. You can detect mouseOver several ways, there are plenty of examples looking up on google
    let us know if you get stuck at some point.
     
  3. mustafamagdy

    mustafamagdy

    Joined:
    Sep 11, 2015
    Posts:
    2
    But how the image will be placed if the text length is not determined yet?