Search Unity

GetComponent for Pixel Perfect Camera

Discussion in '2D' started by musicdudejoe, Mar 3, 2021.

Thread Status:
Not open for further replies.
  1. musicdudejoe

    musicdudejoe

    Joined:
    Jan 27, 2021
    Posts:
    1
    I'm not sure if it's something I'm doing wrong but I cannot find a way to get the Pixel Perfect Camera component from the main camera. I want to change values there but I'm struggling to even access it. Wasn't sure if this was on purpose or if it's a bug.

    GetComponent<PixelPerfectCamera>
    does not work.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    If this were a bug in Unity then absolutely nothing would work.

    "Does not work". Maybe ellaborate because nobody knows what that really means. If you're hinting that its returning NULL then it simply means that this component isn't on the GameObject you're calling "GetComponent" on; it's as simple as that.
     
  3. nopogo

    nopogo

    Joined:
    Sep 9, 2012
    Posts:
    25
    @MelvMay the most unhelpful response I've ever read on here to date, and that is quite the achievement. Congrats!

    Had the same issue. For me it was my imports. I was using:
    Code (CSharp):
    1. using UnityEngine.U2D;
    which is not the "right" PixelPerfectCamera for some reason. If you instead do
    Code (CSharp):
    1. using UnityEngine.Experimental.Rendering.Universal;
    it will work
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    We get thousands of posts stating "it does not work" where devs do not explain what is actually wrong and other devs spend a lot of time guessing what is wrong before being able to suggest a fix. Please spend thousands of hours helping people on the forums, then come back and tell me about being helpful. ;)

    You could've easily posted your suggestion without such exaggerated criticism too.
     
    venediklee likes this.
Thread Status:
Not open for further replies.