Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Mesh.isReadable

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var isReadable: bool;
public bool isReadable;

Description

Returns true if the Mesh is read/write enabled, or false if it is not.

When a Mesh is read/write enabled, Unity uploads the Mesh data to GPU-addressable memory, but also keeps it in CPU-addressable memory. When a Mesh is not read/write enabled, Unity uploads the Mesh data to GPU-addressable memory, and then removes it from CPU-addressable memory.

You can set this value using the Read/Write Enabled checkbox when importing a model to Unity. To set the value to false at run time, set the markNoLongerReadable argument of Mesh.UploadMeshData.

In most cases, you should disable this option to save runtime memory usage. You should only enable it under the following circumstances:

- When you read from or write to the Mesh data in your code.
- When you pass the Mesh to StaticBatchingUtility.Combine() to combine the Mesh at run time.
- When you use the Mesh to bake a NavMesh using the NavMesh building components at run time.
- When you use the Mesh with a Mesh Collider, and the Mesh Collider's transform has negative scaling (for example, (–1, 1, 1)).
- When you use the Mesh with a Mesh Collider, and the Mesh Collider's transform is skewed or sheared (for example, when a rotated Transform has a scaled parent Transform).
- When you use the Mesh with a Mesh Collider, and the Mesh Collider's Cooking Options flags are set to any value other than the default.


Notes: When Unity creates a Mesh from script, this value is initially set to true. Meshes not marked readable will throw an error on accessing any data arrays from script at runtime. Access is always allowed in the Unity Editor outside of the game and rendering loop, regardless of this setting.

See Also: StaticBatchingUtility.Combine.

#pragma strict
function Start() {
	var mesh: Mesh = GetComponent.<MeshFilter>().sharedMesh;
	print(mesh.isReadable);
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { Mesh mesh = GetComponent<MeshFilter>().sharedMesh; print(mesh.isReadable); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答