Cant get type by “Type _tempType = Type.GetType(“UnityEngine.ParticleRenderer”);”
not only ParticleRenderer, including SkinnedMeshRenderer and others.
I have to get the type by string, I can get my custom classes.
Plz help.
Cant get type by “Type _tempType = Type.GetType(“UnityEngine.ParticleRenderer”);”
not only ParticleRenderer, including SkinnedMeshRenderer and others.
I have to get the type by string, I can get my custom classes.
Plz help.
This will work for you.
public static Type FindTypeInLoadedAssemblies(string typeName)
{
Type _type = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
_type = assembly.GetType(typeName);
if (_type != null)
break;
}
return _type;
}
Then you can do like
var type = FindTypeInLoadedAssemblies("UnityEngine.ParticleRenderer")
Of course you can optimize this with cache for AppDomain.CurrentDomain.GetAssemblies()
if you look for types several times in a short timespan.