Skip to main content
added 374 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

You can override the size of the enum, if needed:

enum CombatMove : int //implied, 32-bits, max value 2147483647
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

Strings

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));
 

The dictionary for strings:

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

Parsing a string back into to an enum:

    string combatString = "RightMiddleJab";
    try
    {
        CombatMove combatMove = 
           (CombatMove)System.Enum.Parse(typeof(CombatMove), combatString);
    }
    catch (System.ArgumentException)
    {
        Debug.Log("Invalid enum string: " + combatString);
        throw;
    }

You can override the size of the enum, if needed:

enum CombatMove : int //implied, 32-bits, max value 2147483647
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));
 
using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

You can override the size of the enum, if needed:

enum CombatMove : int //implied, 32-bits, max value 2147483647
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

Strings

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

The dictionary for strings:

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

Parsing a string back into to an enum:

    string combatString = "RightMiddleJab";
    try
    {
        CombatMove combatMove = 
           (CombatMove)System.Enum.Parse(typeof(CombatMove), combatString);
    }
    catch (System.ArgumentException)
    {
        Debug.Log("Invalid enum string: " + combatString);
        throw;
    }
edited body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

You can override the typesize of the enum, if needed:

enum CombatMove : int //implied, 32-bits, max value 2147483647
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

You can override the type of the enum, if needed:

enum CombatMove : int //implied
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

You can override the size of the enum, if needed:

enum CombatMove : int //implied, 32-bits, max value 2147483647
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();
added 285 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

You can override the type of the enum, if needed:

enum CombatMove : int //implied
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();

You can override the type of the enum, if needed:

enum CombatMove : int //implied
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

You can override the type of the enum, if needed:

enum CombatMove : int //implied
{
   RightMiddleJab = 0, //0
   LeftMiddleJab = 1,  //1
   RightUpperJab = 3,  //3
   LeftUpperJab,       //4
}

And since you can cast them, there is probably no reason to refer to them by name:

CombatMove combatMove = CombatMove.LeftUpperJab;
int combatMoveValue = (int)combatMove;

I don't know exactly what you are trying to index, both types are arbitrary:

using System.Collections.Generic;
Dictionary<CombatMove, AnimationClip> AnimationClipsByEnum;
AnimationClipsByEnum[CombatMove.RightMiddleJab].ClearCurves();

If you really do have a good reason, you can use the System.Enum class:

string[] CombatMoveNames = System.Enum.GetNames(typeof(CombatMove));

using System.Collections.Generic;
Dictionary<string, AnimationClip> AnimationClipsByName;
AnimationClipsByName["RightMiddleJab"].ClearCurves();
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading