leeeel
September 13, 2020, 7:21am
1
Given a custom class
public class GenericProjectile:MonoBehaviour{}
When using Addcomponent() function, the function couldn’t recognize the custom Types( if this class is not in a namespace).
Any way to solve this problem?
That introduce custom types to Python?
tran10
April 11, 2021, 11:59pm
2
Hello,
I have the same problem but I didn’t find the solution to use Addcomponent() function in Python.
Hope that someone can have solution
tran10
April 16, 2021, 8:55am
3
Ok, I found the solution we can use “clr” to get the environment of Unity like this:
import clr
print(dir(clr))
import UnityEngine as UE
go = UE.GameObject.CreatePrimitive(UE.PrimitiveType.Cube)
go.AddComponent(clr.GenericProjectile)
2 Likes
tran10:
Ok, I found the solution we can use “clr” to get the environment of Unity like this:
import clr
print(dir(clr))
import UnityEngine as UE
go = UE.GameObject.CreatePrimitive(UE.PrimitiveType.Cube)
go.AddComponent(clr.GenericProjectile)
brilliant, this Unity Python really lacks of good documents , I think all user must to read the http://pythonnet.github.io/ very carefully ,hope they can provide a rich document later soon