Search Unity

Bug Selecting Gameobject with sprite renderer with negative x scale is not working.

Discussion in 'Editor & General Support' started by castor76, Nov 4, 2021.

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    For Unity 2021.2, using 2D

    if you have a simple game object with negative scale, you can't select it easily by clicking on the sprite object. You have to marque area select it instead.

    This is highly annoying, and was not like this before 2021.2.
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have made bug report : case (1381316 )
     
  3. Lepisto3D

    Lepisto3D

    Joined:
    Oct 6, 2019
    Posts:
    27
    Same problem for me still, in Unity 2021.3.8f1

    I really can't figure out the issue. If I rotate my camera around, it allows me to click select on some of the sprites. And if I flip the X / Y on the renderer, sometimes it works too, but there doesn't seem to be a specific pattern or anything.

    Can add that this happens even on sprites that are not negative transforms.
     
  4. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    I kinda figured this out. Basically the "Sprite" shader has some weird setting (like it looks two-sided, but gets culled like a one-sided thing). The workaround is to use Unlit (not "Sprite Unlit") shader with "Render Face = Both".
     
  5. RyanCantCode

    RyanCantCode

    Joined:
    Oct 22, 2018
    Posts:
    8
    Is there any plan or official way to fix this that I'm missing? I just ran into it in Unity 2022.3.12f1 LTS.

    The issue mentioned above by @castor76 (1381316) is marked as "Third Party Issue", but I don't think that's the case.

    https://issuetracker.unity3d.com/is...e-scene-view-when-its-scale-value-is-negative

    One of the commenters (WENGJX-) posted a workaround that actually works (below).

    To recreate the issue:
    - Import an png texture as a Sprite
    - Add it to the scene.
    - Make a new URP Sprite Lit shader graph.
    - Setup (_MainTex into) SampleTexture2D (Hookup Color and Alpha) as normal in that shader graph.
    - Create Material from the Shader Graph.
    - Add the Material to the Sprite Renderer of the Sprite you added to the scene earlier.
    - Make the Sprites X = -1
    - Try to select the sprite in scene view.

    Issue:
    - You can not select the sprite in Scene View unless you marquee over the entire thing or use the Heirarchy Inspector while it's X is negative.

    The workaround:
    - Change the Sprite Lit shader graph on the object with a -X value to a Lit shader graph.
    - Change Render Face to "Both".
    - Change back to Sprite Lit Shader graph.
    - Save.
    - It can now be selected in the Scene view regardless of X being negative.

    The confusion of closing the issue as third-party may have come from the fact the the Sprite-Lit-Default shader that is auto applied to every Sprite DOES work, it CAN be selected if X is negative, but that's likely because it has something thing going on in the shader code that is on by default or not available to us when we create a new Sprite Lit shader graph.

    The problem is, we can't access "Render Face" on a Sprite Lit shader (in Shader Graph) to fix this issue, but apparently, the graph holds this value somewhere on the backend where it persists between changing between Lit shader and Sprite Lit shader graph types, so fixing it in the Lit shader (by setting Render Face to Both), will actually retain the changes when switching back to Sprite Lit, maybe those settings are Universal and just revealed depending on Material selection?

    If "Render Face" doesn't "do" anything to the sprite lit shader except make it selectable when applied to a reversed object in the scene view, then maybe it should be on (set to Both) by default for all new Sprite Lit and Unlit shader graphs created so objects they are applied to can be selected in the scene view no matter which way they face?

    I would have suggested to give us the option to change it on the Sprite Lit shader graph, but that would be confusing, because it doesn't seem to do anything to a Sprite Lit shader except fix this issue, so setting it to Both by default on Sprite Lit/Unlit shaders would be my vote.

    Lastly, I ran into this because I use a script to reverse doors for double doors in a top down game and selecting the doors becomes impossible (except by using marquee selection) once the X is made negative, unless the workaround above is used.