Ejemplo n.º 1
0
        public void Clear()
        {
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            _mesh.Clear();
            if (_sibling != null)
            {
                _sibling.DestroyVisual();
            }

            if (_colliderPart == null)
            {
                _colliderPart = ColliderPart.Create(transform.parent);
            }
            _colliderPart.Clear();
        }
Ejemplo n.º 2
0
        public void GenerateFromDynamicMesh(BuildRMesh overflow = null)
        {
            Debug.Log("VisualPart.cs GenerateFromDynamicMesh :" + overflow);
            HUtils.log();

            if (_dynamicMesh == null)
            {
                _dynamicMesh = new BuildRMesh(DYNAMIC_MESH_NAME);
            }
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            if (_filter == null)
            {
#if UNITY_EDITOR
                _filter = UnityEditor.Undo.AddComponent <MeshFilter>(gameObject);
#else
                _filter = gameObject.AddComponent <MeshFilter>();
#endif
            }
            if (_renderer == null)
            {
#if UNITY_EDITOR
                _renderer = UnityEditor.Undo.AddComponent <MeshRenderer>(gameObject);
#else
                _renderer = gameObject.AddComponent <MeshRenderer>();
#endif
            }
            if (overflow != null)
            {
                _dynamicMesh = overflow;
            }
            _dynamicMesh.Build(_mesh);
            _filter.sharedMesh        = _mesh;
            _renderer.sharedMaterials = _dynamicMesh.materials.ToArray();


            if (_dynamicMesh.hasOverflowed)
            {
                if (_sibling == null)
                {
                    _sibling = Create(transform.parent, name);
                }
                _sibling.GenerateFromDynamicMesh(_dynamicMesh.overflow);
            }
            else
            {
                if (_sibling != null)
                {
                    _sibling.DestroyVisual();
                }
                _sibling = null;
            }

            if (_colliderPart == null)
            {
                _colliderPart = ColliderPart.Create(transform.parent);
            }

            if (_colliderMesh == null)
            {
                _colliderMesh = new BuildRCollider(DYNAMIC_COLLIDER_NAME);
            }
            _colliderPart.GenerateFromColliderMesh(_colliderMesh);
        }