示例#1
0
    //保存されている日食データを初期化する
    private void initPresetEclipseData(string datafilename)
    {
        // Assetsフォルダから読み込む
        string path = Application.dataPath + "/eclipsedata/" + datafilename;

        StreamReader reader     = new StreamReader(path);
        string       jsonstring = reader.ReadToEnd();
        EclipseData  data       = null;

        try
        {
            data = JsonUtility.FromJson <EclipseData>(jsonstring);
            if (data != null && data.initDateTime())
            {
                currenteclipsedata = data;

                start     = currenteclipsedata.getStartTime();
                finish    = currenteclipsedata.getFinishTime();
                current   = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, 0, DateTimeKind.Utc);
                longitude = data.getInitialMapLongitude();
                latitude  = data.getInitialMapLatitude();

                shadowrenderer.setEclipseData(currenteclipsedata, earthshadow, UmbralShadowRenderer.PLAYMODE);
                //setCameraPosition();
                ready = true;
            }
            reader.Close();
        }
        catch (Exception e) { /* Debug.Log("readJson " + e.ToString());*/ }
    }
示例#2
0
 private void setTextAsset(string text, string datafilename)
 {
     if (datafilename.IndexOf(".json") != -1)
     {
         try
         {
             EclipseData data = JsonUtility.FromJson <EclipseData>(text);
             if (data != null && data.initDateTime())
             {
                 EclipseDataHolder.setEclipseData(data);
                 ready = true;
             }
             //reader.Close();
         }
         catch (Exception e) { /*Debug.Log("readJson " + e.ToString());*/ }
     }
 }
示例#3
0
    //日食データをアセットバンドルから初期化する
    IEnumerator initEclipseDataFromAssetBundle(string datafilename)
    {
        string jsonstring = null;

        if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            string       path   = Application.dataPath + "/StreamingAssets/" + datafileprefix + datafilename;
            StreamReader reader = new StreamReader(path);

            jsonstring = reader.ReadToEnd();
            reader.Close();
        }
        else if (Application.platform == RuntimePlatform.Android)
        {
            string bundleUrl = Path.Combine("jar:file://" + Application.dataPath + "!/assets" + "/", datafileprefix + datafilename);
            WWW    www       = new WWW(bundleUrl);
            yield return(www);

            while (!www.isDone)
            {
            }
            jsonstring = www.text;
            //text = "count =" + www.text.Length.ToString();
        }
        try
        {
            EclipseData data = JsonUtility.FromJson <EclipseData>(jsonstring);
            if (data != null && data.initDateTime())
            {
                currenteclipsedata = data;
                EclipseDataHolder.setEclipseData(currenteclipsedata);

                start   = currenteclipsedata.getStartTime();
                finish  = currenteclipsedata.getFinishTime();
                current = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, 0, DateTimeKind.Utc);

                shadowrenderer.setEclipseData(currenteclipsedata, earthshadow, UmbralShadowRenderer.PLAYMODE);
                longitude = data.getInitialCameraLongitude();
                latitude  = data.getInitialCameraLatitude();
                positionUpdated(0.0f, 0.0f);
                ready = true;
            }
            //reader.Close();
        }
        catch (Exception e) { /*Debug.Log("readJson " + e.ToString());*/ }
    }
示例#4
0
    //日食データを初期化する
    private void initEclipseData(string datafilename)
    {
        //Resourceから読み込む
        TextAsset jsondata = (TextAsset)Resources.Load("20300601", typeof(TextAsset));

        //StreamReader reader = new StreamReader(path);
        string      jsonstring = jsondata.text;//reader.ReadToEnd();
        EclipseData data       = null;

        try
        {
            data = JsonUtility.FromJson <EclipseData>(jsonstring);
            if (data != null && data.initDateTime())
            {
                currenteclipsedata = data;

                start   = currenteclipsedata.getStartTime();
                finish  = currenteclipsedata.getFinishTime();
                current = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, 0, DateTimeKind.Utc);
                ready   = true;
            }
        }
        catch (Exception e) {}
    }