Example #1
0
        public override void BeginMove()
        {
            m_isMoveInProgress = true;
            m_meshes           = new Dictionary <ProBuilderMesh, IList <Face> >();
            IEnumerable <ProBuilderMesh> meshes = m_faceSelection.Meshes;

            foreach (ProBuilderMesh mesh in meshes)
            {
                IList <Face> faces = new List <Face>();
                mesh.GetFaces(m_faceSelection.GetFaces(mesh), faces);
                m_meshes.Add(mesh, faces);
            }
        }
        public override void Extrude(float distance)
        {
            m_faceSelection.BeginChange();

            ProBuilderMesh[] meshes = m_faceSelection.Meshes.OrderBy(m => m == m_faceSelection.LastMesh).ToArray();
            foreach (ProBuilderMesh mesh in meshes)
            {
                IList <Face> faces = m_faceSelection.GetFaces(mesh).ToArray();
                for (int i = 0; i < faces.Count; ++i)
                {
                    m_faceSelection.Remove(faces[i]);
                }

                mesh.Extrude(faces, ExtrudeMethod.FaceNormal, distance);

                for (int i = 0; i < faces.Count; ++i)
                {
                    m_faceSelection.Add(mesh, faces[i]);
                }

                mesh.ToMesh();
                mesh.Refresh();
            }

            m_faceSelection.EndChange();

            if (distance != 0.0f)
            {
                m_faceSelection.Synchronize(
                    m_faceSelection.GetCenterOfMass(),
                    m_faceSelection.LastPosition + m_faceSelection.LastNormal * distance);
            }
        }