当前位置: 首页 > news >正文

wordpress添加超链接seo教程有什么

wordpress添加超链接,seo教程有什么,凡科做的网站怎么改壁纸,常用python编程软件Unity persistentDataPath使用案例 一、Application.persistentDataPath 1、概念 persistentDataPath:此属性用于返回一个持久化数据存储目录的路径,可以在此路径下存储一些持久化的数据文件;是一个可读写的目录;此文件夹在Edi…

Unity persistentDataPath使用案例

一、Application.persistentDataPath

1、概念

persistentDataPath:此属性用于返回一个持久化数据存储目录的路径,可以在此路径下存储一些持久化的数据文件;是一个可读写的目录;此文件夹在Editor阶段没有,手机安装App后自动生成;

关联的概念-Unity项目文件夹StreamingAssets:只能读,不能写。

2、应用场景

1)手机应用场景中存储当前游戏的进度,以便下次运行游戏时读取

如下代码文件,存储游戏中的下列数据coins、starCount = 0、collection

    [Serializable]

    public class SaveData

    {

        //Current loaded save file

        public static SaveData save;

        private static string fileName;

        //Unsaved global variables

        public static bool checkpoint = false;

        public static Vector3 checkpointPos;

        public static Quaternion checkpointRot;

        public static bool hubPositionSet = false;

        //Saved variables

        public int coins = 0;

        public int starCount = 0;

        public List<string> collection = new List<string>();

        //Save

        public void Save()

        {

            System.IO.File.WriteAllText(fileName, JsonUtility.ToJson(this));

        }

        //Load (Make sure fileName is set, will be loaded if it exists)

        public static bool Load()

        {

            if (System.IO.File.Exists(fileName))

            {

                save = JsonUtility.FromJson<SaveData>(System.IO.File.ReadAllText(fileName));

                hubPositionSet = true;

                return true;

            }

            else

                return false;

        }

        //Create new game

        public static void NewGame()

        {

            save = new SaveData();

            hubPositionSet = false;

        }

        public static void SetFileName(string name)

        {

            fileName = Path.Combine(Application.persistentDataPath, name + ".json");

        }

        //Null check

        public static void NullCheck()

        {

            if (save == null)

            {

                SetFileName("TestSave");

                if (!Load()) NewGame();

                Debug.Log("Hello Mario Framework: Using test save file!");

                hubPositionSet = false;

            }

        }

        //Get coin count

        public int GetCoins()

        {

            return coins;

        }

        //Add or remove coins

        public void AddCoins(int i)

        {

            coins += i;

        }

        //Collect a single coin

        public void CollectCoin()

        {

            coins++;

        }

        //Get star count

        public int GetStarCount()

        {

            return starCount;

        }

        //Collect a star (Or ignore if already collected)

        public bool CollectStar(string name)

        {

            if (AddCollection(name))

            {

                starCount++;

                return true;

            }

            else return false;

        }

        //Add to collection

        public bool AddCollection(string id)

        {

            if (!collection.Contains(id))

            {

                collection.Add(id);

                return true;

            }

            else return false;

        }

        //Check if something is in the collection

        public bool CheckCollection(string id)

        {

            return collection.Contains(id);

        }

    }

2)放置一些首次运行时需要的可读写的数据文件

将游戏运行时需要的可读写的文件模板放到只读文件夹“StreamingAssets”,手机首次运行时再拷贝到可读写的目录“Application.persistentDataPath”,

如下实例,游戏在手机平台首次运行时将我们的数据模板文件”data.txt”拷贝到“persistentDataPath”目录,以便于以后在手机端游戏运行时实时读写。

public void copy(string fileName = "data.txt")

{

    string url;

    //Mac,Windows或Linux平台

    #if UNITY_EDITOR || UNITY_STANDALONE

    url = $"file://{Application.dataPath}/StreamingAssets/{fileName}";

    //ios平台路径

    #elif UNITY_IPHONE

            url = $"file://{Application.dataPath}/Raw/{fileName}";

    //安卓路径

    #elif UNITY_ANDROID

            url = $"jar:file://{Application.dataPath}!/assets/{fileName}";

    #endif

    string persistentUrl = $"{Application.persistentDataPath}/{fileName}";

    if (!File.Exists(persistentUrl))

    {

        Debug.Log($"{persistentUrl} 文件不存在,从StreamingAssets中Copy!");

        WWW www = new WWW(url);

        while (true)

        {

            if (www.isDone)

            {

                if (www.error == null)

                {

                    //本次读的文本

                    File.WriteAllText(persistentUrl, www.text);   

                    File.WriteAllBytes(path, www.bytes);

                    Debug.Log($"持久化目录: {persistentUrl}");

                    break;

                }

                else

                {

                    Debug.LogWarning($"没得到StreamingAssets的文件 : {fileName}");

                }

            }

        }

    }

    else

    {

        Debug.Log($"{persistentUrl} 文件已存在!");

    }

}

http://www.ds6.com.cn/news/113980.html

相关文章:

  • 如何将网站建设得更好抖音推广佣金平台
  • 网上投资网站建设长沙seo关键词
  • 怎么做可以聊天的网站关键词调价工具哪个好
  • 上孩做网站广东省新闻
  • 新开的公司怎么做网站网络营销的培训课程
  • 做网站弄什么语言网络营销专业介绍
  • 诈骗网站谁做爱站之家
  • 莱州双语网站咨询公司
  • 免费设计logo的网站有哪些seo快速排名站外流量推广
  • 做h5找图网站seo是干什么的
  • 济南网站开发建设百度企业推广怎么收费
  • 建筑人才网官方太原网站制作优化seo公司
  • 免费优化网站建设网站关键词优化怎么做的
  • 做照片的网站有哪些百度收录快速提交
  • 建设公司网站费用怎么做账b2b网站免费推广
  • 网站管理后台源码seo霸屏软件
  • 嘉兴推广网站网站seo源码
  • 做时时彩网站牌照申请优化大师免费版下载
  • 网站开发方案 文档广告文案经典范例200字
  • 自己网站建设和维护指数基金排名前十名
  • 建设文化产业网站的方案网站快速排名
  • 怎么区分网站的好坏百度网站联系方式
  • 做网商哪个国外网站好河南网站建设制作
  • ps制作网站产品图片品牌网络推广外包
  • 网站用户体现好坏360免费建站
  • 什么网站可以看女人唔易做微信广告投放推广平台
  • 四川泸州做网站的公司有哪些网络营销策划的基本原则
  • 好发信息网网站建设白嫖永久服务器
  • 在对方网站做友情链接新闻营销
  • 专业建站网产品网络推广关键词排名查询工具