Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

ScrollRect + Mask not masking everything

Discussion in 'UGUI & TextMesh Pro' started by MarkOfVarberg, Sep 1, 2014.

  1. MarkOfVarberg


    Sep 5, 2013
    I have a ScrollRect with a mask set. The contents are dynamically added and consist of a number of headers with a content grid made up of buttons with sprites on them.
    There are a number of problems I'm running into, which you can see in the attached video:
    1. Some items are masked and some are not.
    2. The sprites (or the button containers) are jittering, which seems to indicate some resizing/positioning is happening, despite them being children of a fixed size grid layout.
    3. I have "preserve aspect" set on the button image, which works, but some sprite images are outside the bounds of the button size set by the grid layout constraints of 62x62

    Any help for these issues would be appreciated!

  2. Tim-C


    Unity Technologies

    Feb 6, 2010
    1) How are you adding the images to the canvas / what material is being used?
    2) Your canvas is probably set to pixel perfect (this is why it would be jittering).
    3) Maybe a bug? Raise it.
  3. MarkOfVarberg


    Sep 5, 2013
    1) I am creating a sprite from areas on a texture atlas like this:
    Code (CSharp):
    1.             Sprite sprite = Sprite.Create (material.mainTexture as Texture2D, atlasRect, new Vector2 (0.5f, 0.5f));
    3.             Transform optionButton = Instantiate (characterOptionsPanel.optionButtonPrefab) as Transform;
    4.             optionButton.SetParent (optionPanel, false);
    5.             Button button = optionButton.GetComponent<Button> ();
    6.             button.onClick.AddListener (delegate {
    7.               OptionPanelButtonPressed (button);
    8.             });
    9.             Image buttonImage = optionButton.GetComponent<Image> ();
    10.             buttonImage.color = new Color (1.0f, 1.0f, 1.0f, 1.0f);
    11.             buttonImage.sprite = sprite;
    2) I turned pixel perfect off and this fixed the jittering issue. I don't understand why the jittering happens in the non-anti-aliasing case?

    3) For the button image sizes I will raise a bug unless you see something strange in my code.
    Last edited: Sep 2, 2014