Je suis sur un projet où j'utilise le package "UnityEditor.Scripting.Python".
Tous fonctionne très bien dans unity

Quant au Build, impossible de le faire

On m'affiche les messages d'erreurs:
"Assets\_Scripts\GetPositionUnity.cs(7,19): error CS0234: The type or namespace name 'Scripting' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)"
Assets\_Scripts\GetPositionUnity.cs(21,6): error CS0246: The type or namespace name 'MenuItemAttribute' could not be found (are you missing a using directive or an assembly reference?)
"Assets\_Scripts\GetPositionUnity.cs(21,6): error CS0246: The type or namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?)"
J'ai vu qu'une des solutions qui existent, c'est de mettre le script dans un dossier "Editor"


Quelqu'un pourrait me venir en aide s'il vous plait,

Code : Tout sélectionner
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using TMPro;
using UnityEditor;
using UnityEditor.Scripting.Python;
using UnityEngine;
public class GetPositionUnity : MonoBehaviour
{
private string msg;
public TextMeshProUGUI mainText;
[MenuItem("Python Scripts/GetPosition")]
public static IEnumerator GetPositionFromPython()
{
//GetPosition.py fait appel à la methode ExtractPosition de cette classe
PythonRunner.RunFile("Assets/_Scripts/GetPosition.py");
yield return new WaitForSeconds(0.1f);
}
void Update()
{
StartCoroutine(GetPositionFromPython());
}
public void ExtractPosition(string msg)
{
//Affichage des coordonnées dans la console
Debug.Log(msg);
//Modification du texte affiché dans la fenêtre
mainText.text = msg;
}
}