Author Topic: [resolved]Setting Anchor through code reset UISprite size  (Read 1758 times)

vikti

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
[resolved]Setting Anchor through code reset UISprite size
« on: December 01, 2014, 01:20:31 PM »
Hellon

I attempt to dynamically add markers on a map.

My marker is a prefab with a UISprite component. It has a 120*120 size

I do :
  1.         GameObject UIMarker = NGUITools.AddChild(MapComponentPanel, markerPrefab);
  2.         UIMarker.GetComponent<UISprite>().SetAnchor(markerDummy.transform);

At runtime the sprite size is reseted to 2*2.

What is the right way to add a child and to anchor it while keeping the size of the prefab ?
« Last Edit: December 02, 2014, 01:31:36 PM by vikti »

vikti

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Setting Anchor through code reset UISprite size
« Reply #1 on: December 01, 2014, 03:27:53 PM »
With deeper search in the forum I found that the widget/sprite must need a parent.

So for now I have :

|--dummyMarker
    UISprite

and I need to have

|--parent
    UIWidget
    |--dummyMarker
        UIsprite

I will try that

Edit : it works.
« Last Edit: December 02, 2014, 01:31:10 PM by vikti »