- Home /
Mesh.uv during Editor Mode
Greetings,
I have a class that uses a sprite sheet to display animations on a quad. However, if I have more than one object using the same sheet then I need to display with uvs. So this is fine to use mesh.uv. But the problem comes in when I am using the Editor, it throws exceptions because I am using renderer.mesh not renderer.sharedMesh. But I have to use mesh because otherwise the uv's will change on all of the objects that share the "quad" resource (Asset). Any suggestions, I will be happy just to catch that exception.
I am using the following code:
// Pseudo Code
renderer.mesh.uv = new Vector2[] { stuff here }; // (throws exception during editor mode)
renderer.sharedMesh.uv = new Vector2[] { blah blah }; // Changes all objects
Answer by rutter · Apr 05, 2012 at 07:54 PM
I assume you're using JavaScript? If I try to access renderer.mesh while using #pragma strict, I get the following compiler error:
BCE0019: 'mesh' is not a member of 'UnityEngine.Renderer'.
Perhaps you should try something more like this:
var mesh : Mesh = GetComponent(MeshFilter).mesh;
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# try catch block doesn't work for iOS? 2 Answers
How do I sync a mesh over network? (Photon) 1 Answer
How to Move Vertices from a Mesh to a Specific Location 2 Answers