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

Export guard / layer mask fix #708

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Runtime/Scripts/GLTFSceneExportGuard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using UnityEngine;

namespace UnityGLTF
{
// Empty implementation of IGLTFSceneExportGuard for use with editor.
public class GLTFSceneExportGuard : MonoBehaviour, IGLTFSceneExportGuard
{
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/GLTFSceneExportGuard.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Runtime/Scripts/GLTFSceneExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public override bool BeforeMaterialExport(GLTFSceneExporter exporter, GLTFRoot g
#pragma warning restore CS0618 // Type or member is obsolete
}

// Empty interface to mark a portion of a transform hierarchy as unexportable.
public interface IGLTFSceneExportGuard
{
//
}

[Obsolete("Use UnityGLTF.ExportContext instead. (UnityUpgradable) -> UnityGLTF.ExportContext")]
public class ExportOptions: ExportContext
{
Expand Down Expand Up @@ -965,8 +971,11 @@ private bool ShouldExportTransform(Transform transform)
{
return false;
}
if (settings.UseMainCameraVisibility && (_exportLayerMask >= 0 && _exportLayerMask != (_exportLayerMask | 1 << transform.gameObject.layer))) return false;

if (settings.UseMainCameraVisibility && (_exportLayerMask != 0 && _exportLayerMask != (_exportLayerMask | 1 << transform.gameObject.layer))) return false;
if (transform.CompareTag("EditorOnly")) return false;
if (transform.GetComponent<IGLTFSceneExportGuard>() != null) return false;

return true;
}

Expand Down