コード例 #1
0
ファイル: Util.cs プロジェクト: PointLineAharaLab/PointLine
 private static void LoadFileUsingPath(string path)
 {
     ClickOnPanel.DeleteAll();
     if (path != null && path.Length != 0)
     {
         try
         {
             using (StreamReader reader = new StreamReader(path, false))
             {
                 InitLog();
                 string str;
                 int    PId = -1, LId = -1, CId = -1, MId = -1;
                 do
                 {
                     str = reader.ReadLine();
                     if (str == null)
                     {
                         break;             //多分要らない。
                     }
                     else
                     {
                         Log lg = GetLogFromString(str);
                         //AddLog(lg);
                         if (lg.ObjectType == "Point")
                         {
                             if (PId < lg.Id)
                             {
                                 PId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Line")
                         {
                             if (LId < lg.Id)
                             {
                                 LId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Circle")
                         {
                             if (CId < lg.Id)
                             {
                                 CId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Module")
                         {
                             if (MId < lg.Id)
                             {
                                 MId = lg.Id;
                             }
                         }
                     }
                 }while (str != null);
                 reader.Close();
                 ClickOnPanel.SetId(PId + 1, LId + 1, CId + 1, MId + 1);
                 AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
                 AppMgr.lns = MonoBehaviour.FindObjectsOfType <Line>();
                 AppMgr.cis = MonoBehaviour.FindObjectsOfType <Circle>();
                 AppMgr.mds = MonoBehaviour.FindObjectsOfType <Module>();
             }
         }
         catch (Exception e)
         {
             Debug.Log(e.Message);
         }
     }
     else
     {
         Debug.Log("Invalid path given");
     }
     AppMgr.DrawOn       = true;
     AppMgr.KeyOn        = true;
     AppMgr.FileDialogOn = false;
 }