private void compileButton_Click(object sender, EventArgs e) { script.Source = scriptBox.Text; HeightRender.Effect effect; string errors; switch (HeightRender.CompileEffect(script, out effect, out errors)) { case HeightRender.EffectCompileResult.WrongApplySignature: MessageBox.Show("The method signature for the \"Apply\" function should be:\n\nPhoton Apply(int x, int y, Photon color, HeightField heightField)", "Script Error"); break; case HeightRender.EffectCompileResult.MissingApplyFunction: MessageBox.Show("The \"Apply\" function is missing from your script.", "Script Error"); break; case HeightRender.EffectCompileResult.SyntaxError: MessageBox.Show("There was a compilation error in your script:\r\n" + errors, "Script Error"); break; case HeightRender.EffectCompileResult.Success: Document.SetEffect(effectName, effect, script); break; } }
private static EffectScript LoadEffect(Stream stream) { CSScript script = new CSScript(); script.Source = LoadText(stream); HeightRender.Effect effect; string errors; HeightRender.CompileEffect(script, out effect, out errors); EffectScript es = new EffectScript() { effect = effect, script = script }; return(es); }