コード例 #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
    //日食データをアセットバンドルから初期化する
    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;
        }
        try
        {
            EclipseData data = JsonUtility.FromJson <EclipseData>(jsonstring);
            if (data != null && data.initDateTime())
            {
                EclipseDataHolder.setEclipseData(data);
                currenteclipsedata = data;

                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.getInitialMapLongitude();
                latitude  = data.getInitialMapLatitude();
                setCameraPosition();
                ready = true;
            }
        }
        catch (Exception e) { /*Debug.Log("readJson " + e.ToString()); */ }
    }
コード例 #3
0
    //EclipseDataHolderからデータを読み込む
    private void initFromEclipseDataHolder()
    {
        EclipseData data = EclipseDataHolder.getEclipseData();

        if (data != null)
        {
            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;
        }
    }