Python for Unity doesn't support Custom class

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?

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 :frowning:

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

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