Hello Guest

Author Topic: Make SlicedSprite Resize to Screen Size  (Read 4098 times)

wagenheimer

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Make SlicedSprite Resize to Screen Size
« on: January 17, 2014, 04:27:53 pm »
I need an advice!

My TK2dCamara Native Resolution is (1365/768) and Auto Scale = Fit Height and FitMode = Center.

I have a SlicedSprite and I want it to resize to fit the actual view Width, how to I calculate the right size considering the actual aspect ratio?

Thanks!

wagenheimer

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Re: Make SlicedSprite Resize to Screen Size
« Reply #1 on: January 17, 2014, 05:02:42 pm »
I can resize the sprite using

Code: [Select]
SlicedSprite.dimensions = new Vector2(tk2dCamera.Instance.ScreenExtents.width,SlicedSprite.dimensions.y);

But how to resize the tk2dUiLayoutScript instead of the sprite? I need to keep everything aligned after resizing the sprite. Is this possible?


wagenheimer

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Re: Make SlicedSprite Resize to Screen Size
« Reply #2 on: January 17, 2014, 05:31:47 pm »
Problem solved! =)

gameObject.GetComponent<tk2dUILayout>().SetBounds(new Vector3(tk2dCamera.Instance.ScreenExtents.xMin,tk2dCamera.Instance.ScreenExtents.yMin,0), new Vector3(tk2dCamera.Instance.ScreenExtents.xMax,tk2dCamera.Instance.ScreenExtents.yMax,0));