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
5c9a76ed
Commit
5c9a76ed
authored
Aug 24, 2023
by
lijin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片颜色列表只获取一次
parent
cddac77d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
MainData.cs
Assets/GameMgr/MainData.cs
+13
-7
ResJsonData.cs
Assets/GameMgr/ResJsonData.cs
+3
-4
No files found.
Assets/GameMgr/MainData.cs
View file @
5c9a76ed
...
...
@@ -8,6 +8,7 @@ using Unity.VisualScripting;
using
UnityEngine
;
using
UnityEngine.EventSystems
;
using
UnityEngine.UI
;
using
static
Unity
.
Burst
.
Intrinsics
.
X86
.
Avx
;
//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
//sw.Start();
...
...
@@ -29,6 +30,9 @@ public class MainData : MonoBehaviour
public
Image
imgpng
;
//线框图组件
public
Image
imgjpg
;
//彩色图组件
public
Color
[]
c_png
;
public
Color
[]
c_map
;
public
RectTransform
rect
;
//本节点
public
int
curGroupId
=
-
1
;
//当前选组ID
...
...
@@ -43,7 +47,11 @@ public class MainData : MonoBehaviour
map
=
_map
;
json
=
_json
;
dynamic
=
_dynamic
;
json
.
JoinMap
(
map
);
//把点阵数据放进json配置以快速获取某个区域的所有点
c_png
=
png
.
GetPixels
();
c_map
=
map
.
GetPixels
();
json
.
JoinMap
(
c_map
);
//把点阵数据放进json配置以快速获取某个区域的所有点
imgjpg
.
sprite
=
jpg
;
//由layout组件自动适应大小
imgpng
.
sprite
=
Sprite
.
Create
(
png
,
new
Rect
(
0
,
0
,
json
.
width
,
json
.
height
),
new
Vector2
(
0.5f
,
0.5f
));
...
...
@@ -79,7 +87,6 @@ public class MainData : MonoBehaviour
//判断是否当前选组
if
(
rd
.
groupId
!=
curGroupId
&&
!
b
)
{
return
false
;
}
//染色逻辑
Color
[]
c_png
=
png
.
GetPixels
();
for
(
int
i
=
0
;
i
<
rd
.
posIndex
.
Count
;
i
++)
{
c_png
[
rd
.
posIndex
[
i
]]
=
Color
.
clear
;
...
...
@@ -128,15 +135,14 @@ public class MainData : MonoBehaviour
{
dynamic
=
new
DynamicData
();
//动态数据直接舍弃
//重置染色
Color
[]
c
=
png
.
GetPixels
();
for
(
int
i
=
0
;
i
<
c
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
c_png
.
Length
;
i
++)
{
if
(
c
[
i
]
==
Color
.
clear
)
if
(
c
_png
[
i
]
==
Color
.
clear
)
{
c
[
i
]
=
Color
.
white
;
c
_png
[
i
]
=
Color
.
white
;
}
}
png
.
SetPixels
(
c
);
png
.
SetPixels
(
c
_png
);
png
.
Apply
();
SaveManager
.
Instance
.
SaveRes
(
key
,
dynamic
,
png
);
//保存
}
...
...
Assets/GameMgr/ResJsonData.cs
View file @
5c9a76ed
...
...
@@ -81,17 +81,16 @@ public class ResJsonData
public
ExtraMetaData
extraMetaData
;
private
static
V2
v
;
public
void
JoinMap
(
Texture2D
map
)
public
void
JoinMap
(
Color
[]
c_
map
)
{
if
(
isInit
)
{
return
;
}
isInit
=
true
;
Color
[]
c
=
map
.
GetPixels
();
for
(
int
i
=
0
;
i
<
c
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
c_map
.
Length
;
i
++)
{
V2
_v
=
ColorToV
(
c
[
i
]);
V2
_v
=
ColorToV
(
c
_map
[
i
]);
if
(
_v
.
x
!=
0
||
_v
.
y
!=
0
)
{
roomDatas
[
_v
.
x
].
posIndex
.
Add
(
i
);
...
...
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