Search Unity

set RectTransform.position on Update scrambles all Images

Discussion in 'Scripting' started by Trung-Hieu, Oct 7, 2015.

  1. Trung-Hieu

    Trung-Hieu

    Joined:
    Feb 18, 2013
    Posts:
    37
    Hi there,

    I am having a problem where, if a script set the RectTransform.position properties in every frame (Update or LateUpdate), then all other UI.Image components are scrambled. Do you guys having the same problem? Is there any workaround?

    Here is the screenshot of the problem:
    Capture.PNG

    with this piece of code attached on the Name Badge object (the UI object containing the horse icon with the Teapot text):
    Capture2.PNG

    Here is what it is supposed to look like (should have the Name Badge as well)
    Capture1.PNG
    with the code:
    Capture4.PNG


    P.s: I tried with Update/LateUpdate/FixedUpdate/OnGUI/Coroutine but to no avail

    P.s 2: Oh I solved it. Basically it is because right now all the Image component in the scene has no Sprite (I only use its color tint). You need to put a sprite in the Image component in order for it to render correctly
     
    Last edited: Oct 7, 2015