Beispiel #1
0
 public void DeActiveHUDGroup(HUDGroup group)
 {
     if (group.mesh != null)
     {
         pool.Push(group.mesh);
         group.mesh = null;
     }
 }
Beispiel #2
0
        public void RegisterHUDGroupRebuildMesh(HUDGroup group)
        {
            if (group_rebuild_mesh.Contains(group))
            {
                return;
            }

            group_rebuild_mesh.Add(group);
        }
Beispiel #3
0
 public void ActiveHUDGroup(HUDGroup group)
 {
     if (group.mesh == null)
     {
         if (pool.Count == 0)
         {
             group.mesh = new Mesh();
             group.mesh.MarkDynamic();
         }
         else
         {
             group.mesh = pool.Pop();
         }
     }
 }
        public void CollectionMeshfInfo(HUDGroup group)
        {
            CheckCapacity(group.items.Count);
            CollectionMeshInfoOffset offset = new CollectionMeshInfoOffset()
            {
                group = group.unique_id
            };
            int count           = 0;
            int mesh_quad_count = 0;

            offset.offset = transform_indices.Length;
            foreach (var itm in group.items)
            {
                if (itm.build_data_index < 0 || itm.batch == null)
                {
                    continue;
                }

                if (itm.batch.buffer_info.transform_job_datas[itm.build_data_index].is_active == 0)
                {
                    continue;
                }

                transform_indices.Add(new TransformIndex()
                {
                    index              = itm.build_data_index,
                    quad_count         = (int)itm.size,
                    buffer_offset      = itm.batch.buffer_info.info.offset,
                    quad_buffer_offset = itm.batch.buffer_info.info.quad_offset
                });
                count++;
                mesh_quad_count += itm.valid_quad;
            }

            offset.length = count;
            //if(offset.length > 0)
            {
                indeices_offset.Add(offset);
                offset.out_index = output_index;
                output_index++;
                building_group.Add(group.unique_id, group);
            }
            if (mesh_quad_count > max_mesh_quad_count)
            {
                max_mesh_quad_count = mesh_quad_count;
            }
        }
Beispiel #5
0
 public static void InnerDepthSort(HUDGroup group)
 {
     group.items.Sort((lg, rg) => { return(lg.local_position.z.CompareTo(rg.local_position.z)); });
 }
        public void FinishUpdateMesh()
        {
            if (!is_job_valid)
            {
                return;
            }
            CompleteJob();

            var a_out_poices  = out_poices.AsArray();
            var a_out_uv0     = out_uv0.AsArray();
            var a_out_uv1     = out_uv1.AsArray();
            var a_out_colors  = out_colors.AsArray();
            var a_out_indices = out_indices.AsArray();

            int count = indeices_offset.Length;

            for (int i = 0; i < count; ++i)
            {
                var      info  = indeices_offset[i];
                HUDGroup group = null;
                if (!building_group.TryGetValue(info.group, out group))
                {
                    continue;
                }

                var mesh = group.mesh;
                if (mesh == null)
                {
                    // 说明group 被销毁或隐藏了
                    continue;
                }

                int out_quad_count = info.length;
                var mesh_info      = group.mesh_info;
                // 检查下大小
                if (out_quad_count > mesh_info.quad_count)
                {
                    mesh_info.Resize(out_quad_count);
                }

                int v_count = out_quad_count * 4;
                int i_count = out_quad_count * 6;
                mesh.Clear();
#if UNITY_2019_3_OR_NEWER
                mesh.SetVertices(a_out_poices, info.v_index, v_count);
                mesh.SetUVs(0, a_out_uv0, info.v_index, v_count);
                mesh.SetUVs(1, a_out_uv1, info.v_index, v_count);
                mesh.SetColors(a_out_colors, info.v_index, v_count);
                mesh.SetIndices(a_out_indices, info.i_index, i_count, MeshTopology.Triangles, 0);
#else
                NativeArray <Vector3> .Copy(a_out_poices, info.v_index, mesh_info.poices, 0, v_count);

                NativeArray <Vector2> .Copy(a_out_uv0, info.v_index, mesh_info.uv0, 0, v_count);

                NativeArray <Vector2> .Copy(a_out_uv1, info.v_index, mesh_info.uv1, 0, v_count);

                NativeArray <Color32> .Copy(a_out_colors, info.v_index, mesh_info.colors, 0, v_count);

                NativeArray <int> .Copy(a_out_indices, info.i_index, mesh_info.indices, 0, i_count);

                int index_length = mesh_info.indices.Length;
                for (int t = i_count; t < index_length; ++t)
                {
                    mesh_info.indices[t] = 0;
                }

                mesh.vertices  = mesh_info.poices;
                mesh.uv        = mesh_info.uv0;
                mesh.uv2       = mesh_info.uv1;
                mesh.colors32  = mesh_info.colors;
                mesh.triangles = mesh_info.indices;
#endif
            }
        }
Beispiel #7
0
 public void Attach(HUDGroup group)
 {
     target_group = group;
     OnAttch();
     target_group.OnComponentAttach(self_graphics);
 }