Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
tuseGameColor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shujianhe
tuseGameColor
Commits
7eafc103
Commit
7eafc103
authored
Aug 18, 2023
by
JiangWanZhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加保存bin文件和png的脚本
parent
4794eb71
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
0 deletions
+95
-0
gameScene.unity
Assets/Scenes/gameScene.unity
+14
-0
mainGameView.cs
Assets/scripts/common/mainGameView.cs
+6
-0
FileUtility.cs
Assets/scripts/utils/FileUtility.cs
+64
-0
FileUtility.cs.meta
Assets/scripts/utils/FileUtility.cs.meta
+11
-0
No files found.
Assets/Scenes/gameScene.unity
View file @
7eafc103
...
...
@@ -656,6 +656,7 @@ GameObject:
-
component
:
{
fileID
:
297775246
}
-
component
:
{
fileID
:
297775249
}
-
component
:
{
fileID
:
297775250
}
-
component
:
{
fileID
:
297775251
}
m_Layer
:
0
m_Name
:
Main Camera
m_TagString
:
MainCamera
...
...
@@ -807,6 +808,18 @@ MonoBehaviour:
AutoBtn
:
{
fileID
:
1354215336290540113
}
CloseBtn
:
{
fileID
:
669974489
}
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
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -8928,6 +8941,7 @@ MonoBehaviour:
clickPosEff
:
{
fileID
:
5397047662947055783
,
guid
:
1765abab6384f17448d404269ec52238
,
type
:
3
}
selectTextureIdx
:
0
MrgParent
:
{
fileID
:
7418061516327095409
}
LoadingPanel
:
{
fileID
:
7418061516327095409
}
---
!u!114
&8094727572906316438
MonoBehaviour
:
m_ObjectHideFlags
:
0
...
...
Assets/scripts/common/mainGameView.cs
View file @
7eafc103
...
...
@@ -59,6 +59,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
private
ColorIndexTables
nowSelectColors
=
null
;
public
Transform
MrgParent
;
public
Transform
LoadingPanel
;
public
int
SelectTextureIdx
{
get
{
return
selectTextureIdx
;
}
...
...
@@ -1736,4 +1737,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
readFs
.
Close
();
return
rjd
;
}
private
void
CloseLoadingPanel
()
{
LoadingPanel
.
gameObject
.
SetActive
(
false
);
}
}
Assets/scripts/utils/FileUtility.cs
0 → 100644
View file @
7eafc103
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
();
}
}
Assets/scripts/utils/FileUtility.cs.meta
0 → 100644
View file @
7eafc103
fileFormatVersion: 2
guid: a84e71b0940ee354b88759c457e77bf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment