Exemplo n.º 1
0
    /// <summary>
    /// 保存本地存储数据
    /// </summary>
    public static void SaveLocalSaveData()
    {
        string path    = UniversalTool.GetSaveFilePath("LocalSaveData.json");
        string jsonStr = JsonMapper.ToJson(StaticData.playerInfoData.CurLocalSaveData);

        UniversalTool.SaveJson(path, jsonStr);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 加载本地存储数据
    /// </summary>
    public static void LoadLocalSaveData()
    {
        string path = UniversalTool.GetSaveFilePath("LocalSaveData.json");
        string json = UniversalTool.LoadJson(path);

        if (!string.IsNullOrEmpty(json))
        {
            StaticData.playerInfoData.CurLocalSaveData = JsonMapper.ToObject <LocalSaveData>(json);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 保存地鼠信息到json
    /// </summary>
    public void SaveMouseInfo()
    {
        if (isUser)
        {
            mouseGenerateInfo.IsActiveMouse = isActive;
        }
        string path    = UniversalTool.GetSaveFilePath("MonarMouse.json");
        string jsonStr = JsonMapper.ToJson(mouseGenerateInfo);

        UniversalTool.SaveJson(path, jsonStr);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 私聊信息存储
    /// </summary>
    /// <param name="fileName"></param>
    public static void PrivateChatSaveFile()
    {
        //需要保存的文件名称
        string path = UniversalTool.GetSaveFilePath("PrivateChatMessages.json");

        string jisonSre = JsonMapper.ToJson(_privateChannelMessages);

        UniversalTool.SaveJson(path, jisonSre);

        Debug.Log("接收消息就存储 存储地址:" + path);
    }
Exemplo n.º 5
0
    //传的参数是自己获取的图片
    private IEnumerator DownLoadTexture2d(Texture2D texture)
    {
        //截图操作  
        yield return(UniversalTool.StaticWaitForEndOfFrame);

        //截图保存的图片
        byte[] bytes = texture.EncodeToPNG();

        //获取系统时间  
        System.DateTime now = new System.DateTime();
        now = System.DateTime.Now;
        string filename = string.Format("image{0}{1}{2}{3}.png", now.Day, now.Hour, now.Minute, now.Second);

        filename = "/PhotoAlbum" + filename;
        //
        string Path_save   = UniversalTool.GetSaveFilePath(filename);
        string destination = Path_save.Replace(filename, "/PhotoAlbum");

        //
        filename = filename.Replace("/PhotoAlbum", "");

        //本地存储
        File.WriteAllBytes(Path_save, bytes);

        //应用平台判断,路径选择  
        if (Application.platform == RuntimePlatform.Android)
        {
            //destination = "/mnt/sdcard/DCIM/Screenshots";
#if UNITY_ANDROID
            Debug.Log("将文件图片写入地址!");
            toastAblumImg(destination, filename);

            // 安卓在这里需要去 调用原生的接口去 刷新一下,不然相册显示不出来
            using (AndroidJavaClass playerActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                using (AndroidJavaObject jo = playerActivity.GetStatic <AndroidJavaObject>("currentActivity"))
                {
                    Debug.Log("scanFile:m_androidJavaObject ");
                    jo.Call("scanFile", Path_save);
                }
            }
#endif
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
#if UNITY_IPHONE
            _SavePhoto(Path_save);
#endif
        }
        //下载完成
        DownloadCompleted?.Invoke();
    }
Exemplo n.º 6
0
    /// <summary>
    /// 加载私聊文件
    /// </summary>
    public static void LoadPrivateChatFile()
    {
        string path = UniversalTool.GetSaveFilePath("PrivateChatMessages.json", false);

        if (String.IsNullOrEmpty(path))
        {
            return;
        }

        string json = UniversalTool.LoadJson(path);

        if (!String.IsNullOrEmpty(json))
        {
            _privateChannelMessages = null;
            _privateChannelMessages = JsonMapper.ToObject <List <PrivateChatSaveInfo> >(json);
        }
    }
Exemplo n.º 7
0
 /// <summary>
 /// 加载地鼠存储的信息
 /// </summary>
 public void LoadMouseInfo()
 {
     if (mouseGenerateInfo == null)
     {
         string path = UniversalTool.GetSaveFilePath("MonarMouse.json");
         string json = UniversalTool.LoadJson(path);
         StaticData.DebugGreen(path);
         if (!String.IsNullOrEmpty(json))
         {
             mouseGenerateInfo = JsonMapper.ToObject <MouseGenerateInfo>(json);
         }
         else
         {
             mouseGenerateInfo = new MouseGenerateInfo();
         }
         if (isUser)
         {
             isActive = mouseGenerateInfo.IsActiveMouse;
         }
     }
 }