|
Hi! I need to convert a string into its equivalent enum object. Although I could make an auxiliary function to do that, I wonder if C# can do that for me and I've found this article, but I'm afraid it doesn't work in Unity. I've been searching here through Unity Answers but haven't been able to find a solution, can you help me? Thanks in advance!
(comments are locked)
|
This works! Great! Many thanks!
Mar 14 '11 at 01:32 PM
Ignacio 1
where does the string go?
Jan 30 at 03:57 AM
Anxowtf
@Anxowtf The initial string goes into the 'your_string' variable in the example code above. The function then looks for an entry in the specified enumeration that matches the given string and returns it.
Jun 03 at 06:36 PM
Zarenityx
(comments are locked)
|

That does work. Let me see if I can find an example for you.
Yes, sorry about being a little bit vague. I should have mentioned I was getting a compilation error because I was trying to use it exactly as it appeared in the article (i.e., by using Enum.Parse). I tried the solution that taoa suggested and it worked! Thanks for your reply!