public static void DoStrip(ProBuilderMesh pb)
        {
            try
            {
                GameObject go = pb.gameObject;

                Renderer ren = go.GetComponent <Renderer>();

                if (ren != null)
                {
                    EditorUtility.SetSelectionRenderState(ren, EditorSelectedRenderState.Highlight | EditorSelectedRenderState.Wireframe);
                }

                if (EditorUtility.IsPrefabAsset(go))
                {
                    return;
                }

                EditorUtility.SynchronizeWithMeshFilter(pb);

                if (pb.mesh == null)
                {
                    DestroyProBuilderMeshAndDependencies(go, pb, false);
                    return;
                }

                string cachedMeshPath;
                Mesh   cachedMesh;

                // if meshes are assets and the mesh cache is valid don't duplicate the mesh to an instance.
                if (Experimental.meshesAreAssets && EditorMeshUtility.GetCachedMesh(pb, out cachedMeshPath, out cachedMesh))
                {
                    DestroyProBuilderMeshAndDependencies(go, pb, true);
                }
                else
                {
                    Mesh m = UnityEngine.ProBuilder.MeshUtility.DeepCopy(pb.mesh);

                    DestroyProBuilderMeshAndDependencies(go, pb);

                    go.GetComponent <MeshFilter>().sharedMesh = m;
                    if (go.TryGetComponent(out MeshCollider meshCollider))
                    {
                        meshCollider.sharedMesh = m;
                    }
                }
            }
            catch {}
        }
예제 #2
0
        /// <summary>
        /// Hide the default unity wireframe renderer
        /// </summary>
        void SetOverrideWireframe(bool overrideWireframe)
        {
            const EditorSelectedRenderState k_DefaultSelectedRenderState = EditorSelectedRenderState.Highlight | EditorSelectedRenderState.Wireframe;

            foreach (var mesh in Selection.transforms.GetComponents <ProBuilderMesh>())
            {
                // Disable Wireframe for meshes when ProBuilder is active
                EditorUtility.SetSelectionRenderState(
                    mesh.renderer,
                    overrideWireframe
                        ? k_DefaultSelectedRenderState & ~(EditorSelectedRenderState.Wireframe)
                        : k_DefaultSelectedRenderState);

                EditorUtility.SynchronizeWithMeshFilter(mesh);
            }

            SceneView.RepaintAll();
        }
예제 #3
0
        public static void DoStrip(ProBuilderMesh pb)
        {
            try
            {
                GameObject go = pb.gameObject;

                Renderer ren = go.GetComponent <Renderer>();

                if (ren != null)
                {
                    EditorUtility.SetSelectionRenderState(ren, EditorUtility.GetSelectionRenderState());
                }

                if (EditorUtility.IsPrefabAsset(go))
                {
                    return;
                }

                EditorUtility.SynchronizeWithMeshFilter(pb);

                if (pb.mesh == null)
                {
                    DestroyImmediate(pb);

                    if (go.GetComponent <Entity>())
                    {
                        DestroyImmediate(go.GetComponent <Entity>());
                    }

                    return;
                }

                string cachedMeshPath;
                Mesh   cachedMesh;

                // if meshes are assets and the mesh cache is valid don't duplicate the mesh to an instance.
                if (Experimental.meshesAreAssets && EditorMeshUtility.GetCachedMesh(pb, out cachedMeshPath, out cachedMesh))
                {
                    pb.preserveMeshAssetOnDestroy = true;
                    DestroyImmediate(pb);
                    if (go.GetComponent <Entity>())
                    {
                        DestroyImmediate(go.GetComponent <Entity>());
                    }
                }
                else
                {
                    Mesh m = UnityEngine.ProBuilder.MeshUtility.DeepCopy(pb.mesh);

                    DestroyImmediate(pb);

                    if (go.GetComponent <Entity>())
                    {
                        DestroyImmediate(go.GetComponent <Entity>());
                    }

                    go.GetComponent <MeshFilter>().sharedMesh = m;
                    if (go.GetComponent <MeshCollider>())
                    {
                        go.GetComponent <MeshCollider>().sharedMesh = m;
                    }
                }
            }
            catch {}
        }