x


BCE0019: 'mesh' is not a member of 'UnityEngine.Component' on Android Build

When trying to Build a game for android, I get this error "BCE0019: 'mesh' is not a member of 'UnityEngine.Component'" 3 times.

In here

if(GetComponent(MeshFilter).mesh == null)
    GetComponent(MeshFilter).mesh = new Mesh();

& in here

var mesh : Mesh = GetComponent(MeshFilter).mesh;

Anybody any idea on how to fix this?

Thanks in advance!!

more ▼

asked Apr 08 '11 at 01:10 AM

ThomasQ gravatar image

ThomasQ
221 34 40 43

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

GetComponent returns Component, and indeed mesh is not a member of Component. If you're not using dynamic typing then you have to cast it correctly. If you want less typing, use generics.

GetComponent.<MeshFilter>().mesh = ...
more ▼

answered Apr 08 '11 at 01:34 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

(comments are locked)
10|3000 characters needed characters left

Again. I'm gonna awnser my own question... I've got to stop asking to quickly :D

here's the working code:

    if((GetComponent(MeshFilter) as MeshFilter).mesh == null)
    (GetComponent(MeshFilter) as MeshFilter).mesh = new Mesh(); 

&

    var mesh : Mesh = (GetComponent(MeshFilter) as MeshFilter).mesh

I still don't know how this works, so if someone could clarify on this, would be great..

more ▼

answered Apr 08 '11 at 01:20 AM

ThomasQ gravatar image

ThomasQ
221 34 40 43

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2457
x1953
x111

asked: Apr 08 '11 at 01:10 AM

Seen: 2665 times

Last Updated: Apr 08 '11 at 01:10 AM