Exemplo n.º 1
0
    void Start()
    {
        if (BibaContentConstants.ENVIRONMENT == Environment.Development)
        {
            var jsonService = new JSONDataService();
            var version     = jsonService.ReadFromDisk <BibaVersion> (BibaContentConstants.GetResourceFilePath(BibaContentConstants.BIBAVERSION_FILE));

            GetComponent <Text> ().text = version.Version + "." +
                                          version.BuildNumber + " " +
                                          BibaContentConstants.ENVIRONMENT.ToString().Substring(0, 3);
        }
    }
Exemplo n.º 2
0
        public T ReadFromDisk <T>(string path)
        {
            Debug.Log(string.Format("Reading: {0}", path));

            //Check if file is accessible in the fileSystem
            if (File.Exists(path))
            {
                return(JsonUtility.FromJson <T>(File.ReadAllText(path)));
            }

            //Check in the Resources folder if not found in the file system
            var textAsset = Resources.Load <TextAsset>(BibaContentConstants.GetRelativePath(Path.GetFileNameWithoutExtension(path)));

            if (textAsset != null && !string.IsNullOrEmpty(textAsset.text))
            {
                return(JsonUtility.FromJson <T>(textAsset.text));
            }

            return(Activator.CreateInstance <T>());
        }
Exemplo n.º 3
0
        IEnumerator LoadLevelAsync()
        {
            AsyncOperation asyncOp;
            var            specialSceneId    = SpecialSceneLoaderService.GetNextSceneToShow(NextMenuState.SceneName);
            var            persistedFilePath = BibaContentConstants.GetPersistedPath(specialSceneId + BibaContentConstants.UNITY3D_EXTENSION);

            if (!string.IsNullOrEmpty(specialSceneId) && File.Exists(persistedFilePath))
            {
                persistedFilePath = FILE_SUFFIX + persistedFilePath;

                using (WWW www = WWW.LoadFromCacheOrDownload(persistedFilePath, 1))
                {
                    yield return(www);

                    if (www.error != null)
                    {
                        throw new Exception("WWW download had an error:" + www.error);
                    }

                    www.assetBundle.LoadAsset(specialSceneId);

                    asyncOp = Application.LoadLevelAdditiveAsync(specialSceneId);
                    yield return(asyncOp);

                    www.assetBundle.Unload(false);
                    www.Dispose();
                }
            }
            else
            {
                asyncOp = Application.LoadLevelAdditiveAsync(NextMenuState.SceneName);
                yield return(asyncOp);
            }

            LevelLoaded();
        }