Hello Guest

Author Topic: Scaling sprite according to resolution  (Read 4774 times)

moofly

  • Guest
Scaling sprite according to resolution
« on: March 13, 2015, 04:48:37 pm »
I'm using a 2DToolkit camera and it has a wildcard override set to maintain a constant width in the scene.  This works perfectly fine for most elements within the scene and overcomes many potential problems. 

One of the sprites, a tree, I'd essentially like to scale so that it goes from the bottom to the top of the screen on all devices.  In the past I've done this by attaching a script so that on start() (and update() inside an #ifdef UNITY_EDITOR to aid testing) the sprite was scaled, but I wondered if 2DToolkit had some clever built-in way that 2D toolkit could did this that I wasn't aware of?

Also, should I put the scaling into the Sprite component rather than the Transform component to avoid breaking the batching?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Scaling sprite according to resolution
« Reply #1 on: March 13, 2015, 10:30:46 pm »
You can do some cheeky thing where you use 2 cameras, one that just sees the trees that is set up to fit vertical and the other one set up normally. That could work, but just scaling it needs a bit of code but is probably easier longer term :)

moofly

  • Guest
Re: Scaling sprite according to resolution
« Reply #2 on: March 14, 2015, 02:21:14 pm »
Thanks !

moofly

  • Guest
Re: Scaling sprite according to resolution
« Reply #3 on: March 14, 2015, 02:57:40 pm »
Another question - I notice in the demos that you attached the screen anchors to the camera.  I've tried adding the screen anchor script to the tree gameobject as a component and it seems to work fine - is there a reason I shouldn't do it this way?  I like it this way because it means my scene stays organised.

Update: I've looked through the script (not sure why I didn't do that before) and it looks fine, but if you think it isn't wise do say!
« Last Edit: March 14, 2015, 04:18:43 pm by moofly »