Exemplo n.º 1
0
        public static void Init(PBMesh mesh, Vector2 scale)
        {
            if (mesh.m_pbMesh != null)
            {
                return;
            }

            mesh.m_meshFilter = mesh.GetComponent <MeshFilter>();
            mesh.m_pbMesh     = mesh.GetComponent <ProBuilderMesh>();
            if (mesh.m_pbMesh == null)
            {
                mesh.m_pbMesh = mesh.gameObject.AddComponent <ProBuilderMesh>();
                if (mesh.m_positions != null)
                {
                    Face[] faces = mesh.m_faces.Select(f => f.ToFace()).ToArray();
                    mesh.m_pbMesh.Rebuild(mesh.m_positions, faces, mesh.m_textures);

                    IList <Face> actualFaces = mesh.m_pbMesh.faces;
                    for (int i = 0; i < actualFaces.Count; ++i)
                    {
                        actualFaces[i].submeshIndex = mesh.m_faces[i].SubmeshIndex;
                    }

                    mesh.m_pbMesh.Refresh();
                    mesh.m_pbMesh.ToMesh();
                }
                else
                {
                    ImportMesh(mesh.m_meshFilter, mesh.m_pbMesh, scale);
                }
            }
        }
        private void Awake()
        {
            m_target = GetComponent <PBMesh>();
            if (!m_target)
            {
                m_target = gameObject.AddComponent <PBMesh>();
            }

            m_targetMesh = m_target.GetComponent <ProBuilderMesh>();
        }
Exemplo n.º 3
0
        private void Awake()
        {
            foreach (Transform child in transform)
            {
                Destroy(child.gameObject);
            }

            m_target = GetComponent <PBMesh>();
            if (!m_target)
            {
                m_target = gameObject.AddComponent <PBMesh>();
            }

            m_targetMesh = m_target.GetComponent <ProBuilderMesh>();
            if (IsEditing)
            {
                BeginEdit();
            }
        }