Search Unity

Sprite / canvas layer order problems.

Discussion in 'Scripting' started by dacoursey, Mar 29, 2017.

  1. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    I'm trying to figure out how to put a sprite over the top of a line drawn with vectrosity.

    This is a tiny 2d game with only one script attached to the main camera. The 2d lines drawn are on a canvas at runtime, which is working. But I want a sprite to pop up over the track, which isn't - it's underneath.

    I created a new canvas, and set the sorting layer:

    Code (CSharp):
    1. public Canvas drawingCanvas;  //drawingCanvas is attached to the script
    2. drawingCanvas.sortingLayerName = "Track";
    However, when I mouse over the field while debugging in VS, it still shows the name as "Default".

    Any insight would be greatly appreciated, been banging my head on this for a few days.

    Thanks

    david
     
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    I've not used Vectrosity but it's likely that it's rendering using it's own camera somehow?

    You can order canvases but if something is rendering using another camera (on top of that) then you won't be able to put any sprites above it unless you create another camera too.

    For example, you could have:

    BehindCamera (Camera type - renders with a culling mask 'BehindUI')
    ---->BehindCanvas

    FrontCamera (Camera type - renders with a culling mask 'FrontUI')
    ---->FrontCanvas

    You can then change the camera depths until you get it working with Vectrosity. You need to have the 'BehindCamera' rendering first, Vectrosity next and finally your FrontCamera.