美文网首页总结Unity知识归纳
移动端外部配置文件读写

移动端外部配置文件读写

作者: IongX | 来源:发表于2017-04-11 15:23 被阅读8次
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System;
public class DoFileTest : MonoBehaviour {

    public Text PathText;
    public Text ResultText;
    public InputField TestField;

    public string filepath;
    // Use this for initialization
    void Start ()
    {
        filepath = Application.persistentDataPath + "/file.txt";
        PathText.text = filepath;
    }
    
    public void ReadFile()
    {
        try
        {
            StreamReader sr = new StreamReader(filepath);
            string ss = sr.ReadToEnd();
            Debug.Log(ss);
            ResultText.text = ss;
        }catch(Exception e)
        {
            ResultText.text = e.Message;
        }

    }


    public void OnBtnClick()
    {
        Debug.Log(TestField.text + "       shengc");
        try
        {
            FileStream fs = new FileStream(filepath, FileMode.Create);
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(TestField.text);
            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Close();         
        }
        catch(Exception e)
        {
            Debug.Log("保存失败!!!!");
        }

    }
}

unity3d读取外部文件详细 :

http://www.cnblogs.com/murongxiaopifu/p/4199541.html

相关文章

  • 移动端外部配置文件读写

    unity3d读取外部文件详细 : http://www.cnblogs.com/murongxiaopifu/...

  • Vue项目配置

    vue-cli配置、网络请求配置、移动端配置 # vue-cli配置:vue.config.js配置文件 配置文件...

  • 一张图看懂Unity热更新基本流程

    因为在移动端真机上只有 Application.persistentDataPath 目录是可读写的,所以热更新需...

  • NFS 部署

    服务端 编辑配置文件/etc/exports来配置我们的NFS服务的访问和同步策略ro 只读rw 可读写sync ...

  • 移动端系统存取配置文件

    一、Android获取配置 书写配置 参考:https://www.cnblogs.com/huangjie123...

  • Django下移动端调试Web项目全过程(图文)

    查看本机ip Django项目settings.py中添加host 开启外部访问 移动端输入ip地址进行访问 这样...

  • 接口测试 笔记

    接口 连接前后端以及移动端 接口测试就是测试系统组件接口之间的一种测试 外部接口:测试被测系统和外部系统之间的接口...

  • Vue<滑动标尺>

    找了很多资料,发现这类的很少,而且很多的兼容性不好。这个可以在PC端以及移动端使用,但是用起来需要引用外部js。(...

  • day14 MyCAT--分布式及优化

    六、配置文件模板说明(读写分离) 七 、配置文件--读写分离+高可用 八、垂直分库 九、垂直分表 十、 MyCAT...

  • C++与Rust引用外部符号的比较

    文档列表见:Rust 移动端跨平台复杂图形渲染项目开发总结 - 目录 通常,C/C++通过#include导入外部...

网友评论

    本文标题:移动端外部配置文件读写

    本文链接:https://www.haomeiwen.com/subject/owxuattx.html