unity+adnroid+根目錄創建文件夾


直接上代碼:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
public class TKGameInit : MonoBehaviour {
    public Text pathText;
    private void Awake()
    {
#if UNITY_ANDROID

        Debug.LogError("777788888");
        TKGlobalData.CurrentSaveDataPath = "/sdcard/TKData/SaveData/";
        if (!Directory.Exists(TKGlobalData.CurrentSaveDataPath))
        {
            Directory.CreateDirectory(TKGlobalData.CurrentSaveDataPath);
        }
        TKGlobalData.CurrentLoadDataPath = "/sdcard/TKData/ServerData/";
        if (!Directory.Exists(TKGlobalData.CurrentLoadDataPath))
        {
            Directory.CreateDirectory(TKGlobalData.CurrentLoadDataPath);

        }
        pathText.text = TKGlobalData.CurrentLoadDataPath;
#elif UNITY_EDITOR
        //Debug.LogError("1111122222222");
        TKGlobalData.CurrentSaveDataPath = Application.persistentDataPath + "/SaveData/data/";
        TKGlobalData.CurrentLoadDataPath = Application.persistentDataPath+"/";
		 if (!Directory.Exists(TKGlobalData.CurrentSaveDataPath))
        {
            Directory.CreateDirectory(TKGlobalData.CurrentSaveDataPath);
        }
		if (!Directory.Exists(TKGlobalData.CurrentLoadDataPath))
        {
             Directory.CreateDirectory(TKGlobalData.CurrentLoadDataPath);
             Debug.LogError("7222111");
        }
		pathText.text = TKGlobalData.CurrentLoadDataPath;
#endif



    }
    // Use this for initialization
    void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TKGlobalData
{
    public static string Btn_CuetomName="";
    public static string VideoPath = Application.persistentDataPath + "/MulPhotos/";
    public static string UserName;
    public static bool IsMan;
    public static int userID;
    public static int loadUserID;
    public static int checkID;
    public static int CurrentSelectProjectID;//當前選擇項目ID
    public static int currentSelectEquiID;//d當前選擇設備ID
    public static int currentSelectWorkShopID;//當前選擇廠房ID
    public static string currentServerDataPath = Application.persistentDataPath;

    public static string CurrentSaveDataPath;
    public static string CurrentLoadDataPath;
    public static List<string> CurrentTextureList;
}

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM