Search Unity

Webplayer + Directory.Create?

Discussion in 'Scripting' started by Chaosgod_Esper, Mar 5, 2015.

  1. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    Hi there....

    I created this Script:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6. using System.Runtime.Serialization;
    7. using System.Runtime.Serialization.Formatters.Binary;
    8. using System.IO;
    9. using System.Text;
    10.  
    11. public class Sys_Awaken : MonoBehaviour {
    12.  
    13.    public bool ShouldASceneBeenLoaded = false;
    14.    public string LoadThisFirstScene;
    15.    public UILabel DebugLabel;
    16.  
    17.    public GameObject MapButton;
    18.    private string saveFolder_Data = System.Environment.ExpandEnvironmentVariables("%USERPROFILE%\\BDC\\LWoN\\Data\\");
    19.  
    20.    // Use this for initialization
    21.    void Start () {
    22.      if(DebugLabel != null){DebugLabel.text = "INFO: Hide Cursor";}
    23.      Screen.showCursor = false;
    24.      MapButton.SetActive(false);
    25.      if(DebugLabel != null){DebugLabel.text = "INFO: Ask for Directory";}
    26.      if(!Directory.Exists(saveFolder_Data + "Maps\\")){
    27.        Directory.CreateDirectory(saveFolder_Data);
    28.        Directory.CreateDirectory(saveFolder_Data + "Maps\\");
    29.        if(DebugLabel != null){DebugLabel.text = "INFO: Created Directory";}
    30.      }
    31.      
    32.      //if(DebugLabel != null){DebugLabel.text = "INFO: Ask for Testmap";}
    33.      if(File.Exists(saveFolder_Data + "Maps\\Testmap_Dia.tmd")){
    34.        MapButton.SetActive(true);
    35.      }
    36.  
    37.      if(ShouldASceneBeenLoaded){
    38.        Application.LoadLevel(LoadThisFirstScene);
    39.      }
    40.      //if(DebugLabel != null){DebugLabel.text = "INFO: Finished";}
    41.    }
    42. }
    43.  
    44.  
    as you can see, the script askes if a specific Directory in the User Documents exists. This works in Standalone, but not webplayer.

    Is there a way to ask for Directories, Create Directories, ask for File.Exists and Save/Load Files in Webplayer?
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190