示例#1
0
        static bool GetMeshForPBComponent(ModelExporter exporter, ProBuilderMesh pmesh, Autodesk.Fbx.FbxNode node)
        {
            Mesh mesh = new Mesh();

            MeshUtility.Compile(pmesh, mesh, s_FbxOptions.quads ? MeshTopology.Quads : MeshTopology.Triangles);

            var pMeshRenderer   = pmesh.GetComponent <MeshRenderer>();
            var sharedMaterials = pMeshRenderer ? pMeshRenderer.sharedMaterials : null;

            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();

            if (exporterType == typeof(ConvertToPrefabSettingsSerialize))
            {
                // probuilder can't handle mesh assets that may be externally reloaded, just strip pb stuff for now.
                StripProBuilderScripts.DoStrip(pmesh);
            }

            return(true);
        }
    public void StripProBuilderScripts_RemovesMeshAndShapeComponents()
    {
        var go    = new GameObject();
        var shape = go.AddComponent <ProBuilderShape>();

        shape.Rebuild(new Bounds(Vector3.zero, Vector3.one), Quaternion.identity, Vector3.zero);

        Assume.That(go.GetComponent <ProBuilderMesh>() != null);
        Assume.That(go.GetComponent <ProBuilderShape>() != null);

        StripProBuilderScripts.DoStrip(go.GetComponent <ProBuilderMesh>());

        Assert.That(go.GetComponent <ProBuilderMesh>() == null);
        Assert.That(go.GetComponent <ProBuilderShape>() == null);

        UObject.DestroyImmediate(go);
    }
示例#3
0
    public void StripProBuilderScripts_RemovesMeshAndPolyShapeComponents()
    {
        var go   = new GameObject();
        var poly = go.AddComponent <PolyShape>();

        go.AddComponent <ProBuilderMesh>();
        poly.CreateShapeFromPolygon();

        Assume.That(go.GetComponent <ProBuilderMesh>() != null);
        Assume.That(go.GetComponent <PolyShape>() != null);

        StripProBuilderScripts.DoStrip(go.GetComponent <ProBuilderMesh>());

        Assert.That(go.GetComponent <ProBuilderMesh>() == null);
        Assert.That(go.GetComponent <PolyShape>() == null);

        UObject.DestroyImmediate(go);
    }
示例#4
0
    public void StripProBuilderScripts_RemovesMeshAndBezierComponents()
    {
        var go = new GameObject();

        go.AddComponent <ProBuilderMesh>();
        var bezier = go.AddComponent <BezierShape>();

        bezier.Init();
        bezier.Refresh();

        Assume.That(go.GetComponent <ProBuilderMesh>() != null);
        Assume.That(go.GetComponent <BezierShape>() != null);

        StripProBuilderScripts.DoStrip(go.GetComponent <ProBuilderMesh>());

        Assert.That(go.GetComponent <ProBuilderMesh>() == null);
        Assert.That(go.GetComponent <BezierShape>() == null);

        UObject.DestroyImmediate(go);
    }