收藏
回答

在IOS 小游戏环境下 动态修改 mesh vertices(每帧——元素运动)发现网格绘制异常

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小游戏 Bug iOS 18.6.2 iphone12 8.0.61
          private Material material;
        protected void ApplyMesh(Vector3[] verts, Vector4[] uv, Color[] colors, List<int> triangles, Bounds bounds, Material material = null) {
            this.material = material == null ? SharedMaterial : material;
            if (m_SharedMesh == null) {
                m_SharedMesh = new Mesh();
                m_SharedMesh.name = this.GetType().Name;
                m_SharedMesh.MarkDynamic();
            }
            if (m_SharedTexture != null) SharedMaterial.mainTexture = m_SharedTexture;
            m_SharedMesh.bounds = bounds;
            m_SharedMesh.SetVertices(verts);
            m_SharedMesh.SetNormals(normals);
            m_SharedMesh.SetUVs(0, uv);

            if (colors != null && colors.Length > 0)
                m_SharedMesh.SetColors(colors);
                  m_SharedMesh.SetTriangles(triangles, 0);
        }

        public void Graphic(Material material = null) {
            if (m_SharedMesh == null) return;
            Material mat = material == null ? SharedMaterial : material;
            Graphics.DrawMesh(m_SharedMesh, transform.position, Quaternion.identity, mat, 0);
        }

回答关注问题邀请回答
收藏
登录 后发表内容