You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/unity/en/tutorial/python2cs.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Calling C# from Python
1
+
# Calling C# from Python
2
2
3
3
> 💡 PuerTS 3.0 also supports [JavaScript](./js2cs.md) and [Lua](./lua2cs.md) calling C#, each with different syntax. Click the links to see the corresponding tutorials.
4
4
@@ -181,7 +181,7 @@ void Start() {
181
181
env.Eval(@"
182
182
exec('''
183
183
import System
184
-
import System.Collections.Generic.List__T1 as List
184
+
import System.Collections.Generic.List_1 as List
185
185
186
186
# create generic type: List<int>
187
187
ListInt = puerts.generic(List, System.Int32)
@@ -197,9 +197,9 @@ print(ls.Count) # 3
197
197
}
198
198
```
199
199
200
-
> ⚠️ **Special naming for generic types**: In C#, generic type names use backticks to indicate the number of type parameters (e.g. `` List`1 ``). In Python's `import` syntax, backticks must be replaced with `__T` followed by the count:
201
-
> -`` List`1 `` → `List__T1`
202
-
> -`` Dictionary`2 `` → `Dictionary__T2`
200
+
> ⚠️ **Special naming for generic types**: In C#, generic type names use backticks to indicate the number of type parameters (e.g. `` List`1 ``). In Python's `import` syntax, backticks must be replaced with `_` followed by the count:
201
+
> -`` List`1 `` → `List_1`
202
+
> -`` Dictionary`2 `` → `Dictionary_2`
203
203
>
204
204
> When using `puerts.load_type()`, you can use the original backtick format directly:
Copy file name to clipboardExpand all lines: unity/upms/python/Runtime/Src/Backends/BackendPython.cs
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -131,12 +131,12 @@ class puerts:
131
131
def load_type(type_name: str):
132
132
""""""
133
133
Load a C# class or generic type definition, raise ModuleNotFoundError if the type cannot be found or loaded.
134
-
:param type_name: The full name of the C# type to load. If the type is generic, use the format 'TypeName__Tn' where n is the number of generic parameters.
134
+
:param type_name: The full name of the C# type to load. If the type is generic, use the format 'TypeName_n' where n is the number of generic parameters.
135
135
:return: The loaded C# class or generic type definition
0 commit comments