/// <summary> /// Draw the editor UI in immediate mode. /// /// Called by OnInspectorGUI, which catches any exception we throw here. /// </summary> void OnInspectorGUICanThrow() { // Overall UI layout for now: information at the top. // Settings for in-process next (may also affect out-of-process Python). // Settings for out-of-process next. // TODO: nicer UI. var settings = (PythonSettings)target; // TODO: label + selectable label so users can copy-paste package version // (and the same for all versions below) EditorGUILayout.LabelField("Package Version: " + PythonSettings.Version); EditorGUILayout.LabelField( new GUIContent("Python Version: " + ShortPythonVersion(PythonRunner.PythonVersion), "Python for Unity is running Python version " + PythonRunner.PythonVersion)); EditorGUILayout.LabelField( new GUIContent("Python for .NET Version: " + PythonSettings.PythonNetVersion, "Python for Unity uses Python for .NET version " + PythonSettings.PythonNetVersion)); EditorGUILayout.Separator(); //Site Packages section. EditorGUILayout.LabelField("Site Packages", EditorStyles.boldLabel); // The site packages array goes through the serializedObject code path // to offer the usual array modification workflow in the UI. // TODO: make this much prettier. var sitePackagesArray = serializedObject.FindProperty("m_sitePackages"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(sitePackagesArray, Styles.sitePackages, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (PythonSettings.SitePackagesChanged) { EditorGUILayout.HelpBox("Restart Unity for these changes to be applied.", MessageType.Warning); } EditorGUILayout.Separator(); #if UNITY_EDITOR_WIN if (GUILayout.Button("Spawn shell in environment", GUILayout.Width(170))) { PythonRunner.SpawnShell(); } #endif }
void Execute(string code) { PythonRunner.RunString(code, "__main__"); }