示例#1
0
    public IEnumerator ExtractResourceCoroutine()
    {
        var _7zPath = Path.Combine(Application.persistentDataPath, _compressUpdaterFile);

        if (File.Exists(_7zPath))
        {
            File.Delete(_7zPath);
        }

        BetterStreamingAssets.Initialize();

        _writeStream = new FileStream(_7zPath, FileMode.CreateNew);

        _readStream = BetterStreamingAssets.OpenRead(_compressUpdaterFile);

        _fileAsyncState = new AsyncFileOp.FileAsyncState(_readStream, _writeStream, true);


        AsyncFileOp.CopyAsync(_fileAsyncState);

        while (true)
        {
            if (_fileAsyncState.isDone)
            {
                var path1 = Path.Combine(Application.persistentDataPath, _compressUpdaterFile);
                _extractState = ExtractState.ING;
                plugin_7z.Extract7z(path1, Application.persistentDataPath, this.gameObject.name);

                break;
            }

            yield return(null);
        }
    }
示例#2
0
    bool LoadByteCodeByFile()
    {
        string szPathName = "test.code";

        print_error("开始加载, 路径:" + szPathName);
        try
        {
            BetterStreamingAssets.Initialize();

            byte[] fileData = BetterStreamingAssets.ReadAllBytes(szPathName);
            if (fileData != null && fileData.Length > 0)
            {
                print_error("加载成功:" + szPathName + ", 字节大小:" + fileData.Length.ToString());
                FCLibHelper.fc_set_code_data(fileData, fileData.Length, 0);
                OnAfterLoadScriptData();
                return(true);
            }
        }
        catch (Exception e)
        {
            print_error(e.ToString());
        }
        print_error("加载失败:" + szPathName);
        return(false);
    }
示例#3
0
 void Start()
 {
     GameManager.instance.langReader = this;
     BetterStreamingAssets.Initialize();
     GetLangs();
     LoadLang();
 }
    public override void Save(eSaveType saveType)
    {
        strSave = "";

        JSONNode data;

        BetterStreamingAssets.Initialize();
        data = JSON.Parse(BetterStreamingAssets.ReadAllText(path));

        foreach (var iter in data)
        {
            strSave += iter.Value["skinName"] + ":";

            if (PlayerData.Instance.skinList.ContainsKey(iter.Value["skinName"]))
            {
                strSave += PlayerData.Instance.skinList[iter.Value["skinName"]].ToString();
            }
            else
            {
                strSave += false.ToString();
            }

            strSave += "/";
        }

        strSave = strSave.Remove(strSave.Length - 1);

        base.Save(saveType);
    }
示例#5
0
    string dbFileName = "/inout.db"; //@"/innerData.db";


    public void Init()
    {
        dbPath = Application.persistentDataPath + dbFileName;

        if (!PlayerPrefs.HasKey("dbPath"))
        {
            PlayerPrefs.SetString("dbPath", dbPath);
        }

        Common.GetInstance.PrintLog('w', "SqliteMgr", dbPath);

        //check DB file exist
        //Debug.LogWarning("copy db files");
        if (ConstValue.CLEARDB && File.Exists(dbPath)) //remove db file on dev mode
        {
            File.Delete(dbPath);
        }

        if (!File.Exists(dbPath))
        {
            BetterStreamingAssets.Initialize();
            byte[] readByte = BetterStreamingAssets.ReadAllBytes(dbFileName);
            File.WriteAllBytes(dbPath, readByte);
        }
    }
示例#6
0
        public static T LoadJsonFromStreamingAssets <T>(string key)
        {
            BetterStreamingAssets.Initialize();
            string dataAsJson = BetterStreamingAssets.ReadAllText(key + JsonExtension);

            return(JsonUtility.FromJson <T>(dataAsJson));
        }
示例#7
0
 // Start is called before the first frame update
 void Start()
 {
     Debug.Log("Start Method");
     BetterStreamingAssets.Initialize();
     setData();
     LoadTargetData();
 }
示例#8
0
        public static T LoadNewtonsoftJsonFromStreamingAssets <T>(string key)
        {
            BetterStreamingAssets.Initialize();
            string dataAsJson = BetterStreamingAssets.ReadAllText(key + JsonExtension);

            return(JsonConvert.DeserializeObject <T>(dataAsJson, new JsonApiSerializerSettings()));
        }
示例#9
0
        public static Dictionary <string, object> LoadDictionaryFromStreamingAssets(string key)
        {
            BetterStreamingAssets.Initialize();
            string dataAsJson = BetterStreamingAssets.ReadAllText(key + JsonExtension);

            return(JsonConvert.DeserializeObject <Dictionary <string, object> >(dataAsJson, new GenericConverter()));
        }
示例#10
0
    private void Start()
    {
        Instance = this;
        onStop.Invoke();

        RetrieveSyncSettings();         //Retrieve the sync settings from saved settings on the device!

        HasVideoLoaded = false;

        timeSlider.onValueChanged.AddListener(delegate(float val) {
            /*if(onlyOneDevice || !AllowedToChangeTimeOrPause) {
             *      timeSlider.SetValueWithoutNotify((float)VideoTime/TotalVideoTime);
             *      return;
             * }*/                              //<- this code, if uncommented, prevents the time slider from being modified when playing back video for a single device
            float time = val * TotalVideoTime;
            videoPlayer.Control.SeekFast(time); //set guide video time
            //send packet to force user device to reach selected time
            GuideAdapter.Instance.SendGotoTime(videoPlayer.Control.GetCurrentTime());
            if (Playing)
            {
                Pause();                //force it to pause so that the guide will need to press Play, giving enough time for the VR device to catch up.
            }
        });
        BetterStreamingAssets.Initialize();
    }
示例#11
0
    private void Start()
    {
        Camera.main.backgroundColor = DeviceColour.getDeviceColor(SystemInfo.deviceUniqueIdentifier);        //Set background colour to something unique
        Instance   = this;
        mainCamera = Camera.main;
        player     = GetComponent <MediaPlayer>();

        choiceContainer.SetActive(false);
        blackScreen.SetActive(false);

        BinauralAudio = false;

        /*
         * player.errorReceived += delegate (VideoPlayer player, string message) {
         *      Haze.Logger.LogError("VideoPlayer error: " + message);
         *      errorWhileLoading = true;
         *      endOfVideo();
         * };
         */

        if (VRDevice.MirageSolo)
        {
            GameObject.Instantiate(gvrControllerInput);            //Create the controller input manager for Daydream version
        }

        BetterStreamingAssets.Initialize();
    }
示例#12
0
    private void Awake()
    {
        BetterStreamingAssets.Initialize();

        FileToData();
        CreateContent();
    }
示例#13
0
    Color[,] PNGtoArray(string folder, string file)
    {
        //Texture2D tex = null;
        byte[] fileData;

        BetterStreamingAssets.Initialize();


        fileData = BetterStreamingAssets.ReadAllBytes(folder + "/" + file + ".png");
        tex      = new Texture2D(2, 2);
        tex.LoadImage(fileData);


        Color[,] Array = new Color[tex.width, tex.height];

        for (int i = 0; i < tex.width; i++)
        {
            for (int j = 0; j < tex.height; j++)
            {
                Array[i, j] = (tex.GetPixel(i, j));
            }
        }

        return(Array);
    }
示例#14
0
    // Start is called before the first frame update
    void Start()
    {
        BetterStreamingAssets.Initialize();

        string[] paths2 = BetterStreamingAssets.GetFiles("new_trash", "*.png", System.IO.SearchOption.AllDirectories);
        GameController = GameObject.FindGameObjectWithTag("GameController");
        sp             = GameController.GetComponent <SpritePickerAR>();



        int r = UnityEngine.Random.Range(0, paths2.Length);

        Debug.Log(r);

        string ok = paths2[r];

        ok = ok.Remove(0, 10);
        ok = ok.Replace(".png", string.Empty);

        Debug.Log(ok);


        this.name = ok;
        var sprite_res = Resources.Load <Sprite>("NewTrashToSpawn/" + ok);

        this.GetComponent <Image>().sprite = sprite_res;
    }
示例#15
0
    void Start()
    {
        txt = gameObject.GetComponent <Text>();

        BetterStreamingAssets.Initialize();

        txt.text = BetterStreamingAssets.ReadAllText(fileName + ".txt");
    }
示例#16
0
        private void Start()
        {
            var deviceInitializer = GetComponentInChildren <IVRDeviceInitializer>();
            var device            = deviceInitializer.CreateDevice();

            VRDevice.Initialize(device);
            VRDevice.Device.SetupAvatar(Avatar);
            BetterStreamingAssets.Initialize();
        }
示例#17
0
    // Start is called before the first frame update
    void Start()
    {
        BetterStreamingAssets.Initialize();
        #if UNITY_ANDROID
        Screen.orientation = ScreenOrientation.LandscapeLeft;
        Screen.fullScreen  = false;
        #endif

        loadCards();
    }
示例#18
0
    void creditos()
    {
        string texto;
        string arquivo;

        arquivo = "Credits.txt";

        BetterStreamingAssets.Initialize();
        texto         = BetterStreamingAssets.ReadAllText(arquivo);
        credito.text += texto;
    }
示例#19
0
    void Start()
    {
        BetterStreamingAssets.Initialize();
        //DontDestroyOnLoad(gameObject);

        setData();

        LoadGameData();
        LoadPlayerProgress();

        SceneManager.LoadScene("Quiz Scene", LoadSceneMode.Additive);
    }
示例#20
0
    private void Awake()
    {
        if (Config.Loaded == false)
        {
            BetterStreamingAssets.Initialize();
            Config.Loaded = true;
        }

        DontDestroyOnLoad(this);

        LoadLocalDB();
    }
示例#21
0
    void Awake()
    {
        if (Config.Loaded == false)
        {
            BetterStreamingAssets.Initialize();
            Config.Loaded = true;
        }


        DontDestroyOnLoad(this);

        LoadConfigUsingJson();
    }
示例#22
0
    private void Start()
    {
        Settings.PlayMode = 3;

        BetterStreamingAssets.Initialize();

        bool easy_exist   = BetterStreamingAssets.FileExists("/SudokuSample/easy.txt");
        bool medium_exist = BetterStreamingAssets.FileExists("/SudokuSample/medium.txt");
        bool hard_exist   = BetterStreamingAssets.FileExists("/SudokuSample/hard.txt");

        if (!easy_exist || !medium_exist || !hard_exist)
        {
            Settings.PlayMode = 0;
            return;
        }

        string easy_all_text   = BetterStreamingAssets.ReadAllText("/SudokuSample/easy.txt");
        string medium_all_text = BetterStreamingAssets.ReadAllText("/SudokuSample/medium.txt");
        string hard_all_text   = BetterStreamingAssets.ReadAllText("/SudokuSample/hard.txt");

        string[] easy_maps   = easy_all_text.Split('\n');
        string[] medium_maps = medium_all_text.Split('\n');
        string[] hard_maps   = hard_all_text.Split('\n');

        int easy_cnt = 0;

        foreach (var map in easy_maps)
        {
            fileManager.StartSaving($"easy{easy_cnt++}", map);
        }
        Settings.Easy_Cnt = easy_cnt;

        int medium_cnt = 0;

        foreach (var map in medium_maps)
        {
            fileManager.StartSaving($"medium{medium_cnt++}", map);
        }
        Settings.Medium_Cnt = medium_cnt;

        int hard_cnt = 0;

        foreach (var map in hard_maps)
        {
            fileManager.StartSaving($"hard{hard_cnt++}", map);
        }
        Settings.Hard_Cnt = hard_cnt;

        print($"Installed {easy_cnt}, {medium_cnt}, {hard_cnt}");
    }
示例#23
0
 private void setUpLanguage()
 {
     BetterStreamingAssets.Initialize();
     if (Application.systemLanguage == SystemLanguage.Russian ||
         Application.systemLanguage == SystemLanguage.Ukrainian ||
         Application.systemLanguage == SystemLanguage.Belarusian)
     {
         nameLanguagesFile = "ruru";
     }
     else
     {
         nameLanguagesFile = "enus";
     }
 }
示例#24
0
    // Start is called before the first frame update
    void Start()
    {
        string          texto;
        string          arquivo;
        TextMeshProUGUI titulo;

        arquivo = "Title.txt";

        BetterStreamingAssets.Initialize();
        texto = BetterStreamingAssets.ReadAllText(arquivo);

        titulo      = gameObject.GetComponent <TextMeshProUGUI>();
        titulo.text = texto;
    }
示例#25
0
    /// <summary>
    /// Método que crea la base de datos y la rellena.
    /// </summary>
    public void CreateDB()
    {
        ArrayPow2();

        //Creación de tablas si no existen
        _connection.CreateTable <Textura>();
        _connection.CreateTable <Buildings>();
        _connection.CreateTable <Numeracion>();

        try
        {
            if (this.GetTamtablaTexture() == 0)
            {
                //Sí la BBDD está vacia carga las texturas de prueba
                if (Application.platform == RuntimePlatform.Android)
                {
                    BetterStreamingAssets.Initialize();
                    string[] dirs = BetterStreamingAssets.GetFiles("texturasInicial", "*.*");


                    foreach (string nombreimage in dirs)
                    {
                        if (!nombreimage.Contains(".meta") && (nombreimage.Contains(".jpg") || nombreimage.Contains(".png")))
                        {
                            string[] subfile = nombreimage.Split('/');
                            GuardarImagen(BetterStreamingAssets.ReadAllBytes(nombreimage), subfile[1]);
                        }
                    }
                }
                else
                {
                    //analiza si hay nuevas fotos de prueba que añadir y las añade
                    string[] dirs = System.IO.Directory.GetFiles(@"Assets/StreamingAssets/texturasInicial");

                    foreach (string nombreimage in dirs)
                    {
                        if (!nombreimage.Contains(".meta") && (nombreimage.Contains(".jpg") || nombreimage.Contains(".png")))
                        {
                            string[] subfile = nombreimage.Split('\\');

                            GuardarImagen(File.ReadAllBytes(@"Assets/StreamingAssets/texturasInicial/" + subfile[1]), subfile[1]);
                        }
                    }
                }
            }
        }
        catch { Debug.Log("No existe la carpeta TexturaInicial"); }
        return;
    }
示例#26
0
        /// <summary>
        /// Import the list of objects in objectList.
        /// </summary>
        protected virtual void Start()
        {
            string texto;
            string arquivo;

            if (autoLoadOnStart)
            {
                //variaveis
                arquivo = "Models.txt";
                Debug.Log(arquivo);
                BetterStreamingAssets.Initialize();
                texto = BetterStreamingAssets.ReadAllText(arquivo);
                int[] separacoes = new int[2];
                int   i = 0, cont = 0;
                //carregar a lista de objectos a importar
                do
                {
                    separacoes[0] = i;
                    Debug.Log("Entrou com cont = " + cont);
                    //pega o endereco do modelo
                    for (int j = 0; i < texto.Length && j < 8; i++)
                    {
                        if (texto[i] == '\n' || texto[i] == ' ')
                        {
                            if (j < 1)
                            {
                                separacoes[1] = i;
                            }
                            //Debug.Log(separacoes[j]);
                            j++;
                        }
                    }

                    //configura para carregar o modelo
                    ModelImportInfo mii = new ModelImportInfo();
                    mii.name = "object" + cont;
                    this.objectsList.Add(mii);
                    this.objectsList[cont].path = texto.Substring(separacoes[0], separacoes[1] - separacoes[0] - 1);
                    if (objectsList[cont].path[objectsList[cont].path.Length - 1] == 10)
                    {
                        objectsList[cont].path = objectsList[cont].path.Substring(0, objectsList[cont].path.Length - 2);
                    }
                    cont++;
                } while (i < texto.Length);

                //importar os  modelos
                ImportModelListAsync(objectsList.ToArray());
            }
        }
示例#27
0
 public void Awake()
 {
     if (IsLoaded)
     {
         return;
     }
     BetterStreamingAssets.Initialize();
     GameData    = new GameData(this);
     SaveManager = new SaveManager();
     if (SaveManager.SaveExists("save"))
     {
         SaveManager.Load("save");
     }
     IsLoaded = true;
 }
示例#28
0
    // Start is called before the first frame update
    void Start()
    {
        BetterStreamingAssets.Initialize();
        string filePath = System.IO.Path.Combine("term", "obj");

        filePath = System.IO.Path.Combine(filePath, SceneManager.GetActiveScene().name + ".txt");
        Debug.Log(filePath);
        string newText = "";

        foreach (string item in BetterStreamingAssets.ReadAllLines(filePath))
        {
            newText += item + "\n";
        }
        text.text = newText;
    }
示例#29
0
    private void Awake()
    {
        BetterStreamingAssets.Initialize();

        localPath = string.Format("{0}/GymnasticVideo", Application.persistentDataPath);

        //get gymnastic file list
        files = new List <string>();

#if UNITY_EDITOR
        StreamReader sReader = new StreamReader(Path.Combine(Application.streamingAssetsPath, "GymnasticInfo.csv"));
#elif UNITY_ANDROID
        StreamReader sReader = BetterStreamingAssets.OpenText("GymnasticInfo.csv");
#endif
        string readData;

        if (sReader == null)
        {
            Debug.LogWarning("sReader null");
        }
        else
        {
            while ((readData = sReader.ReadLine()) != null)
            {
                //Debug.LogWarning("data : " + sReader.ReadLine());
                try
                {
                    files.Add(readData.Split(',')[0]);
                }
                catch (Exception e)
                {
                    //Debug.LogWarning("not pose data in " + idx + " : " + e.Message);
                }
            }
            sReader.Close();
            sReader = null;
        }
        //end

        //check directory
        if (!Directory.Exists(localPath))
        {
            Directory.CreateDirectory(localPath);
        }

        //check exist files & file download contain under coroutine
        StartCoroutine(StartDownLoad());
    }
示例#30
0
    private void Start()
    {
        rawImage = gameObject.GetComponent <RawImage>();

        imageName = "Image" + gameObject.name + ".png";

        BetterStreamingAssets.Initialize();

        thisTexture = new Texture2D(100, 100);

        byte[] bytes = BetterStreamingAssets.ReadAllBytes(imageName);

        thisTexture.LoadImage(bytes);
        thisTexture.name = imageName;
        rawImage.texture = thisTexture;
    }