Question

I tried getting the type of UnityEngine.Vector3 using Type.GetType() but its returning NULL. It works fine for native types.

Was it helpful?

Solution

You might need to specify the assembly in which this type is located as well if the type is situated in a different assembly:

var type = Type.GetType("UnityEngine.Vector3, UnityEngine", true);

OTHER TIPS

You need to use the Assembly if it's not a "nativa type" or inside the calling Assembly

Read this:

If typeName includes the namespace but not the assembly name, this method searches only the calling object's assembly and Mscorlib.dll, in that order. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly. If the assembly has a strong name, a complete assembly name is required.

typeName (the parameter of Type.GetType(string type))

Type: System.String The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace. The syntax is like this:

var type = Type.GetType("UnityEngine.Vector3, AssemblyName");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top