-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fade Plane and transparent Sprite Fix #1563
Fade Plane and transparent Sprite Fix #1563
Conversation
… maintain." This reverts commit 8ec2a24.
This commit moves the FadePlane to the last layer in the SortingLayers to prevent it from wiping out any transparent 2D textures.
namespace HoloToolkit.Unity | ||
{ | ||
// Overrides the sorting layer of all renderers and child renderers | ||
public class SortingLayerOverride : MonoBehaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a monobehaviour or maybe an extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. It could be an extension but I'd probably still want a monobehaviour to call into that extension method as I tend to just add this behavior to gameObject or prefab that I need to sort.
|
||
void Start() | ||
{ | ||
renderers = GetComponentsInChildren<Renderer>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if it's null first before searching, that way we can give devs the option to serialize this into the prefab/scene.
private Renderer[] renderers; | ||
|
||
|
||
void Start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; all Unity Methods should be private
{ | ||
componentRenderer.sortingLayerName = TargetSortingLayerName; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
|
||
namespace HoloToolkit.Unity | ||
{ | ||
// Overrides the sorting layer of all renderers and child renderers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use the <summary>
tags
Enabled serialization of renderers and made formatting changes.
@StephenHodgson Made the requested changes. Thanks for reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just missing braces around that null check, but looks good to me.
Overview
The FadePlane currently wipes out transparent sprites that are not on the default sorting plane. This commit maintains the FadePlane's functionality while ensuring transparent sprites still appear by drawing the FadePlane last.
Changes
I added a class called SortingLayerOverride which I believe was sharing with me from an engineer at Microsoft awhile back. I modified it to enable you to choose to always select the last layer in the sorting layers array.
I applied this behavior to the FadePlan and set it to use the last available layer.
I did not create a bug ticket but when you use the FadePlane the transparent wipes out any transparent 2D sprite that is not on the default sorting layer. This commit fixes that issue.