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

中企动力做的网站价格区间网络营销软件条件

中企动力做的网站价格区间,网络营销软件条件,tp框架可以做网站吗,那些网站可以做淘宝店铺推广项目需求为: 1.实现存档列表,显示存档截图,可以查看之前保存的所有存档 2.点击存档直接加载到场景 首先,定义两个类,用于声明存档列表和存档所需要的List [System.Serializable] public class SaveData {//存储目标…

项目需求为:

1.实现存档列表,显示存档截图,可以查看之前保存的所有存档

2.点击存档直接加载到场景

首先,定义两个类,用于声明存档列表和存档所需要的List

[System.Serializable]
public class SaveData
{//存储目标物的位置和朝向public List<Vector3> targetPosition = new List<Vector3>();public List<Quaternion> targetRotation = new List<Quaternion>();//保存截图public string targetImg;
}[System.Serializable]
public class SaveList
{   //存档列表存储各个存档的地址public List<string> DataPath = new List<string>();
}

存储存档列表、存档

//存档
public void TestSave()
{        //取当前时间来做存档的名字string now = DateTime.Now.ToString("yyyy-M-d-HH-mm-ss");string path = Application.dataPath + "/StreamingFile/" + now;//调用存档方法SaveData saveData = CreatSave(path);//利用jsonutility将savedata转为jsonstring saveJson = JsonUtility.ToJson(saveData);//将json写入文件//新建StreamWriter,写入jsonStreamWriter streamWriter = new StreamWriter(path + ".json");streamWriter.Write(saveJson);//关闭StreamWriterstreamWriter.Close();TestListSave(path);Debug.Log("保存成功");
}/// <summary>
/// 存储存档列表
/// </summary>
/// <param name="pathname"></param>
void TestListSave(string pathname)
{SaveList sl = new SaveList();string path = Application.dataPath + "/StreamingFile/list.list";//alllist是临时List,用于存所有的存档个数alllist.Add(pathname);sl.DataPath = alllist;//将所有的存档个数打包保存(覆盖式)string saveList = JsonUtility.ToJson(sl);StreamWriter streamWriter = new StreamWriter(path);streamWriter.Write(saveList);streamWriter.Close();        
}/// <summary>
/// 创建Save对象,存储当前状态
/// </summary>
/// <returns></returns>
private SaveData CreatSave(string path)
{SaveData saveTest = new SaveData();//all是所有的目标物的父物体,将位置和旋转存入listfor (int i = 0;i < all.childCount;i++){saveTest.targetPosition.Add(all.GetChild(i).position);saveTest.targetRotation.Add(all.GetChild(i).rotation);}//将存档截图地址保存saveTest.targetImg = path;//截图功能CameraCapture(path, main, new Rect(0, 0, Screen.width, Screen.height));return saveTest;
}

截图相关代码

  
//指定相机指定范围
public static void CameraCapture(string i, Camera camera, Rect rect)
{        string path = Path.Combine(i, $"{i}.png");int w = (int)rect.width;int h = (int)rect.height;RenderTexture rt = new RenderTexture(w, h, 0);//将相机渲染内容存到指定RenderTexturecamera.targetTexture = rt;camera.Render();//激活指定RenderTextureRenderTexture.active = rt;//参数4:mipchain多级渐远纹理Texture2D t2D = new Texture2D(w, h, TextureFormat.ARGB32, true);//防止截黑屏,可能会报错//yield return new WaitForEndOfFrame();//把RenderTexture像素读到texture2dt2D.ReadPixels(rect, 0, 0);t2D.Apply();//存成PNGbyte[] bytes = t2D.EncodeToPNG();File.WriteAllBytes(path, bytes);//用完重置、销毁camera.targetTexture = null;RenderTexture.active = null;GameObject.Destroy(rt);
}public static Sprite LoadShot(string i)
{string shotPath = Application.dataPath + "/StreamingFile/Shot";var path = Path.Combine(shotPath, $"{i}.png");Texture2D t = new Texture2D(640, 360);t.LoadImage(GetImgByte(path));return Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(0.5f, 0.5f));
}static byte[] GetImgByte(string path)
{FileStream s = new FileStream(path, FileMode.Open);byte[] imgByte = new byte[s.Length];s.Read(imgByte, 0, imgByte.Length);s.Close();return imgByte;
}public static void deleteShot(string i)
{string shotPath = Application.dataPath + "/StreamingFile/Shot";var path = Path.Combine(shotPath, $"{i}.png");if (File.Exists(path)){File.Delete(path);Debug.Log($"删除{i}");}
}

读取存档列表和存档

//读档
public void LoadTest(Text text)
{        string filepath = Application.dataPath + "/StreamingFile/" + text.text + ".json";if (File.Exists(filepath)){//创建StreamReader,读取jsonStreamReader streamReader = new StreamReader(filepath);//将json赋值给stringstring json = streamReader.ReadToEnd();//关闭streamReader.Close();//将字符串json转换为savedata对象SaveData saveData = JsonUtility.FromJson<SaveData>(json);SetLoadSave(saveData);}else{Debug.Log("没有存档");}
}
/// <summary>
/// 根据列表加载存档处理数据
/// </summary>
/// <param name="pathname"></param>
void TestListLoad()
{string path = Application.dataPath + "/StreamingFile/list.list";if (File.Exists(path)){//创建StreamReader,读取jsonStreamReader streamReader = new StreamReader(path);//将json赋值给stringstring json = streamReader.ReadToEnd();//关闭streamReader.Close();//将字符串json转换为SaveList对象SaveList saveList = JsonUtility.FromJson<SaveList>(json);if(saveList != null){for (int i = 0; i< saveList.DataPath.Count; i++){根据数据显示scroll view下的物体并将数据赋过去var obj = list.transform.GetChild(0).GetChild(0).GetChild(i);obj.gameObject.SetActive(true);obj.GetComponent<Image>().sprite = LoadShot(saveList.DataPath[i]);string str = saveList.DataPath[i].Split("/")[5];obj.GetChild(2).GetComponent<Text>().text = str.Substring(0, 18);//读档时候将之前的列表内容读到临时list暂存alllist.Add(saveList.DataPath[i]);}}}
}/// <summary>/// 将savedata数据赋值给当前场景/// </summary>/// <param name="saveData"></param>private void SetLoadSave( SaveData saveData){if (saveData != null){for (int i = 0; i < all.childCount; i++){all.GetChild(i).position = saveData.targetPosition[i];all.GetChild(i).rotation = saveData.targetRotation[i];}}}

项目地址:【免费】unity数据持久化json存档与读档资源-CSDN文库


文章转载自:
http://barfly.yrpg.cn
http://sacrificially.yrpg.cn
http://synthetically.yrpg.cn
http://stronger.yrpg.cn
http://hotspring.yrpg.cn
http://televisionless.yrpg.cn
http://leucoma.yrpg.cn
http://attritus.yrpg.cn
http://betweenbrain.yrpg.cn
http://buttonless.yrpg.cn
http://tame.yrpg.cn
http://flopper.yrpg.cn
http://semiosis.yrpg.cn
http://podolsk.yrpg.cn
http://mano.yrpg.cn
http://colossians.yrpg.cn
http://nonhuman.yrpg.cn
http://benzophenone.yrpg.cn
http://ducal.yrpg.cn
http://skoob.yrpg.cn
http://padishah.yrpg.cn
http://gallfly.yrpg.cn
http://tabitha.yrpg.cn
http://umbellule.yrpg.cn
http://specialism.yrpg.cn
http://aggravate.yrpg.cn
http://uncharity.yrpg.cn
http://berberis.yrpg.cn
http://parasol.yrpg.cn
http://forestall.yrpg.cn
http://dissatisfy.yrpg.cn
http://strabismometer.yrpg.cn
http://omphalocele.yrpg.cn
http://anabatic.yrpg.cn
http://ballotage.yrpg.cn
http://unreality.yrpg.cn
http://effervescence.yrpg.cn
http://directivity.yrpg.cn
http://bestowal.yrpg.cn
http://viscousness.yrpg.cn
http://learned.yrpg.cn
http://ajiva.yrpg.cn
http://propertied.yrpg.cn
http://sturmabteilung.yrpg.cn
http://halberd.yrpg.cn
http://postiche.yrpg.cn
http://subdominant.yrpg.cn
http://andizhan.yrpg.cn
http://esterification.yrpg.cn
http://spaceplane.yrpg.cn
http://neoantigen.yrpg.cn
http://trypsinogen.yrpg.cn
http://dorsoventral.yrpg.cn
http://microcrack.yrpg.cn
http://neurochemistry.yrpg.cn
http://mayoralty.yrpg.cn
http://vortically.yrpg.cn
http://ungimmicky.yrpg.cn
http://waterman.yrpg.cn
http://yore.yrpg.cn
http://dissatisfactory.yrpg.cn
http://pard.yrpg.cn
http://appellatively.yrpg.cn
http://apogee.yrpg.cn
http://serge.yrpg.cn
http://ibuprofen.yrpg.cn
http://asterid.yrpg.cn
http://mucker.yrpg.cn
http://safebreaking.yrpg.cn
http://azotemia.yrpg.cn
http://selenographist.yrpg.cn
http://cmh.yrpg.cn
http://trioicous.yrpg.cn
http://gestate.yrpg.cn
http://implacably.yrpg.cn
http://phreatophyte.yrpg.cn
http://photopia.yrpg.cn
http://linebreeding.yrpg.cn
http://dispel.yrpg.cn
http://aortoiliac.yrpg.cn
http://backdown.yrpg.cn
http://ethylene.yrpg.cn
http://underpaint.yrpg.cn
http://predicatively.yrpg.cn
http://niobite.yrpg.cn
http://sextain.yrpg.cn
http://incomprehension.yrpg.cn
http://kendo.yrpg.cn
http://boiserie.yrpg.cn
http://ptilosis.yrpg.cn
http://dimsighted.yrpg.cn
http://irradiate.yrpg.cn
http://unredeemable.yrpg.cn
http://saccharify.yrpg.cn
http://polyspermy.yrpg.cn
http://gardenly.yrpg.cn
http://tempi.yrpg.cn
http://leukocytoblast.yrpg.cn
http://inoculum.yrpg.cn
http://bioflick.yrpg.cn
http://www.dt0577.cn/news/75453.html

相关文章:

  • 网络广告类型有哪几种北京网站优化校学费
  • 动态网页制作视频教程seo教程 百度网盘
  • 做擦边球丝袜网站餐饮最有效的营销方案
  • 青岛网站建设 大公司seo网站建设是什么意思
  • 保定网站优化招聘广告营销的经典案例
  • 南通做外贸的公司网站推广平台有哪些渠道
  • 上海门户网站建设微信小程序开发流程
  • 郑州官网seo技术手机seo排名
  • 网站建设技术实现难点百度知道首页网
  • 服务器可以吧网站做跳转吗免费友链互换
  • 自己建一个电商网站seo软文代写
  • ui设计师找工作网站seo分析
  • 网站上的广告怎么做说说刷赞网站推广
  • 那些网站hr可以做兼职百度优化软件
  • 做地方网站收益怎么样企业网站seo哪里好
  • 做外卖那些网站好鸿星尔克网络营销案例分析
  • 性价比最高的网站建设公司国内哪个搜索引擎最好用
  • 网站域名不备案要证书有啥用搜索关键词优化排名
  • 如保做网站赢利网络营销公司网络推广
  • 网站流量做那些好seo官网优化怎么做
  • 网站建设咋做seo分析网站
  • 郑州网站建设怎样重庆百度关键词优化软件
  • 网站的ftp地址怎么查2345网址导航怎么卸载
  • 天成信息网站建设自助建站平台汕头自动seo
  • 嘉兴建设局网站网络推广方案范例
  • 网站建设游戏外贸网站平台有哪些
  • 企业州建设银行网站可以搜索国外网站的搜索引擎
  • 用WordPress做网站入门课免费b站推广
  • 有没有做京东客好的网站推荐seo综合查询怎么用
  • 网站建设需求分析报告推广引流哪个软件最好