Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 TommyJ · Jan 25, 2017 at 10:31 PM · c#buttonspriterenderinggraphics

Black border around 2D sprite

There seems to be some kind of graphical/rendering bug. I am making different themes for my video game and for some reason, when I switch themes(a different sprite sheet), there's a black border around it. I made sure the rendering options are the same on both sprite sheets, and both sprites were the same resolution. Can someone please explain why this is happening?

The original themed buttons alt text

The new themed buttons alt text

blue.png (7.2 kB)
green.png (4.7 kB)
Comment
Add comment · Show 2
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 UnityCoach · Jan 25, 2017 at 10:40 PM 0
Share

What is the source? PNG? PSD?

avatar image TommyJ UnityCoach · Jan 25, 2017 at 11:43 PM 0
Share

Portable network graphic or PNG

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Koen-Matthijs · Jan 25, 2017 at 11:09 PM

Hi

I had a few of these occur as well. The actual black line is because the background of your cam is black and Unity is not so happy with your sprite size.

A few things you should check:

  1. Your sprite should be NPOT. If it isn't make it so and fill the added space with transparency.

  2. Check the filtering and use Point Filtering

  3. Play with the pixel-to-unit size (set it 1-on-1 just to see what happens and adjust from there)

  4. Switch on pixel snapping (i.e. go pixel perfect) or use a custom material with the default sprite shader

Hope these may help you out.


Kind regards,

Koen Matthijs

Comment
Add comment · Show 1 · Share
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 TommyJ · Jan 25, 2017 at 11:48 PM 0
Share

Playing around with these setting worked beautifully, thanks!

avatar image
0

Answer by liortal · Aug 30, 2017 at 09:02 PM

Setting the created texture to use point filtering seems to give better results:

 public static Sprite LoadPNGToSprite(string filepath)
     {
         Texture2D texture = LoadPNG(filepath);
 
         texture.alphaIsTransparency = true;
         texture.wrapMode = TextureWrapMode.Repeat;
         texture.filterMode = FilterMode.Point;
 
         float pixelsPerUnit = 100;
 
         return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0), pixelsPerUnit);
     }
Comment
Add comment · Share
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
0

Answer by jrwalz · Mar 23, 2018 at 11:30 PM

I was actually thinking about spending some time learning this Unity graphics engine. So I thought that I would start out with something simple, like putting a border around a sprite then manually creating a map from each sprite with that border. Well that would have been a lot of work for a graphics engine that is supposed to represent 2018, but then I realized what would seem completely illogical. There isn't a way to put a border around the sprite, wow. I'll wait for the next future, the real one.

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Smoothing Directionally between three materials 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

2D Sprite Graphics Glitching, Skewing, Flickering, Crazy, Haywire 1 Answer

Strange artifacts in builds 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges