Skip to content
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

Merged

Conversation

markgrossnickle
Copy link

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.

  • Fixes: # .
    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.

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
Copy link
Contributor

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?

Copy link
Author

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>();
Copy link
Contributor

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()
Copy link
Contributor

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;
}

Copy link
Contributor

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
Copy link
Contributor

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.
@markgrossnickle
Copy link
Author

@StephenHodgson Made the requested changes. Thanks for reviewing.

StephenHodgson
StephenHodgson previously approved these changes Jan 3, 2018
Copy link
Contributor

@StephenHodgson StephenHodgson left a 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.

Added brackets.
Added length check as Unity will default to an empty list.
@StephenHodgson StephenHodgson changed the base branch from master to Dev_Working_Branch January 4, 2018 23:58
@StephenHodgson StephenHodgson merged commit 032b42d into microsoft:Dev_Working_Branch Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants