Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by peterworth · Jan 06, 2015 at 03:50 PM · uispritemipmaps

getting mip mapping to work on sprites

I can't seem to get mip maps to work for when i'm scaling down sprites in a 2d game.

It's the same problem in 2 different situations:

1) an ordinary sprite, becoming smaller when "zoomed out" by changing the scale on the camera

2) an Image in the new UI system, scaled down by having its RectTransform width and height set smaller

Should it work in both of these situations? I'm making the sprites in a script like this:

 Texture2D texture = new Texture2D(4,4,TextureFormat.BGRA32,true);
 
 //have tried all different kinds of settings for the following, none seem to help
 texture.filterMode =  FilterMode.Trilinear;
 texture.mipMapBias =  8f;
 texture.anisoLevel = 9; 
 
 texture.LoadImage(image);
 Sprite sprite = Sprite.Create(texture, new Rect(0f,0f,texture.width,texture.height), new Vector2(.5f,.5f), 100.0f);
 cell.transform.Find("Thumb").gameObject.GetComponent<Image>().sprite = sprite;

this is what an image of a grid looks like scaled down in unity: alt text

and this is the same image scaled down properly (what i'd like it to look like): alt text

is it impossible to do this with mip maps? if so is there another way you're supposed to do it? it must be possible! driving me mad...

EDIT:

I've managed to get both of the above situations working properly with mipmaps, by doing it with a test sprite in the editor rather than in a script. I.e. i turned mipmaps on in the image file's import settings.

But for my game i need to do it in a script (to import hundreds of sprites). Does anyone know if it should work? I would have thought that creating the texture with the last parameter set to true would be equivalent to turning mipmaps on in the texture import settings?

good.png (11.6 kB)
bad.png (11.0 kB)
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 peterworth · Jan 07, 2015 at 10:24 AM 0
Share

additionally, in the import settings in the editor, i see an option for "in linear space" - where is the equivalent for this in the Texture2D class?

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.

Follow this Question

Answers Answers and Comments

25 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can't change Image sprite because in rebuild loop? 2 Answers

Unity 4.6's button Bug? 1 Answer

How to add callback for button press to a private function (New UI)? 1 Answer

Unity 5.0 Trying to Change the Image - Source Image via Script 3 Answers

How to make a UI image change sprite through a script that is not attached to the UI image itself 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