How to fix 'DrawMesh requires material.SetPass before!'?

To get into unity I’m copy-pasting stuff from the ShadowDemoProject into my own project. Things go pretty well and I really begin to feel the power of unity, but there’s one thing I cannot solve right now:

I’m using the highlight function from DragRigidBodyShadow.js:

function OnPostRender()
{
if( highlightObject == null )
return;

var go = highlightObject;
highlightMaterial.SetPass( 0 );
var meshes = go.GetComponentsInChildren(MeshFilter);
for( var m : MeshFilter in meshes )
{
Graphics.DrawMeshNow( m.sharedMesh, m.transform.position, m.transform.rotation );
}
}

but always get the error: DrawMesh requires material.SetPass before!

Can anyone please explain what this means and how I can avoid this?

Thx a bunch

Ekki (unity Newbie)

Are you using the rest of the DragRigidbodyShadow script as supplied in the original project? If so, is the highlightMaterial variable assigned in the inspector? If it isn’t then you should also be getting null reference errors. You can check this by opening the console window (menu: Window > Console).

A valid material is assigned. To be sure I used even the identical material from the demo project. It’s definitely not a null-pointer issue.

Thx, andeeee