Comments (1)
运行环境:戴森球计划dspgame
BepInEx5.4.23.1 + IronPython3.4.1+net4.6.2
[Message: BepInEx] BepInEx 5.4.23.1 - DSPGAME (2024/6/4 11:31:23)
[Info : BepInEx] Running under Unity v2018.4.12.5889476
[Info : BepInEx] CLR runtime version: 4.0.30319.17020
i meet the same wrong
i use import deal with it, not use scope:
pyfile global a =0 // print(a) --> 0
void Start()
engine.Execute("import manage; manage.Start()"); // a +=1 print(a) --> 1
void Update()
engine.Execute("import manage; manage.Update()"); // a +=1 print(a) --> 2
void OnGUI()
engine.Execute("import manage; manage.OnGUI()"); // a +=1 print(a) --> 3
使用python模块脚本的全局单一特性,存储数据,从而保证数据的一致性。
(不管import多少次,只有第1次import是生效的,而其他import则是调用)
===============================================
using System;
using System.Collections;
using UnityEngine;
using BepInEx;
using HarmonyLib;
using IronPython.Hosting;
using IronPython.Runtime;
using System.IO;
using Microsoft.Scripting.Runtime;
using Microsoft.Scripting;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Scripting.Hosting;
using System.Reflection;
using System.Runtime.Remoting.Contexts;
namespace IronPython3Mod
{
[BepInPlugin(GUID, NAME, VERSION)]
[BepInProcess(GAME_PROCESS)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "cn.zhufile.dsp.zhu_ironpython3_mod";
public const string NAME = "IronPython3Mod";
public const string VERSION = "1.0.7";
private const string GAME_PROCESS = "DSPGAME.exe";
public static ScriptEngine engine = null;
public static float time = 0;
public void Start()
{
engine = Python.CreateEngine();// Create a new IronPython engine
// engine.Execute("print('111111111111111111')"); // OK, it work!!!
// Set up the search paths for the Python script
var searchPaths = engine.GetSearchPaths();
searchPaths.Add("BepInEx\\plugins\\IronPython3\\net462\\Lib");
searchPaths.Add("BepInEx\\plugins\\IronPython3\\mod");
searchPaths.Add("BepInEx\\plugins\\IronPython3\\modmanage");
engine.SetSearchPaths(searchPaths);
// 运行python脚本文件,加载mod
engine.Execute("import manage; manage.Start()");
}
public void Update()
{
time += Time.deltaTime; // 每帧的时间间隔,单位秒
if (time > 30)
{
time = 0;
engine.Execute("import manage; manage.Update()");
}
}
public void OnGUI()
{
engine.Execute("import manage; manage.OnGUI()");
}
}
==============================================
anather, there are many different in ipy.exe and bepinex‘s ironpython3 engine
for example,
a = os.listdir(".") do it in ipy.exe, but in bepinex‘s ironpython3 engine is wrong !!!
from ironpython3.
Related Issues (20)
- "not a Zip file" - what does it mean?! HOT 2
- input function throws: LookupException: unknown encoding: utf_8 HOT 6
- NullReferenceException while creating IronPython engine in referenced project HOT 4
- no module named errno HOT 4
- No way to programmatically stop execution HOT 8
- future feature is not defined HOT 1
- IronPython
- The ipyc /out: option dose not change the output path of exe host
- IronPython.Runtime.Exceptions.ImportException: 'No module named 'xml.etree.ElementTree'' HOT 5
- Calling method with an argument of ReadOnlySpan<char> throws ArgumentException
- Ironpython version 3.4.1 Exception at runtime console application HOT 1
- big-data examples: using apache beam or spark
- "Index was outside the bounds of the array" exception thrown when importing a class with hundreds of properties HOT 3
- Install setup.py HOT 6
- Extension binder fails to resolve overloads with nested generics
- How to support IronPython 2.7 and 3.4 in one app? HOT 1
- If call Python and there is an infinite loop in Python, where can set the timeout?
- v3: Embedding in a web site - build warnings about WindowsBase HOT 2
- Cannot install pip package if package contains native code that should be compiled during install
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ironpython3.