コード例 #1
0
 private void OnDisable()
 {
     _meshSource?.Dispose();
     _meshSource = null;
     if (TryGetComponent(out MeshFilter meshFilter))
     {
         meshFilter.mesh = null;
     }
 }
コード例 #2
0
        private void OnEnable()
        {
            _meshSource?.Dispose();
            _meshSource = new MeshSource(8192 * 3);

            if (!TryGetComponent(out MeshFilter meshFilter))
            {
                meshFilter = gameObject.AddComponent <MeshFilter>();
            }

            meshFilter.hideFlags = HideFlags.DontSave | HideFlags.NotEditable;
            meshFilter.mesh      = _meshSource.Mesh;

            Generate();
        }