From c72e91fe8355dea16161855085ec5a2f203877d7 Mon Sep 17 00:00:00 2001 From: Richard Possnett <95437308+dbb789@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:33:52 +0000 Subject: [PATCH 1/2] Add GLTFSceneExportGuard / fix issue with layer mask check --- Runtime/Scripts/GLTFSceneExportGuard.cs | 9 +++++++++ Runtime/Scripts/GLTFSceneExportGuard.cs.meta | 11 +++++++++++ Runtime/Scripts/GLTFSceneExporter.cs | 13 +++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Runtime/Scripts/GLTFSceneExportGuard.cs create mode 100644 Runtime/Scripts/GLTFSceneExportGuard.cs.meta diff --git a/Runtime/Scripts/GLTFSceneExportGuard.cs b/Runtime/Scripts/GLTFSceneExportGuard.cs new file mode 100644 index 000000000..5e0bc3941 --- /dev/null +++ b/Runtime/Scripts/GLTFSceneExportGuard.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UnityGLTF +{ + // Empty implementation of IGLTFSceneExportGuard for use with editor. + public class GLTFSceneExportGuard : MonoBehaviour, IGLTFSceneExportGuard + { + } +} diff --git a/Runtime/Scripts/GLTFSceneExportGuard.cs.meta b/Runtime/Scripts/GLTFSceneExportGuard.cs.meta new file mode 100644 index 000000000..e24b5f36b --- /dev/null +++ b/Runtime/Scripts/GLTFSceneExportGuard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42e734434e468b447a31d9cc5da41ccf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Scripts/GLTFSceneExporter.cs b/Runtime/Scripts/GLTFSceneExporter.cs index 38b712ff3..9399d52d6 100644 --- a/Runtime/Scripts/GLTFSceneExporter.cs +++ b/Runtime/Scripts/GLTFSceneExporter.cs @@ -95,6 +95,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 { @@ -967,9 +973,12 @@ 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; - return true; + if (transform.GetComponent() != null) return false; + + return true; } private SceneId ExportScene(string name, Transform[] rootObjTransforms) From cf54dbe47518b18eae036bf97d1667d73355205d Mon Sep 17 00:00:00 2001 From: Richard Possnett <95437308+dbb789@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:40:28 +0000 Subject: [PATCH 2/2] Switch from spaces to tabs as per coding style elsewhere --- Runtime/Scripts/GLTFSceneExportGuard.cs | 4 ++-- Runtime/Scripts/GLTFSceneExporter.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Runtime/Scripts/GLTFSceneExportGuard.cs b/Runtime/Scripts/GLTFSceneExportGuard.cs index 5e0bc3941..9fe7485f0 100644 --- a/Runtime/Scripts/GLTFSceneExportGuard.cs +++ b/Runtime/Scripts/GLTFSceneExportGuard.cs @@ -2,8 +2,8 @@ namespace UnityGLTF { - // Empty implementation of IGLTFSceneExportGuard for use with editor. + // Empty implementation of IGLTFSceneExportGuard for use with editor. public class GLTFSceneExportGuard : MonoBehaviour, IGLTFSceneExportGuard { - } + } } diff --git a/Runtime/Scripts/GLTFSceneExporter.cs b/Runtime/Scripts/GLTFSceneExporter.cs index 9399d52d6..f4137c241 100644 --- a/Runtime/Scripts/GLTFSceneExporter.cs +++ b/Runtime/Scripts/GLTFSceneExporter.cs @@ -95,11 +95,11 @@ 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 - { - // - } + // 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 @@ -976,9 +976,9 @@ private bool ShouldExportTransform(Transform transform) if (settings.UseMainCameraVisibility && (_exportLayerMask != 0 && _exportLayerMask != (_exportLayerMask | 1 << transform.gameObject.layer))) return false; if (transform.CompareTag("EditorOnly")) return false; - if (transform.GetComponent() != null) return false; + if (transform.GetComponent() != null) return false; - return true; + return true; } private SceneId ExportScene(string name, Transform[] rootObjTransforms)