Commit 7eafc103 authored by JiangWanZhi's avatar JiangWanZhi

添加保存bin文件和png的脚本

parent 4794eb71
...@@ -656,6 +656,7 @@ GameObject: ...@@ -656,6 +656,7 @@ GameObject:
- component: {fileID: 297775246} - component: {fileID: 297775246}
- component: {fileID: 297775249} - component: {fileID: 297775249}
- component: {fileID: 297775250} - component: {fileID: 297775250}
- component: {fileID: 297775251}
m_Layer: 0 m_Layer: 0
m_Name: Main Camera m_Name: Main Camera
m_TagString: MainCamera m_TagString: MainCamera
...@@ -807,6 +808,18 @@ MonoBehaviour: ...@@ -807,6 +808,18 @@ MonoBehaviour:
AutoBtn: {fileID: 1354215336290540113} AutoBtn: {fileID: 1354215336290540113}
CloseBtn: {fileID: 669974489} CloseBtn: {fileID: 669974489}
Test_Text: {fileID: 1230079831} Test_Text: {fileID: 1230079831}
--- !u!114 &297775251
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 297775245}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a84e71b0940ee354b88759c457e77bf0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &302737823 --- !u!1 &302737823
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -8928,6 +8941,7 @@ MonoBehaviour: ...@@ -8928,6 +8941,7 @@ MonoBehaviour:
clickPosEff: {fileID: 5397047662947055783, guid: 1765abab6384f17448d404269ec52238, type: 3} clickPosEff: {fileID: 5397047662947055783, guid: 1765abab6384f17448d404269ec52238, type: 3}
selectTextureIdx: 0 selectTextureIdx: 0
MrgParent: {fileID: 7418061516327095409} MrgParent: {fileID: 7418061516327095409}
LoadingPanel: {fileID: 7418061516327095409}
--- !u!114 &8094727572906316438 --- !u!114 &8094727572906316438
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -59,6 +59,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -59,6 +59,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
private ColorIndexTables nowSelectColors = null; private ColorIndexTables nowSelectColors = null;
public Transform MrgParent; public Transform MrgParent;
public Transform LoadingPanel;
public int SelectTextureIdx public int SelectTextureIdx
{ {
get { return selectTextureIdx; } get { return selectTextureIdx; }
...@@ -1736,4 +1737,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1736,4 +1737,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
readFs.Close(); readFs.Close();
return rjd; return rjd;
} }
private void CloseLoadingPanel()
{
LoadingPanel.gameObject.SetActive(false);
}
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public class FileUtility : MonoBehaviour
{
private static FileUtility instance;
public static FileUtility Instance => instance;
private string SavePath
{
get
{
return Application.dataPath+$"/Resources/cc2D9Z2w9k0evqUiCQ/"; //暂时先用这里的
}
}
private void Awake()
{
instance = this;
}
/// <summary>
/// 保存bin文件
/// </summary>
/// <param name="path"></param>
/// <param name="json"></param>
public void SaveBin(string name,string json)
{
FileStream fs = new FileStream(SavePath+$"{name}.bin", FileMode.Create, FileAccess.Write);
BinaryFormatter saveBf = new BinaryFormatter();
saveBf.Serialize(fs, json);
fs.Close();
}
/// <summary>
/// 保存png
/// </summary>
/// <param name="path"></param>
/// <param name="png"></param>
public void SavePng(Texture2D png)
{
//var colors = png.GetPixels();
//for (int i = 0; i < png.width; i+=2)
//{
// for (int j = 0; j < png.height; j+=2)
// {
// png.SetPixel(i, j, new Color(1, 1, 1, 1));
// }
//}
//png.Apply();
byte[] dataBytes = png.EncodeToPNG();
FileStream fs = File.Open(SavePath+$"{png.name}.png", FileMode.OpenOrCreate);
fs.Write(dataBytes, 0, dataBytes.Length);
fs.Flush();
fs.Close();
}
}
fileFormatVersion: 2
guid: a84e71b0940ee354b88759c457e77bf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment