コード例 #1
0
        private void MoveTo(Vector3 to)
        {
            Vector3 from   = Position;
            Vector3 offset = to - from;

            bool wasMoveInProgress = m_isMoveInProgress;

            if (!wasMoveInProgress)
            {
                BeginMove();
            }

            foreach (KeyValuePair <ProBuilderMesh, IList <Face> > kvp in m_meshes)
            {
                ProBuilderMesh mesh        = kvp.Key;
                Vector3        localOffset = mesh.transform.InverseTransformVector(offset);

                IList <Face> faces = kvp.Value;
                mesh.TranslateVertices(faces, localOffset);

                mesh.ToMesh();
                mesh.Refresh();
            }
            m_faceSelection.Synchronize(
                m_faceSelection.CenterOfMass + offset,
                m_faceSelection.LastPosition + offset);

            RaisePBMeshesChanged(true);

            if (!wasMoveInProgress)
            {
                EndMove();
            }
        }
コード例 #2
0
        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);
            }
        }