How can I use Type.GetType() with List'1[UnityEngine.Vector3]?

544 views Asked by At

I am currently using:

    public static Type FindType(string qualifiedTypeName)
    {
        Type t = Type.GetType(qualifiedTypeName);

        if (t != null)
        {
            return t;
        }
        else
        {
            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                t = asm.GetType(qualifiedTypeName);
                if (t != null)
                    return t;
            }
            return null;
        }
      

kudos to @Alistar from this post : Type.GetType not working
However, even this doesnt work when it comes to a list of Vector3s from UnityEngine.
I know that you can include the relevant assembly also by adding ", UnityEngine" at the end, but it doesnt work.

Edit:
Just to clarify, I am trying to use a string value

"System.Collections.Generic.List`1[UnityEngine.Vector3]"

Where the actual list type could be anything, and would like to find the actual Type from this string. This works with regular lists and regular vars, but I get null result when it comes to special list types.

Any ideas?

1

There are 1 answers

0
derHugo On BEST ANSWER

The string you provide is not an AssemblyQualifiedName!

It rather looks like it is only the result of Type.ToString.

e.g. the AssemblyQualifiedName of a List<string> looks like this:

System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

and of a List<Vector3> it would be

System.Collections.Generic.List`1[[UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089