0

To be specific. I need to cast a string to an enum. I have tried Type.GetType() but it doesn't seem to work in Unity or I need some complex assembly code. I know of ways to cast a Type to a string but not a nice method the other way around. I am using Unity and C#. I have looked at many answers here with no avail.

Side note : This wont be needed to answer if someone knows how to use an enum as as parameter. Again I scoured google but only found code that picks apart enums to send them or the answer no. Any light on this would be great also.

eg. Load(enumType);

Fredrik Widerberg
  • 3,068
  • 10
  • 30
  • 42
  • Why it didn't work in the normal C# way, what have you tried exactly ? Look at http://stackoverflow.com/questions/1825147/type-gettypenamespace-a-b-classname-returns-null for example – AFract Sep 15 '15 at 08:37
  • In Unity it also requires an assembly parameter for some reason. Also It wont cast not native/system types. Im looking for a way more simple piece of code to cast my own way rather than use GetType. from what I have seen its not good in Unity with custom Types without a bunch of assembly searching ( slow) – Phatboygeo Sep 15 '15 at 08:40
  • I was using Type.GetType("Node.NodeType"); and it was giving me an error for a second paramter – Phatboygeo Sep 15 '15 at 08:41

0 Answers0