From 45fed346454e42ec14579c68ff89aaff10567be7 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Mon, 26 Apr 2021 17:39:06 -0400 Subject: [PATCH 01/13] Fix for rect selection incorrectly selecting elements if mesh's parent is rotated and/or scaled --- Runtime/Core/SelectionPickerRenderer.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Runtime/Core/SelectionPickerRenderer.cs b/Runtime/Core/SelectionPickerRenderer.cs index b1a263322..13e803b98 100644 --- a/Runtime/Core/SelectionPickerRenderer.cs +++ b/Runtime/Core/SelectionPickerRenderer.cs @@ -561,6 +561,8 @@ static GameObject[] GenerateFacePickingObjects( go.AddComponent().sharedMesh = m; go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; + go.hideFlags = HideFlags.HideAndDontSave; + go.transform.SetParent(pb.transform.parent, false); pickerObjects[i] = go; } @@ -591,6 +593,9 @@ static void GenerateVertexPickingObjects( go.name = pb.name + " (Vertex Billboards)"; go.AddComponent().sharedMesh = BuildVertexMesh(pb, map, ref index); go.AddComponent().sharedMaterial = BuiltinMaterials.vertexPickerMaterial; + go.hideFlags = HideFlags.HideAndDontSave; + go.transform.SetParent(pb.transform.parent, false); + pickerObjects[i] = go; } @@ -606,6 +611,9 @@ static void GenerateVertexPickingObjects( go.name = pb.name + " (Depth Mask)"; go.AddComponent().sharedMesh = pb.mesh; go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; + go.hideFlags = HideFlags.HideAndDontSave; + go.transform.SetParent(pb.transform.parent, false); + depthObjects[i] = go; } } @@ -636,6 +644,9 @@ static void GenerateEdgePickingObjects( go.name = pb.name + " (Edge Billboards)"; go.AddComponent().sharedMesh = BuildEdgeMesh(pb, map, ref index); go.AddComponent().sharedMaterial = BuiltinMaterials.edgePickerMaterial; + go.hideFlags = HideFlags.HideAndDontSave; + go.transform.SetParent(pb.transform.parent, false); + pickerObjects[i] = go; } @@ -651,6 +662,9 @@ static void GenerateEdgePickingObjects( go.name = pb.name + " (Depth Mask)"; go.AddComponent().sharedMesh = pb.mesh; go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; + go.hideFlags = HideFlags.HideAndDontSave; + go.transform.SetParent(pb.transform.parent, false); + depthObjects[i] = go; } } From 39395108b429e7669e44f49222f49932a09b7525 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Mon, 26 Apr 2021 19:11:47 -0400 Subject: [PATCH 02/13] Fix adjustment and accompanying test --- Runtime/Core/InternalUtility.cs | 2 +- Tests/Editor/Picking/RectSelection.cs | 35 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Runtime/Core/InternalUtility.cs b/Runtime/Core/InternalUtility.cs index 6ff34eecc..d2f79306e 100644 --- a/Runtime/Core/InternalUtility.cs +++ b/Runtime/Core/InternalUtility.cs @@ -39,7 +39,7 @@ public static T[] GetComponents(this IEnumerable transforms) where public static GameObject EmptyGameObjectWithTransform(Transform t) { GameObject go = new GameObject(); - go.transform.position = t.position; + go.transform.localPosition = t.localPosition; go.transform.localRotation = t.localRotation; go.transform.localScale = t.localScale; diff --git a/Tests/Editor/Picking/RectSelection.cs b/Tests/Editor/Picking/RectSelection.cs index adc619be1..9e153c019 100644 --- a/Tests/Editor/Picking/RectSelection.cs +++ b/Tests/Editor/Picking/RectSelection.cs @@ -116,6 +116,41 @@ Dictionary> TestFacePick(PickerOptions options) } } + [Test] + public void PickVertices_RotatedParent_DepthTestOn() + { + // Create a parent container with -90 degree rotation around Z + var parent = new GameObject("Parent"); + parent.transform.position = new Vector3(0f, 0f, 0f); + parent.transform.rotation = Quaternion.Euler(0f, 0f, -90f); + + // Create a Cube such that when parented to the container has (6f, 0f, 0f) world position + var cube = ShapeFactory.Instantiate(); + cube.transform.position = new Vector3(0f, 6f, 0f); + cube.transform.SetParent(parent.transform, false); + + // Create a camera and point it to (6f, 0f, 0) looking directly at one of the Cube's faces + camera = new GameObject("Camera", typeof(Camera)).GetComponent(); + camera.transform.position = new Vector3(6f, 0, -6f); + camera.transform.forward = Vector3.forward; + + selectables = new ProBuilderMesh[] + { + cube + }; + + // Attempt full screen rect selection - this should select the 4 vertices of the quad that the camera's facing + var vertices = TestVertexPick(new PickerOptions() { depthTest = true }); + var selection = vertices.FirstOrDefault(); + Assert.IsNotNull(selection); + HashSet selectedElements = selection.Value; + Assert.That(selectedElements.Count, Is.EqualTo(4)); + + UObject.DestroyImmediate(cube.gameObject); + UObject.DestroyImmediate(parent); + UObject.DestroyImmediate(camera.gameObject); + } + [Test] public void PickVertices_DepthTestOn() { From 5d29a228e09d1fa4db12ef7734a093a1d4c0ad85 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Tue, 27 Apr 2021 12:29:07 -0400 Subject: [PATCH 03/13] Refactoring. Updated change log --- CHANGELOG.md | 1 + Runtime/Core/InternalUtility.cs | 14 +++++++ Runtime/Core/SelectionPickerRenderer.cs | 49 +++++++++---------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 795f42e12..efe335dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Bug Fixes +- [case: 1324374] Fixed incorrect vertex/edge/face rect selection when mesh's parent is rotated and/or scaled. - [case: 1324399] Fixing errors when building with prefabs in scene. - [case: 1323666] Preventing to assign an empty mesh as MeshCollider. - [case: 1322032] Fixing wrong ProBuilderMesh colors on domain reload when null. diff --git a/Runtime/Core/InternalUtility.cs b/Runtime/Core/InternalUtility.cs index d2f79306e..c8d446828 100644 --- a/Runtime/Core/InternalUtility.cs +++ b/Runtime/Core/InternalUtility.cs @@ -50,6 +50,20 @@ public static GameObject EmptyGameObjectWithTransform(Transform t) return go; } + public static GameObject MeshGameObjectWithTransform(string name, Transform t, Mesh mesh, Material mat, bool inheritParent) + { + GameObject go = InternalUtility.EmptyGameObjectWithTransform(t); + go.name = name; + go.AddComponent().sharedMesh = mesh; + go.AddComponent().sharedMaterial = mat; + go.hideFlags = HideFlags.HideAndDontSave; + + if (inheritParent) + go.transform.SetParent(t.parent, false); + + return go; + } + public static T NextEnumValue(this T current) where T : IConvertible { Assert.IsTrue(current is Enum); diff --git a/Runtime/Core/SelectionPickerRenderer.cs b/Runtime/Core/SelectionPickerRenderer.cs index 13e803b98..d4ba20a2a 100644 --- a/Runtime/Core/SelectionPickerRenderer.cs +++ b/Runtime/Core/SelectionPickerRenderer.cs @@ -540,9 +540,6 @@ static GameObject[] GenerateFacePickingObjects( { var pb = selection[i]; - GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform); - go.name = pb.name + " (Face Depth Test)"; - Mesh m = new Mesh(); m.vertices = pb.positionsInternal; m.triangles = pb.facesInternal.SelectMany(x => x.indexesInternal).ToArray(); @@ -559,10 +556,8 @@ static GameObject[] GenerateFacePickingObjects( m.colors32 = colors; - go.AddComponent().sharedMesh = m; - go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; - go.hideFlags = HideFlags.HideAndDontSave; - go.transform.SetParent(pb.transform.parent, false); + GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Face Depth Test)", pb.transform, m, + BuiltinMaterials.facePickerMaterial, true); pickerObjects[i] = go; } @@ -589,12 +584,10 @@ static void GenerateVertexPickingObjects( { // build vertex billboards var pb = selection[i]; - GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform); - go.name = pb.name + " (Vertex Billboards)"; - go.AddComponent().sharedMesh = BuildVertexMesh(pb, map, ref index); - go.AddComponent().sharedMaterial = BuiltinMaterials.vertexPickerMaterial; - go.hideFlags = HideFlags.HideAndDontSave; - go.transform.SetParent(pb.transform.parent, false); + + var mesh = BuildVertexMesh(pb, map, ref index); + GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Vertex Billboards)", pb.transform, mesh, + BuiltinMaterials.vertexPickerMaterial, true); pickerObjects[i] = go; } @@ -607,12 +600,9 @@ static void GenerateVertexPickingObjects( for (int i = 0; i < selectionCount; i++) { var pb = selection[i]; - GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform); - go.name = pb.name + " (Depth Mask)"; - go.AddComponent().sharedMesh = pb.mesh; - go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; - go.hideFlags = HideFlags.HideAndDontSave; - go.transform.SetParent(pb.transform.parent, false); + + GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Depth Mask)", pb.transform, pb.mesh, + BuiltinMaterials.facePickerMaterial, true); depthObjects[i] = go; } @@ -640,12 +630,10 @@ static void GenerateEdgePickingObjects( { // build edge billboards var pb = selection[i]; - GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform); - go.name = pb.name + " (Edge Billboards)"; - go.AddComponent().sharedMesh = BuildEdgeMesh(pb, map, ref index); - go.AddComponent().sharedMaterial = BuiltinMaterials.edgePickerMaterial; - go.hideFlags = HideFlags.HideAndDontSave; - go.transform.SetParent(pb.transform.parent, false); + + var mesh = BuildEdgeMesh(pb, map, ref index); + GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Edge Billboards)", pb.transform, mesh, + BuiltinMaterials.edgePickerMaterial, true); pickerObjects[i] = go; } @@ -657,14 +645,11 @@ static void GenerateEdgePickingObjects( for (int i = 0; i < selectionCount; i++) { var pb = selection[i]; + // copy the select gameobject just for z-write - GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform); - go.name = pb.name + " (Depth Mask)"; - go.AddComponent().sharedMesh = pb.mesh; - go.AddComponent().sharedMaterial = BuiltinMaterials.facePickerMaterial; - go.hideFlags = HideFlags.HideAndDontSave; - go.transform.SetParent(pb.transform.parent, false); - + GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Depth Mask)", pb.transform, pb.mesh, + BuiltinMaterials.facePickerMaterial, true); + depthObjects[i] = go; } } From 0f5b0dd8fc8126e52b4dc3fdbb7c5b70147ff609 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Tue, 27 Apr 2021 12:54:28 -0400 Subject: [PATCH 04/13] Changelog fix --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ace8cd7..c9e9cd994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [5.0.3] - 2021-04-01 +## [Unreleased] ### Bug Fixes - [case: 1324374] Fixed incorrect vertex/edge/face rect selection when mesh's parent is rotated and/or scaled. + +## [5.0.3] - 2021-04-01 + +### Bug Fixes + - [case: 1324399] Fixing errors when building with prefabs in scene. - [case: 1323666] Preventing to assign an empty mesh as MeshCollider. - [case: 1322032] Fixing wrong ProBuilderMesh colors on domain reload when null. From 587eab332fdb81f0d08f166ad81d89f8a80efe08 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Wed, 28 Apr 2021 10:44:48 -0400 Subject: [PATCH 05/13] Adding a validationExceptions.json to pass Package Validation Suite's CoreModule failures on 2020.1 and 2019.1 --- validationExceptions.json | 9 +++++++++ validationExceptions.json.meta | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 validationExceptions.json create mode 100644 validationExceptions.json.meta diff --git a/validationExceptions.json b/validationExceptions.json new file mode 100644 index 000000000..7c617fb91 --- /dev/null +++ b/validationExceptions.json @@ -0,0 +1,9 @@ +{ + "Exceptions": + [ + { + "ValidationTest": "API Validation", + "PackageVersion": "5.0.3" + } + ] +} \ No newline at end of file diff --git a/validationExceptions.json.meta b/validationExceptions.json.meta new file mode 100644 index 000000000..4392f0186 --- /dev/null +++ b/validationExceptions.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a1430a41101d44a61a313b6897f438c0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 904d2245570532fde5c56da534dfc39ba01ed101 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Thu, 29 Apr 2021 08:27:27 -0400 Subject: [PATCH 06/13] Fix for missing Gizmos menu items in projects where ProBuilder package is installed --- Editor/EditorCore/HierarchyListener.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Editor/EditorCore/HierarchyListener.cs b/Editor/EditorCore/HierarchyListener.cs index 51c609557..aa98dba16 100644 --- a/Editor/EditorCore/HierarchyListener.cs +++ b/Editor/EditorCore/HierarchyListener.cs @@ -12,14 +12,7 @@ static class HierarchyListener { static HierarchyListener() { - // The inspector icon for ProBuilderMesh is set in the component metadata. However, this also serves as the - // scene view gizmo icon, which we do not want. To avoid drawing an icon for every mesh in the Scene View, - // we simply tell the AnnotationManager to not render the icon. This _does_ put ProBuilderMesh in the - // "Recently Changed" list, but only when it is modified the first time. - // The alternative method of setting an icon is to place it in a folder named "Editor Default Resources/Icons", - // however that requires that the resources directory be in "Assets", which we do not want to do. - EditorUtility.SetGizmoIconEnabled(typeof(ProBuilderMesh), false); - + AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload; // When a prefab is updated, this is raised. For some reason it's // called twice? EditorApplication.hierarchyChanged += HierarchyWindowChanged; @@ -29,6 +22,17 @@ static HierarchyListener() PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated; } + static void OnAfterAssemblyReload() + { + // The inspector icon for ProBuilderMesh is set in the component metadata. However, this also serves as the + // scene view gizmo icon, which we do not want. To avoid drawing an icon for every mesh in the Scene View, + // we simply tell the AnnotationManager to not render the icon. This _does_ put ProBuilderMesh in the + // "Recently Changed" list, but only when it is modified the first time. + // The alternative method of setting an icon is to place it in a folder named "Editor Default Resources/Icons", + // however that requires that the resources directory be in "Assets", which we do not want to do. + EditorApplication.delayCall += () => EditorUtility.SetGizmoIconEnabled(typeof(ProBuilderMesh), false); + } + static void PrefabInstanceUpdated(GameObject go) { if (EditorApplication.isPlayingOrWillChangePlaymode) From 6e4f32095d64d9187539594f3392a8853e013e7b Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Thu, 29 Apr 2021 08:59:29 -0400 Subject: [PATCH 07/13] Changelog update --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e36981fa..a9ab88419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Bug Fixes + +- [case: 1332226] Fixed issue where some Gizmos menu items would be missing in projects that have ProBuilder package installed. + ## [5.0.3] - 2021-04-01 ### Bug Fixes From d9f8ae0596cffd0134014ac9ba936baaadfaf681 Mon Sep 17 00:00:00 2001 From: Mod Rimkus Date: Wed, 28 Apr 2021 10:44:48 -0400 Subject: [PATCH 08/13] Adding a validationExceptions.json to pass Package Validation Suite's CoreModule failures on 2020.1 and 2019.1 --- validationExceptions.json | 9 +++++++++ validationExceptions.json.meta | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 validationExceptions.json create mode 100644 validationExceptions.json.meta diff --git a/validationExceptions.json b/validationExceptions.json new file mode 100644 index 000000000..7c617fb91 --- /dev/null +++ b/validationExceptions.json @@ -0,0 +1,9 @@ +{ + "Exceptions": + [ + { + "ValidationTest": "API Validation", + "PackageVersion": "5.0.3" + } + ] +} \ No newline at end of file diff --git a/validationExceptions.json.meta b/validationExceptions.json.meta new file mode 100644 index 000000000..4392f0186 --- /dev/null +++ b/validationExceptions.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a1430a41101d44a61a313b6897f438c0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From e07e23f0b68491ac476e4ba229551c3ed42d0dec Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 19 May 2021 15:44:21 -0400 Subject: [PATCH 09/13] Fixing PBShape export using FBX Exporter --- Addons/Fbx.cs | 28 +++++++++++----------------- CHANGELOG.md | 1 + 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Addons/Fbx.cs b/Addons/Fbx.cs index acc835a14..4961a07bf 100644 --- a/Addons/Fbx.cs +++ b/Addons/Fbx.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Linq; using UnityEditor.ProBuilder; +using UnityEditor.ProBuilder.Actions; namespace UnityEngine.ProBuilder.Addons.FBX { @@ -40,13 +41,6 @@ private static Assembly FbxExporterAssembly } } } - - static readonly Type[] k_ProBuilderTypes = new Type[] - { - typeof(BezierShape), - typeof(PolyShape), - typeof(Entity) - }; static FbxOptions m_FbxOptions = new FbxOptions() { quads = true @@ -71,12 +65,12 @@ static void TryLoadFbxSupport() var getMeshForComponent = FbxExporterAssembly.GetTypes() .Where(t => t.BaseType == typeof(MulticastDelegate) && t.Name.StartsWith("GetMeshForComponent")) .First(t => t.ContainsGenericParameters); - + getMeshForComponent = getMeshForComponent.MakeGenericType(typeof(ProBuilderMesh)); var meshDelegate = Delegate.CreateDelegate(getMeshForComponent, typeof(Fbx).GetMethod("GetMeshForComponent", BindingFlags.NonPublic | BindingFlags.Static)); registerMeshCallback.Invoke(null, new object[] { meshDelegate, true }); - + m_FbxOptions.quads = ProBuilderSettings.Get("Export::m_FbxQuads", SettingsScope.User, true); } @@ -93,17 +87,17 @@ static bool GetMeshForComponent(object exporter, ProBuilderMesh pmesh, object no Object.DestroyImmediate(mesh); - // probuilder can't handle mesh assets that may be externally reloaded, just strip pb stuff for now. - foreach (var type in k_ProBuilderTypes) + var exporterType = exporter.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) + .First(x => x.Name == "get_ExportOptions").Invoke(exporter, null).GetType(); + + var prefabExporterType = FbxExporterAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ConvertToPrefabSettingsSerialize"); + + if(exporterType == prefabExporterType) { - var component = pmesh.GetComponent(type); - if (component != null) - Object.DestroyImmediate(component); + // probuilder can't handle mesh assets that may be externally reloaded, just strip pb stuff for now. + StripProBuilderScripts.DoStrip(pmesh); } - pmesh.preserveMeshAssetOnDestroy = true; - Object.DestroyImmediate(pmesh); - return true; } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a14a71cc..2cc9c03f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Bug Fixes +- [case: 1334017] Fixed errors while exporting a PBShape using FBX Exporter and cleaning export. - [case: 1332226] Fixed issue where some Gizmos menu items would be missing in projects that have ProBuilder package installed. - [case: 1324374] Fixed incorrect vertex/edge/face rect selection when mesh's parent is rotated and/or scaled. From 6788fc79e59dc39fcc439078129f4997eaee0474 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 19 May 2021 17:33:25 -0400 Subject: [PATCH 10/13] moving to optional dependency for FBX Export --- Addons/Fbx.cs | 59 +++++--------------- Addons/Unity.ProBuilder.AddOns.Editor.asmdef | 19 +++++-- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/Addons/Fbx.cs b/Addons/Fbx.cs index 4961a07bf..0c30e65cc 100644 --- a/Addons/Fbx.cs +++ b/Addons/Fbx.cs @@ -1,8 +1,9 @@ -// todo Once we drop support for 2018.3, use optional assembly definitions -using System; +#if FBX_EXPORTER + using UnityEditor; using System.Reflection; using System.Linq; +using UnityEditor.Formats.Fbx.Exporter; using UnityEditor.ProBuilder; using UnityEditor.ProBuilder.Actions; @@ -27,22 +28,7 @@ class FbxOptions [InitializeOnLoad] static class Fbx { - private static Assembly FbxExporterAssembly - { - get - { - try - { - return Assembly.Load("Unity.Formats.Fbx.Editor"); - } - catch (System.IO.FileNotFoundException) - { - return null; - } - } - } - - static FbxOptions m_FbxOptions = new FbxOptions() { + static FbxOptions s_FbxOptions = new FbxOptions() { quads = true }; @@ -53,46 +39,27 @@ static Fbx() static void TryLoadFbxSupport() { - if (FbxExporterAssembly == null) - { - return; - } - - var modelExporter = FbxExporterAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ModelExporter"); - var registerMeshCallback = modelExporter.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(x => x.Name == "RegisterMeshCallback").First(x => x.ContainsGenericParameters); - registerMeshCallback = registerMeshCallback.MakeGenericMethod(typeof(ProBuilderMesh)); - - var getMeshForComponent = FbxExporterAssembly.GetTypes() - .Where(t => t.BaseType == typeof(MulticastDelegate) && t.Name.StartsWith("GetMeshForComponent")) - .First(t => t.ContainsGenericParameters); - - getMeshForComponent = getMeshForComponent.MakeGenericType(typeof(ProBuilderMesh)); - var meshDelegate = Delegate.CreateDelegate(getMeshForComponent, typeof(Fbx).GetMethod("GetMeshForComponent", BindingFlags.NonPublic | BindingFlags.Static)); - - registerMeshCallback.Invoke(null, new object[] { meshDelegate, true }); - - m_FbxOptions.quads = ProBuilderSettings.Get("Export::m_FbxQuads", SettingsScope.User, true); + ModelExporter.RegisterMeshCallback(GetMeshForPBComponent, true); + s_FbxOptions.quads = ProBuilderSettings.Get("Export::m_FbxQuads", SettingsScope.User, true); } - static bool GetMeshForComponent(object exporter, ProBuilderMesh pmesh, object node) + static bool GetMeshForPBComponent(ModelExporter exporter, ProBuilderMesh pmesh, Autodesk.Fbx.FbxNode node) { Mesh mesh = new Mesh(); - MeshUtility.Compile(pmesh, mesh, m_FbxOptions.quads ? MeshTopology.Quads : MeshTopology.Triangles); + MeshUtility.Compile(pmesh, mesh, s_FbxOptions.quads ? MeshTopology.Quads : MeshTopology.Triangles); - // using reflection to call: exporter.ExportMesh(mesh, node, pmesh.GetComponent().sharedMaterials) var pMeshRenderer = pmesh.GetComponent(); var sharedMaterials = pMeshRenderer ? pMeshRenderer.sharedMaterials : null; - var exportMeshMethod = exporter.GetType().GetMethod("ExportMesh", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Mesh), node.GetType(), typeof(Material[]) }, null); - exportMeshMethod.Invoke(exporter, new object[] { mesh, node, sharedMaterials }); + + exporter.ExportMesh(mesh, node, sharedMaterials); Object.DestroyImmediate(mesh); + //Need to have ExportOptions accessible to remove this reflection var exporterType = exporter.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) .First(x => x.Name == "get_ExportOptions").Invoke(exporter, null).GetType(); - var prefabExporterType = FbxExporterAssembly.GetType("UnityEditor.Formats.Fbx.Exporter.ConvertToPrefabSettingsSerialize"); - - if(exporterType == prefabExporterType) + if(exporterType == typeof(ConvertToPrefabSettingsSerialize)) { // probuilder can't handle mesh assets that may be externally reloaded, just strip pb stuff for now. StripProBuilderScripts.DoStrip(pmesh); @@ -102,3 +69,5 @@ static bool GetMeshForComponent(object exporter, ProBuilderMesh pmesh, object no } } } + +#endif diff --git a/Addons/Unity.ProBuilder.AddOns.Editor.asmdef b/Addons/Unity.ProBuilder.AddOns.Editor.asmdef index f1e18cd20..68b428d0b 100644 --- a/Addons/Unity.ProBuilder.AddOns.Editor.asmdef +++ b/Addons/Unity.ProBuilder.AddOns.Editor.asmdef @@ -1,10 +1,12 @@ { "name": "Unity.ProBuilder.AddOns.Editor", + "rootNamespace": "", "references": [ "Unity.ProBuilder", - "Unity.ProBuilder.Editor" + "Unity.ProBuilder.Editor", + "Unity.Formats.Fbx.Editor", + "Autodesk.Fbx" ], - "optionalUnityReferences": [], "includePlatforms": [ "Editor" ], @@ -12,5 +14,14 @@ "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], - "autoReferenced": true -} + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.formats.fbx", + "expression": "4.0.0", + "define": "FBX_EXPORTER" + } + ], + "noEngineReferences": false +} \ No newline at end of file From 4ef06e632263178ee7e17d9b77e57f68b1dab720 Mon Sep 17 00:00:00 2001 From: "thomas.lopez" Date: Tue, 8 Jun 2021 15:14:17 -0400 Subject: [PATCH 11/13] update package to 5.0.4 --- CHANGELOG.md | 2 +- README.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cc9c03f1..139b72c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [5.0.4] - 2021-06-08 ### Bug Fixes diff --git a/README.md b/README.md index a0478fd6a..96f4f74d2 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ mesh.Optimize(); ## Third Party Licenses -[Third Party Licenses](https://github.com/Unity-Technologies/com.unity.probuilder/blob/master/com.unity.probuilder/Third%20Party%20Notices.md) +[Third Party Licenses](https://github.com/Unity-Technologies/com.unity.probuilder/blob/master/Third%20Party%20Notices.md) ## Contributing diff --git a/package.json b/package.json index 24ab8073e..3f60eb3c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.probuilder", "displayName": "ProBuilder", - "version": "5.0.3", + "version": "5.0.4", "unity": "2019.4", "description": "Build, edit, and texture custom geometry in Unity. Use ProBuilder for in-scene level design, prototyping, collision meshes, all with on-the-fly play-testing.\n\nAdvanced features include UV editing, vertex colors, parametric shapes, and texture blending. With ProBuilder's model export feature it's easy to tweak your levels in any external 3D modelling suite.\n\nIf you are using URP/HDRP, be careful to also import the corresponding sample project in the section below to get the proper materials.", "keywords": [ From be9f5b20ebf38307487b674d12d1d09d693839f0 Mon Sep 17 00:00:00 2001 From: "thomas.lopez" Date: Tue, 15 Jun 2021 15:06:39 -0400 Subject: [PATCH 12/13] removing validation exceptions file --- validationExceptions.json | 9 --------- validationExceptions.json.meta | 7 ------- 2 files changed, 16 deletions(-) delete mode 100644 validationExceptions.json delete mode 100644 validationExceptions.json.meta diff --git a/validationExceptions.json b/validationExceptions.json deleted file mode 100644 index 7c617fb91..000000000 --- a/validationExceptions.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Exceptions": - [ - { - "ValidationTest": "API Validation", - "PackageVersion": "5.0.3" - } - ] -} \ No newline at end of file diff --git a/validationExceptions.json.meta b/validationExceptions.json.meta deleted file mode 100644 index 4392f0186..000000000 --- a/validationExceptions.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a1430a41101d44a61a313b6897f438c0 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From fcb74be3d9583d70eead08719685c8e187be2e2b Mon Sep 17 00:00:00 2001 From: "thomas.lopez" Date: Wed, 16 Jun 2021 13:59:47 -0400 Subject: [PATCH 13/13] Updating validation exception for tests --- validationExceptions.json | 9 +++++++++ validationExceptions.json.meta | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 validationExceptions.json create mode 100644 validationExceptions.json.meta diff --git a/validationExceptions.json b/validationExceptions.json new file mode 100644 index 000000000..a826c066c --- /dev/null +++ b/validationExceptions.json @@ -0,0 +1,9 @@ +{ + "Exceptions": + [ + { + "ValidationTest": "API Validation", + "PackageVersion": "5.0.4" + } + ] +} \ No newline at end of file diff --git a/validationExceptions.json.meta b/validationExceptions.json.meta new file mode 100644 index 000000000..4392f0186 --- /dev/null +++ b/validationExceptions.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a1430a41101d44a61a313b6897f438c0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: