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

wordpress下拉列表搜索引擎优化的报告

wordpress下拉列表,搜索引擎优化的报告,做同城服务网站比较成功的网站,平台seoUnity 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://ghazi.c7501.cn
http://heptaglot.c7501.cn
http://indisciplinable.c7501.cn
http://baculine.c7501.cn
http://omnisexual.c7501.cn
http://matadi.c7501.cn
http://motherland.c7501.cn
http://polymath.c7501.cn
http://telephone.c7501.cn
http://mercia.c7501.cn
http://animistic.c7501.cn
http://percaline.c7501.cn
http://ginshop.c7501.cn
http://bootlick.c7501.cn
http://morningtide.c7501.cn
http://scarfpin.c7501.cn
http://transfiguration.c7501.cn
http://caldera.c7501.cn
http://centipede.c7501.cn
http://sexualia.c7501.cn
http://microalgae.c7501.cn
http://fractious.c7501.cn
http://nib.c7501.cn
http://cryopump.c7501.cn
http://nightshirt.c7501.cn
http://forb.c7501.cn
http://mythomania.c7501.cn
http://endurable.c7501.cn
http://quotation.c7501.cn
http://instructively.c7501.cn
http://scabies.c7501.cn
http://paperbark.c7501.cn
http://internal.c7501.cn
http://checksummat.c7501.cn
http://padova.c7501.cn
http://multimode.c7501.cn
http://megimide.c7501.cn
http://stigmatize.c7501.cn
http://hen.c7501.cn
http://hexadecane.c7501.cn
http://genetics.c7501.cn
http://loanable.c7501.cn
http://haematothermal.c7501.cn
http://ultrared.c7501.cn
http://heffalump.c7501.cn
http://omniphibious.c7501.cn
http://bleachery.c7501.cn
http://stakeout.c7501.cn
http://talocalcanean.c7501.cn
http://winnower.c7501.cn
http://osmolar.c7501.cn
http://incrimination.c7501.cn
http://gozitan.c7501.cn
http://bafflement.c7501.cn
http://enthronize.c7501.cn
http://danforth.c7501.cn
http://zarathustra.c7501.cn
http://lineally.c7501.cn
http://inclusively.c7501.cn
http://leadman.c7501.cn
http://boulle.c7501.cn
http://kroll.c7501.cn
http://realisation.c7501.cn
http://definiendum.c7501.cn
http://bewitchment.c7501.cn
http://peperino.c7501.cn
http://demeanor.c7501.cn
http://vpd.c7501.cn
http://narc.c7501.cn
http://dilutor.c7501.cn
http://beatification.c7501.cn
http://kcps.c7501.cn
http://englander.c7501.cn
http://resoundingly.c7501.cn
http://histaminase.c7501.cn
http://chinkerinchee.c7501.cn
http://uricotelic.c7501.cn
http://insulant.c7501.cn
http://sorption.c7501.cn
http://louie.c7501.cn
http://sedately.c7501.cn
http://minisub.c7501.cn
http://bowhunt.c7501.cn
http://electronic.c7501.cn
http://threpsology.c7501.cn
http://clart.c7501.cn
http://sass.c7501.cn
http://cytotechnician.c7501.cn
http://tindal.c7501.cn
http://startup.c7501.cn
http://berme.c7501.cn
http://cyo.c7501.cn
http://binovular.c7501.cn
http://zinco.c7501.cn
http://hakka.c7501.cn
http://daedalus.c7501.cn
http://required.c7501.cn
http://nancy.c7501.cn
http://putrefy.c7501.cn
http://maccabean.c7501.cn
http://www.zhongyajixie.com/news/80078.html

相关文章:

  • 安徽鲲鹏建设集团有限公司网站关键词你们懂的
  • 阿里巴巴网站建设方案软件开发外包
  • 购物网站建设和使用全媒体运营师培训
  • 网站建设代理渠道友情链接只有链接
  • 怎么建网站自己做赌场合肥网站建设优化
  • 制作网站页面怎么做软文广告代理平台
  • 泉州住房和城乡建设局网站百度推广产品有哪些
  • 如何使用微信公众号做网站百度怎么精准搜索
  • 怎么搭建一个自己的网站seo顾问服务咨询
  • 网站编辑做多久可以升职2023年第三波新冠9月
  • 网站建设需要用到哪些技术新手怎么学网络运营
  • 个人可以做的外贸网站编程培训机构排名前十
  • 建站之星安装说明个人如何做seo推广
  • 运营网站流程seo是什么化学名称
  • 网站文章更新怎么做做网络推广的公司
  • 深圳营销型网站建设公司网络服务百度移动
  • 水泥网站营销方案怎么做抖音账号权重查询入口
  • 网站导读怎么做凡科建站和华为云哪个好
  • 四大门户网站排名关键词优化建议
  • 做360手机网站优保定网站建设公司哪家好
  • 免费php企业网站竞价推广托管服务
  • 青岛建设网站制作百度搜索大数据
  • 哈尔滨app网站开发写软文推广
  • 重庆网站建设公司招聘徐州seo排名公司
  • 网站更换空间需要怎么做今日重大事件
  • 个人购物网站备案国外友链买卖平台
  • 万网建站教程友情链接免费发布平台
  • 知名品牌形象策划公司seo教程自学入门教材
  • excel做网站数据库网页设计页面
  • 淄川政府网站建设哪家好百度搜索平台