public void VerifFormule() { Jardin jardin = terrainHandler.getJardin(); Communicate comm = new Communicate(SCRIPT_PYTHON, jardin); //lance le script comm.GetSource().Execute(comm.GetScope()); for (int i = 1; i <= NB_FORMULE; i++) { iField = (InputField)GameObject.Find(PATH + "Form_" + i).GetComponent<InputField>(); output = (Text)GameObject.Find(PATH + "VerifPan_" + i + "/verif_resultat_" + i).GetComponent<Text>(); if (iField.text == "") { continue; } try { Formule formule = FormuleFactory.parse(iField.text); foreach (Element el in jardin.GetElements()) { Debug.Log(el); } object pythonForm = comm.HandleForm(formule); Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul"); object pythonJardin = unity_my_interp_formul(jardin); Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form"); var res = unity_eval_one_form(pythonJardin, pythonForm); //Affiche résultat if ((bool)res == true) { output.color = Color.green; output.text = "Vrai"; } else { output.color = Color.red; output.text = "Faux"; } } catch (ParserLogException) { output.color = Color.red; output.text = "Erreur"; Debug.Log("Erreur formule"); } catch (ValueErrorException) { output.color = new Color32(255, 128, 0, 255); output.text = "Var libre"; } catch (Exception) { output.color = Color.red; output.text = "Erreur imprévue"; } } }
public void VerifFormule() { iField = focusHandler.getCurrentFormule(); output = focusHandler.getCurrentVerif(); if (string.IsNullOrEmpty(iField.text)) { return; } try { Formule formule = FormuleFactory.parse(iField.text); Jardin jardin = terrainHandler.getJardin(); Communicate comm = new Communicate(SCRIPT_PYTHON, jardin); foreach (Element el in jardin.GetElements()) { Debug.Log(el); } //lance le script comm.GetSource().Execute(comm.GetScope()); object pythonForm = comm.HandleForm(formule); Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul"); object pythonJardin = unity_my_interp_formul(jardin); Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form"); var res = unity_eval_one_form(pythonJardin, pythonForm); Debug.Log("res=" + res); //Affiche résultat if ((bool)res == true) { output.color = Color.green; output.text = "Vrai"; } else { output.color = Color.red; output.text = "Faux"; } } catch (ParserLogException) { output.color = Color.red; output.text = "Erreur"; Debug.Log("Erreur formule"); } catch (ValueErrorException) { output.color = new Color32(255, 128, 0, 255); output.text = "Var libre"; } catch (Exception) { output.color = Color.red; output.text = "Erreur imprévue"; } }
public void VerifFormule() { iField = focusHandler.getCurrentFormule(); output = focusHandler.getCurrentVerif(); if (string.IsNullOrEmpty(iField.text)) { return; } try { Formule formule = FormuleFactory.parse(iField.text); Jardin jardin = terrainHandler.getJardin(); Communicate comm = new Communicate(SCRIPT_PYTHON, jardin); foreach(Element el in jardin.GetElements()) { Debug.Log(el); } //lance le script comm.GetSource().Execute(comm.GetScope()); object pythonForm = comm.HandleForm(formule); Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul"); object pythonJardin = unity_my_interp_formul(jardin); Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form"); var res = unity_eval_one_form(pythonJardin, pythonForm); Debug.Log("res=" + res); //Affiche résultat if ((bool)res == true) { output.color = Color.green; output.text = "Vrai"; } else { output.color = Color.red; output.text = "Faux"; } } catch (ParserLogException) { output.color = Color.red; output.text = "Erreur"; Debug.Log("Erreur formule"); } catch (ValueErrorException) { output.color = new Color32(255, 128, 0, 255); output.text = "Var libre"; } catch (Exception) { output.color = Color.red; output.text = "Erreur imprévue"; } }
void Start() { FormuleTest ft = new FormuleTest(); Jardin jardin = jardin2(); Communicate comm = new Communicate("psar_python.py", jardin); //lance le script comm.GetSource().Execute(comm.GetScope()); ft.test_formules(comm, jardin); }
public void VerifFormule() { Jardin jardin = terrainHandler.getJardin(); Communicate comm = new Communicate(SCRIPT_PYTHON, jardin); //lance le script comm.GetSource().Execute(comm.GetScope()); for (int i = 1; i <= NB_FORMULE; i++) { iField = (InputField)GameObject.Find(PATH + "Form_" + i).GetComponent <InputField>(); output = (Text)GameObject.Find(PATH + "VerifPan_" + i + "/verif_resultat_" + i).GetComponent <Text>(); if (iField.text == "") { continue; } try { Formule formule = FormuleFactory.parse(iField.text); foreach (Element el in jardin.GetElements()) { Debug.Log(el); } object pythonForm = comm.HandleForm(formule); Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul"); object pythonJardin = unity_my_interp_formul(jardin); Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form"); var res = unity_eval_one_form(pythonJardin, pythonForm); //Affiche résultat if ((bool)res == true) { output.color = Color.green; output.text = "Vrai"; } else { output.color = Color.red; output.text = "Faux"; } } catch (ParserLogException) { output.color = Color.red; output.text = "Erreur"; Debug.Log("Erreur formule"); } catch (ValueErrorException) { output.color = new Color32(255, 128, 0, 255); output.text = "Var libre"; } catch (Exception) { output.color = Color.red; output.text = "Erreur imprévue"; } } }