Author Topic: image viewer  (Read 11668 times)

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
image viewer
« on: April 14, 2015, 12:57:47 PM »
Hi, i'm a novice developer and i'm trying to make an app with ngui, i'm stuck with a simple problem, hope u can help me!
i need to create with ngui a sort of image viewer for smartphone just like the image viewer in android/ios/wp8 image gallery, but how can i do that?
i have a thumbnail, when i click on it this thumbnail enable one uitexture object on the scene, pass one texture2d to him and the uitexture should be displayed on screen, rescaled properly for the screen resolution.
But i really dunno how can i rescaling the uitexture via script for keep his aspect ratio, i suppose it's an easy task but i'm really noob :(
thank you for your help and sorry for my english.

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: image viewer
« Reply #1 on: April 14, 2015, 07:08:10 PM »
ok i found this:

  1.  //
  2.  public Texture m_texture;
  3.  
  4.  //
  5.  void OnGUI()
  6.  {
  7.      //
  8.      GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), m_texture, ScaleMode.ScaleToFit, true);
  9.  }

that's exactly what i want from my uitexture....can i do that with uitexture?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: image viewer
« Reply #2 on: April 16, 2015, 06:59:44 AM »
ALT+SHIFT+T to create a texture, assign the texture, change its dimensions to where you want it to be (full screen), then enable anchoring so it stays there.

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: image viewer
« Reply #3 on: April 16, 2015, 10:01:11 AM »
ALT+SHIFT+T to create a texture, assign the texture, change its dimensions to where you want it to be (full screen), then enable anchoring so it stays there.

the problem is i assign the texture via script in runtime, so i need the guitexture scale in consequence, i obtain that with GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), m_texture, ScaleMode.ScaleToFit, true); , dunno how can i obtain that with your uitexture

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: image viewer
« Reply #4 on: April 18, 2015, 12:39:58 PM »
Anchoring is what will ensure that it scales to full screen. You can assign it at run time if you like, just skip the "set the texture" part.