• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ATMEthan · Apr 06, 2015 at 09:18 PM · spritesize

Trim a single packed sprite?

Hey all,

I have a game I am making that is an endless vertical climb game. The player has two colors his character can be(Taps the screen to switch colors); depending on which color he is he can climb upwards on the background or climb upwards on the obstacles. Some of these obstacles are as wide/tall as the screen so many of them fill up their own atlas. Majority of these obstacle assets take up their own 2048by2048 sprite sheet. Which I'm fine with b/c I'm doing heavy resource management to begin with.

My problem is that I have no way to trim these sprites in unity. Everything needs to be a POT(for compression reasons, ios mainly) which leaves me at 1024 or 2048 texture sizes so as you may expect there is tons of transparency space. But when I do something like sprite.position = Screen.Height + sprite.bounds.x I'm given 2048 for the height when the actual height might be anything from 1025 - 2048. I can set the border manually for each sprite in the Sprite Editor window but when testing the sprites size is still 2048by2048 in the scene.

I see a trim button in the Sprite Editor window but much to my great dismay that is only available to multiple packed sprites. All of my sprites are individual assets and cannot be set to multiple. So how can I trim the transparency from a single sprite? OR How can I get the actual height/width of a single sprite??

Thank you for the help.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ATMEthan · Apr 06, 2015 at 09:23 PM 0
Share

SOOOOO - basically my only way of getting this information (Size of a sprite that has the transparency trimmed) is to set the borders in the sprite editor to be as tight as possible around my sprite - add the top and bottom value and subtract from the height of the texture.... Am I doing this wrong? There's gotta be a better way.

Edit: now that I've messed with this possible solution for a lil bit - I jumped the gun it doesn't really help at all.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I get the bounds of a sprite on its sprite atlas? 0 Answers

Unity big sprite size and how to deal with it. 1 Answer

Unity2d: Change Sprite size depending on Y position 0 Answers

How to make sprites occupy the same screen space on different resolutions ? 1 Answer

How can I change size the sprites ?? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges