Search Unity

Need help with layers

Discussion in '2D' started by IvanPavlovGames, Jul 23, 2016.

  1. IvanPavlovGames

    IvanPavlovGames

    Joined:
    Aug 25, 2015
    Posts:
    9
    Good day, community. I have 3 layers: first is topmost and third is lowermost. I need that my first layer was on the second, but under the third layer, and the second still being on the third. So I have a question: How to do that, does anyone know?
     
  2. PeaceLaced

    PeaceLaced

    Joined:
    Jun 2, 2015
    Posts:
    53
    Please be more specific and define a few things for us so we can help.

    What does top most mean, order in the layer list or render order?
    What does lower most mean,order in the layer list or render order?
    What does 'was on' mean in the statement "first layer was on the second"?
    What does 'being on' mean in the statement "the second still being on the third"?

    Also, are we talking about regular layers or sorting layers?

    It also may be good to give some context as to what you are trying to do.
     
  3. unitynoob24

    unitynoob24

    Joined:
    Dec 27, 2014
    Posts:
    398
    Assuming you are working with 2D Sprite Renderers.

    They have an 'Order in Layer' property. You can simply enter a value there. Where 0 is like the default, negative will be behind 0, and positive values will be above 0 and their lesser values.

    HOWEVER, if you are looking to have a lot more going on, and depending what the layers are. It would probably be best to set up Sorting Layers which can be found directly above the Order in Layer property. This works the same way assigning Tags does. Click the drop down, create a new Sorting Layer, then name it respectively. IE, Background, Foreground, Level etc. Then simply mark certain elements as such!

    You can use Sorting Layers along side of Order in Layer for best results! But you can mix and match! Really depends on the size of the project and how organized you want to be.

    Hope this helped!
     
  4. IvanPavlovGames

    IvanPavlovGames

    Joined:
    Aug 25, 2015
    Posts:
    9
    EXA.png
    We are talking about sorting layers. Ok then, here is a picture. I have some solutions that go in photo editors: just make that first layer was invisible on the third or make that first layer rendrer only on the second, but these solutions don't go in Unity as I know.
     
  5. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    You can try to add more cameras in scene. Then adjust visiblity layers, camera depths and clear flags.
     
  6. IvanPavlovGames

    IvanPavlovGames

    Joined:
    Aug 25, 2015
    Posts:
    9
    That's interesting. Can you describe this solution in detail,please? Maybe you have an example? Or can you give some links?
     
  7. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    I thought you can make 2 or more cameras. And then just enable layers for rendering. I am not sure now, that this way will help you. Cameras with different depth will still work as other layer. And you are trying to split one layer.
     
  8. IvanPavlovGames

    IvanPavlovGames

    Joined:
    Aug 25, 2015
    Posts:
    9
    But only one camera with the biggest depth shows the scene!
     
  9. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    You can set clear flags - don't clear. Then the top camera will render choosen layers (culling mask) and the background will be taken from cameras with lower depth. As said, I dont think it will help you, because you are trying to make 1st layer be in two layers at one time.
    Try to ask in shader forum about depth mask, maybe :)
     
  10. IvanPavlovGames

    IvanPavlovGames

    Joined:
    Aug 25, 2015
    Posts:
    9
    Anyway, thanks for your help! Maybe I will find how to solve my problem using your advice