Пример #1
0
        public void GenerateFromDynamicMesh(BuildRMesh overflow = null)
        {
            HUtils.log();

            if (_dynamicMesh.vertexCount == 0)
            {
                return;
            }
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            if (_filter == null)
            {
                _filter = gameObject.AddComponent <MeshFilter>();
            }
            if (_renderer == null)
            {
                _renderer = gameObject.AddComponent <MeshRenderer>();
            }
            if (overflow != null)
            {
                _dynamicMesh = overflow;
            }
            _dynamicMesh.Build(_mesh);
            _filter.sharedMesh        = _mesh;
            _renderer.sharedMaterials = _dynamicMesh.materials.ToArray();


            if (_dynamicMesh.hasOverflowed)
            {
                if (_sibling == null)
                {
                    _sibling = GetPoolItem();
                }
                _sibling.GenerateFromDynamicMesh(_dynamicMesh.overflow);
            }
            else
            {
                if (_sibling != null)
                {
                    _sibling.Deactivate();
                    VisualPartRuntimePool.Instance.Push(_sibling);
                }
                _sibling = null;
            }

            if (_colliderPart == null)
            {
                _colliderPart = ColliderPartRuntime.GetPoolItem();
                _colliderPart.GenerateFromColliderMesh(_colliderMesh);
            }
        }
Пример #2
0
        public void Clear()
        {
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            _mesh.Clear();
            if (_sibling != null)
            {
                _sibling.Deactivate();
                VisualPartRuntimePool.Instance.Push(_sibling);
            }
            _colliderMesh.Clear();

            if (_colliderPart == null)
            {
                _colliderPart = ColliderPartRuntime.GetPoolItem();
            }
            _colliderPart.Clear();
        }