Parsing String from script A into Enum in script B

I’m making a game object from scratch and adding a script that uses enums on it. I’d like to load a string from a file and convert that string into the enum and set the enum for the new object.

Edit:

Let me try to reexplain from scratch.

I’m trying to implement “user provided content” (custom textures) in an app that’s “in production”.

These textures are used on “tiles”. Each tile has a “Tile” script.

Tile.cs has TileUse and TileType enums. TileUse lets me know what the tile is being used for (as a floor, wall, corner etc). So, I load up this texture, place it on a game object, put Tile.cs on it and I need to change TileUse from floor (default) to what ever the user made it.

//Tile.cs

public enum TileUse {

		floor,
		wall,
		corner,
		openPassage,
		passage,
		endCap,
		diagonalWall,
		curvedWall,
		goldFish
	}


//SideParentSorter.cs

ctTransform.AddComponent<Tile>();
//Insert way to change TileUse (enum) on Tile.
//Insert way to change TileType (enum) on Tile.

Being completely self taught programmer I’m 90% sure this is a casting issue and 25% wtf at this point.

Enum.Parse works by passing the Type(the enum definition) and the string or optionally the same signature with a Boolean indicating whether or not to observe case sensitivity.

Lets say you have an enum defined as:

public enum Tile
{
  Grass1,
  Grass2,
  Brick3,
  Brick8,
  Stone,
  Granite
}

Lets say you use ToString to store the enum string value into a variable:

string someTile = Tile.Brick3.ToString();

If I want to convert that back to an enum i would use:

Tile tile = (Tile) Enum.Parse(typeof(Tile), someTile);

If i couldn’t guarentee that case would match the enum definition, i would use a different overload of the static method of Parse which could ignore the case of the string.

Tile tile = (Tile) Enum.Parse(typeof(Tile), someTile, true);

Remember, the typeof want the Tile enum type, not the property from a class, i think it’s fair to assume ctTile.TileUse is either a property or field that contains a Tile enum value,