Created
May 30, 2015 08:33
-
-
Save yasuakiohama/d0f08eee33f18c4743e2 to your computer and use it in GitHub Desktop.
enumのテストサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// foreach (var strArray in SaveData.Key.GetArray ()) { | |
// GameObject flageList = Instantiate (Resources.Load ("FlageList")) as GameObject; | |
// flageList.GetComponent<RectTransform> ().SetParent (transform, false); | |
// flageList.GetComponent<RectTransform> ().name = strArray.name; | |
// flageList.GetComponent<CreateNode> ().namelist = strArray.data; | |
// flageList.SetActive (false); | |
// } | |
using UnityEngine; | |
using System.Collections; | |
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace Game | |
{ | |
public class SaveData : MonoBehaviour | |
{ | |
public class Key | |
{ | |
enum Gloval : int{ | |
Flage_001 = 1, | |
Flage_002, | |
Flage_003, | |
Flage_004, | |
Flage_005, | |
Flage_006, | |
Flage_007, | |
Flage_008, | |
Flage_009, | |
Flage_011, | |
Flage_012, | |
Flage_013, | |
Flage_014, | |
Flage_015, | |
Flage_016, | |
Flage_017, | |
}; | |
enum Chapter1 : int{ | |
Flage_001 = 1, | |
Flage_002, | |
Flage_003, | |
Flage_004, | |
Flage_005, | |
Flage_006, | |
Flage_007, | |
Flage_008, | |
Flage_009, | |
Flage_010, | |
Flage_011, | |
Flage_012, | |
}; | |
enum Chapter2 : int{ | |
Flage_001 = 1, | |
Flage_002, | |
Flage_003, | |
Flage_004, | |
Flage_005, | |
Flage_006, | |
Flage_007, | |
Flage_008, | |
Flage_009, | |
}; | |
enum Chapter3 : int{ | |
Flage_001 = 1, | |
Flage_002, | |
Flage_003, | |
}; | |
public class Data | |
{ | |
public Data(string name,string[] data) | |
{ | |
this.name = name; | |
this.data = data; | |
} | |
public string name; | |
public string[] data; | |
} | |
public static List<Data> GetArray() | |
{ | |
List<Data> arrayList = new List<Data> (); | |
arrayList.Add (GetDataArray<Gloval> ()); | |
arrayList.Add (GetDataArray<Chapter1> ()); | |
arrayList.Add (GetDataArray<Chapter2> ()); | |
arrayList.Add (GetDataArray<Chapter3> ()); | |
return arrayList; | |
} | |
public static Data GetDataArray<T>() | |
{ | |
Array array = Enum.GetValues (typeof(T)); | |
Data data = new Data (typeof(T).Name, array.OfType<T> ().Select (o => o.ToString ()).ToArray ()); | |
return data; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment