Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Mar 08, 2014 at 04:56 PM by Romano for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Romano · Feb 26, 2014 at 09:57 AM · 2dspriterendererspriterendererfiltermode

Accessing FilterMode possible on a 2D sprite?

 renderer.material.mainTexture.filterMode = FilterMode.Bilinear;

is what the reference says I should do to access the filter mode of my sprite.

I have tried

 var renderer1 : Renderer;

and

 var renderer1 : SpriteRenderer;

but both give me the error "Object reference not set to an instance of an object."

I've used Debug.Log to try and find the problem and it seems to be the "filterMode" part that it has a problem with. I've attached the whole code below if that helps. The script is attached to my sprite and the sprite renderer is enabled.

 #pragma strict
 
 public var renderer1 : SpriteRenderer;
 
 function Start () 
 {
     renderer1 = GetComponent("Renderer");
 }
 
 function Update () 
 {
     if (Input.GetKey (KeyCode.UpArrow))
     {
         Debug.Log(        renderer1);
         Debug.Log(        renderer1.material)        ;
         Debug.Log(        renderer1.material.mainTexture)        ;
         Debug.Log(        renderer1.material.mainTexture.filterMode); // Throws error.
     }
 }

The error appears when I press the Up arrow. This won't actually be in my game, I just want to figure out how to access the filterMode.

Thanks very much!

Romano

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

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by Romano · Feb 27, 2014 at 08:09 AM

SUCCESS. It's a bit different for 2D sprites it seems.

Instead of this:

 spriteRenderer1.material.mainTexture.filterMode = FilterMode.Bilinear;

Use this:

 spriteRenderer1.sprite.texture.filterMode = FilterMode.Bilinear;
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 radiantboy · Mar 16 at 04:08 AM 0
Share

nice find, i mtrying to set mine to point filter, but it literally has no affect, any ideas?

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Sprite cutoff/altered in game view but not scene view 0 Answers

hide animated Sprite by code (SpriteRenderer) 2 Answers

Changing one keyframe in my animation changes all of them 2 Answers

Updating Sprite texture leaves red outline 1 Answer

Creating a fill animation for sprite renderer 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