usingSystem;usingUnityengine;usingSystem.Collections;usingSystem.Collections.Generic; Public classmessagetext{Private StaticMessageText instance;/// <summary>///Simple Interest Mode/// </summary>/// <returns></returns> Public StaticMessageText Instance () {if(Instance! =NULL)returninstance;instance=NewMessageText ();returninstance;} Dictionary<int,string> dictionary =Newdictionary<int,string>();/// <summary>///Initialize method, read data from table/// </summary> PublicMessageText () {Textasset Textasset= Resources.load<textasset> ("Csv/errorcode");string[] textstrings = TextAsset.text.Split (New Char[] {'\ r','\ n'}, stringsplitoptions.removeemptyentries); for(inti =2; i < textstrings.length; i++){if(Textstrings[i] = =NULL|| Textstrings.length = =0){Continue;}string[] strings = Textstrings[i]. Split (',');if(!dictionary. ContainsKey (Convert.ToInt32 (strings[0])) {dictionary. ADD (Convert.ToInt32 (strings[0]), strings[1]);}} Debug.Log ("Read Success");}
Unity reads CSV table into dictionary