Very odd problem, I have a Canvas object and I am trying to set the overrideSorting flag to true.
public void SetSortingLevel(string sortinglayerName)
{
_canvas.overrideSorting = true;
_canvas.sortingLayerName = sortinglayerName;
}
However, normally this works, however if I put a breakpoint and look at the code, even right after setting the override to true, it is false:
The api shows this is just a setter/getter. Any idea why this is happening?
I have used this code before and it normally works.
Note: This is a nested canvas so it should be allowed to have its sorting layer set.
Answer: As noted in the answer below, the activeInHierarchy check turns out to be false.