Using a string to get a variable from another Script

This is question relate to Google Play Achievements.
For Google Achievement, I have this static class for all achievements.

public static class MyAchievements{

    public const string achievement_NumberOneAchi = "CgkIuojYPEAIA";

    public const string achievement_NumberTwoAchi = "CgkIuojYPEAIB";

}

In another script, I will get a string pass in passInAchiName = “NumberOneAchi”,
and I need to use this to get the string from the Static Class:


void IAchievementIntegration.UnlockAchievement( string passInAchiName)
{

    //use passInAchiName to get "CgkIuojYPEAIA" or MyAchievements.achievement_NumberOneAchi

Social.ReportProgress("CgkIuojYPEAIA", 100.0f, (bool success) => {});

}

You mean something like this?

Type type = typeof(MyAchievements);
FieldInfo info = type.GetField("achievement_NumberOneAchi");
string achievement = (string)info.GetValue(null);

You need the System namespace for the Type and the Reflection for the FieldInfo.

Based on you second explanation in the comments, I would suggest a Dictionary<string, string>. Dictionary is generally a good way to map objects of any type to other objects.

Dictionary<string, string> achiMap = new Dictionary<string, string>();

void Awake() {
    achiMap.Add("NumberOneAchi", "CgkIuojYPEAIA");
    achiMap.Add("NumberTwoAchi", "CgkIuojYPEAIB");
}

void SomeMethod() {
    Social.ReportProgress( achiMap[passInAchiName], 100.0f, (bool success) => {});
}