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
451e1ae3
Commit
451e1ae3
authored
Aug 22, 2023
by
lijin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.huolea.com:shujianhe/tusegamecolor
parents
01ebe7fa
831d7cc1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
32 deletions
+153
-32
GameMgr.prefab
Assets/Resources/perfabs/GameMgr.prefab
+7
-7
gameScene.unity
Assets/Scenes/gameScene.unity
+16
-1
EventName.cs
Assets/scripts/EventName.cs
+3
-0
ScaleToImage.cs
Assets/scripts/ScaleToImage.cs
+83
-24
Gameing.cs
Assets/scripts/Views/gameScene/Gameing.cs
+33
-0
Gameing.cs.meta
Assets/scripts/Views/gameScene/Gameing.cs.meta
+11
-0
No files found.
Assets/Resources/perfabs/GameMgr.prefab
View file @
451e1ae3
...
...
@@ -411,10 +411,10 @@ MonoBehaviour:
m_Name
:
m_EditorClassIdentifier
:
m_Padding
:
m_Left
:
0
m_Right
:
0
m_Top
:
0
m_Bottom
:
0
m_Left
:
40
0
m_Right
:
40
0
m_Top
:
40
0
m_Bottom
:
40
0
m_ChildAlignment
:
4
m_Spacing
:
0
m_ChildForceExpandWidth
:
1
...
...
@@ -5402,7 +5402,7 @@ RectTransform:
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
40
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
0
,
y
:
0
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&4535739684591336511
...
...
@@ -5421,7 +5421,6 @@ MonoBehaviour:
png
:
{
fileID
:
0
}
jpg
:
{
fileID
:
0
}
json
:
allPos
:
roomDatas
:
[]
roomGroupsData
:
[]
colorDiff
:
0
...
...
@@ -5752,7 +5751,8 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
c99b850a1f8be4640b391afdbd751ee8
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
id
:
-1
roomId
:
-1
groupId
:
-1
IsUse
:
-1
SP
:
{
fileID
:
7114594662145661671
}
Rect
:
{
fileID
:
3859749812772851665
}
...
...
Assets/Scenes/gameScene.unity
View file @
451e1ae3
...
...
@@ -5563,6 +5563,7 @@ GameObject:
m_Component
:
-
component
:
{
fileID
:
1147557151012020857
}
-
component
:
{
fileID
:
8094727572906316438
}
-
component
:
{
fileID
:
8094727572906316439
}
m_Layer
:
5
m_Name
:
Gameing
m_TagString
:
Untagged
...
...
@@ -6239,7 +6240,7 @@ MonoBehaviour:
m_SelectOnDown
:
{
fileID
:
0
}
m_SelectOnLeft
:
{
fileID
:
0
}
m_SelectOnRight
:
{
fileID
:
0
}
m_Transition
:
0
m_Transition
:
1
m_Colors
:
m_NormalColor
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_HighlightedColor
:
{
r
:
0.9607843
,
g
:
0.9607843
,
b
:
0.9607843
,
a
:
1
}
...
...
@@ -8201,6 +8202,20 @@ MonoBehaviour:
cam
:
{
fileID
:
0
}
ListMoveOffSet
:
35
PlayImagePaent
:
{
fileID
:
1943337312
}
---
!u!114
&8094727572906316439
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
2077560325776199990
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
0abda17aa99f2ed40ae8f906b43a260f
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
ReSetPos_Btn
:
{
fileID
:
3853497852481138177
}
ShowBtnScale
:
1
---
!u!1
&8136062125027934181
GameObject
:
m_ObjectHideFlags
:
0
...
...
Assets/scripts/EventName.cs
View file @
451e1ae3
...
...
@@ -39,6 +39,9 @@ public static class EventName
public
const
string
Event_FindGroupArea
=
"Event_FindGroupArea"
;
//提示按钮按下
public
const
string
Event_AutoFullArea
=
"Event_AutoFullArea"
;
//自动涂按钮按下
public
const
string
Event_BackToHome
=
"Event_BackToHome"
;
//点返回按钮
public
const
string
Event_ImageScallChange
=
"Event_ImageScallChange"
;
//图片的缩放改变
public
const
string
Event_ReSetPicPos_Scale
=
"Event_ReSetPicPos_Scale"
;
//重新设置图片的位置和缩放
}
public
class
DataName
...
...
Assets/scripts/ScaleToImage.cs
View file @
451e1ae3
using
DG.Tweening
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Linq
;
using
UnityEngine
;
...
...
@@ -21,26 +22,55 @@ public class ScaleToImage : MonoBehaviour
public
float
Min_Move
;
public
float
Max_Move
;
private
Vector3
ToFigerCenter
_Scale
;
//指向手指中间的向量
private
float
ToFigerdistance
_Scale
;
//距离
private
Vector3
ToFigerCenter
;
//指向手指中间的向量
private
float
ToFigerdistance
;
//距离
private
float
MoveValue
_Scale
;
//移动,缩放大了就小一些
private
float
MoveValue
;
//移动,缩放大了就小一些
private
bool
PlayAniFlag_Scale
;
private
Vector3
SavePos_Scale
;
//这个是保存放大到最大的倍数的时候回正的位置
private
float
NowScale
;
private
List
<
float
>
ScaleSize_List
=
new
List
<
float
>();
private
int
ListMaxNum
=
10
;
bool
flag
;
private
float
SatrtScale
;
private
Vector3
StartPos
;
private
float
EndScale
;
private
Vector3
EndPos
;
private
Vector3
OnInitScale
;
//初始化时的缩放
private
Vector3
OnInitPos
;
private
void
Start
()
{
canvasCamera
=
transform
.
parent
.
GetComponent
<
ScaleToImage
>().
canvasCamera
;
RegisterEvent
(
true
);
StartCoroutine
(
Delay
());
}
bool
flag
;
IEnumerator
Delay
()
{
yield
return
new
WaitForSeconds
(
1f
);
OnInitScale
=
target
.
localScale
;
OnInitPos
=
target
.
position
;
}
private
void
RegisterEvent
(
bool
flag
)
{
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_ReSetPicPos_Scale
,
ResetPos_Scale
,
flag
);
}
private
void
ResetPos_Scale
(
object
[]
values
)
{
target
.
localScale
=
OnInitScale
;
target
.
position
=
OnInitPos
;
target
.
gameObject
.
SetActive
(
false
);
target
.
gameObject
.
SetActive
(
true
);
}
private
void
Update
()
{
...
...
@@ -58,16 +88,28 @@ public class ScaleToImage : MonoBehaviour
flag
=
false
;
if
(
target
.
localScale
.
x
<=
Min_Move
)
//缩放小的回大
{
target
.
DOScale
(
Vector3
.
one
*
MinScale
,
0.3f
).
onComplete
=()=>
target
.
DOScale
(
Vector3
.
one
*
MinScale
,
0.3f
).
onComplete
=
()
=>
{
RefreshScrollview
();
};
NowScale
=
MinScale
;
SetscrollRectEnable
(
true
);
}
else
if
(
target
.
localScale
.
x
>=
MaxScale
)
//大的回来小
{
SetscrollRectEnable
(
true
);
EndScale
=
target
.
localScale
.
x
;
EndPos
=
target
.
position
;
float
dis
=
EndScale
-
SatrtScale
;
//缩放差
float
tolimit
=
EndScale
-
MaxScale
;
//结束到最大限制的差
float
value
=
tolimit
/
dis
;
//比值
var
toStart
=
(
StartPos
-
EndPos
).
normalized
;
//指向开始点的向量
var
distance
=
Vector3
.
Distance
(
StartPos
,
EndPos
);
Vector3
Pos
=
EndPos
+
toStart
*
distance
*
value
;
//回去的位置
target
.
DOScale
(
Vector3
.
one
*
MaxScale
,
0.3f
);
target
.
DOMove
(
SavePos_Scale
,
0.3f
).
onComplete
=
()
=>
target
.
DOMove
(
Pos
,
0.3f
).
onComplete
=
()
=>
{
RefreshScrollview
();
};
...
...
@@ -80,6 +122,7 @@ public class ScaleToImage : MonoBehaviour
}
if
(
flag
)
{
SetscrollRectEnable
(
true
);
RefreshScrollview
();
flag
=
false
;
}
...
...
@@ -111,6 +154,7 @@ public class ScaleToImage : MonoBehaviour
{
if
(!
isInit_Scale
)
{
SetscrollRectEnable
(
false
);
//两指点位
touch1
=
canvasCamera
.
ScreenToWorldPoint
(
Input
.
GetTouch
(
0
).
position
);
touch2
=
canvasCamera
.
ScreenToWorldPoint
(
Input
.
GetTouch
(
1
).
position
);
...
...
@@ -120,27 +164,42 @@ public class ScaleToImage : MonoBehaviour
//图片的初始点位
oriPos
=
new
Vector3
(
target
.
position
.
x
,
target
.
position
.
y
,
0
);
if
(
target
.
localScale
.
x
>=
MaxScale
*
0.99f
)
{
SavePos_Scale
=
target
.
position
;
}
float
distance
=
Vector2
.
Distance
(
touch1
,
touch2
)
/
2f
;
var
normal
=
(
touch1
-
touch2
).
normalized
;
pos
=
normal
*
distance
+
touch2
;
//两个手指中间的点
//指向手指中心的单位向量
ToFigerCenter
_Scale
=
(
pos
-
oriPos
).
normalized
;
ToFigerCenter
=
(
pos
-
oriPos
).
normalized
;
//距离
ToFigerdistance
_Scale
=
Vector3
.
Distance
(
pos
,
oriPos
);
ToFigerdistance
=
Vector3
.
Distance
(
pos
,
oriPos
);
oriScale
=
target
.
localScale
.
x
;
//开始的缩放值
isInit_Scale
=
true
;
MoveValue_Scale
=
1
/
oriScale
;
MoveValue
=
1
/
oriScale
;
SatrtScale
=
target
.
localScale
.
x
;
StartPos
=
target
.
position
;
return
;
}
if
(
target
.
localScale
.
x
<
Min_Move
)
{
PlayAniFlag_Scale
=
true
;
if
(
ScaleSize_List
.
Count
<
ListMaxNum
)
{
ScaleSize_List
.
Add
(
NowScale
);
}
else
{
ScaleSize_List
.
Clear
();
ChangeFontSize
(
Min_Move
);
}
return
;
}
//两指缩放比例
float
nowdis
=
Vector3
.
Distance
(
canvasCamera
.
ScreenToWorldPoint
(
Input
.
GetTouch
(
0
).
position
),
canvasCamera
.
ScreenToWorldPoint
(
Input
.
GetTouch
(
1
).
position
));
scale
=
nowdis
/
Vector3
.
Distance
(
touch1
,
touch2
);
//大于1是放大,小于是缩小
...
...
@@ -153,18 +212,14 @@ public class ScaleToImage : MonoBehaviour
scale
=
scale
*
oriScale
*
scaleSpeed
;
//缩小速度
}
if
(
target
.
localScale
.
x
<
Min_Move
)
{
PlayAniFlag_Scale
=
true
;
return
;
}
float
scale_target
=
0
;
scale_target
=
(
Vector3
.
one
*
(
oriScale
+
scale
)).
x
;
Vector3
targetscale
;
if
(
scale_target
<
Min_Move
)
{
targetscale
=
Vector3
.
one
*
Min_Move
*
0.99f
;
target
.
localScale
=
targetscale
;
return
;
}
else
if
(
scale_target
>
MaxScale
)
{
...
...
@@ -174,14 +229,14 @@ public class ScaleToImage : MonoBehaviour
else
{
targetscale
=
Vector3
.
one
*
(
oriScale
+
scale
);
SavePos_Scale
=
target
.
position
;
}
target
.
localScale
=
targetscale
;
//改变目标位置,让位置保持不变
target
.
position
=
oriPos
-
ToFigerCenter_Scale
*
(
target
.
localScale
.
x
-
oriScale
)
*
ToFigerdistance_Scale
*
MoveValue_Scale
;
var
newpos
=
ToFigerCenter
*
(
target
.
localScale
.
x
-
oriScale
)
*
ToFigerdistance
*
MoveValue
;
target
.
position
=
oriPos
-
newpos
;
target
.
localPosition
=
new
Vector3
(
target
.
localPosition
.
x
,
target
.
localPosition
.
y
,
0
);
NowScale
=
targetscale
.
x
;
...
...
@@ -205,5 +260,9 @@ public class ScaleToImage : MonoBehaviour
}
private
void
SetscrollRectEnable
(
bool
enable
)
{
scrollRect
.
enabled
=
enable
;
}
}
Assets/scripts/Views/gameScene/Gameing.cs
0 → 100644
View file @
451e1ae3
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.UI
;
public
class
Gameing
:
MonoBehaviour
{
public
Button
ReSetPos_Btn
;
public
float
ShowBtnScale
;
//显示重设位置按钮的缩放值
// Start is called before the first frame update
void
Start
()
{
ResiterEvent
(
true
);
ReSetPos_Btn
.
onClick
.
AddListener
(
ReSetPos_Btn_Click
);
ReSetPos_Btn
.
gameObject
.
SetActive
(
false
);
}
private
void
ResiterEvent
(
bool
flag
)
{
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_ImageScallChange
,
ChangeScale_Pic
,
flag
);
}
private
void
ChangeScale_Pic
(
object
[]
values
)
{
float
scale
=
(
float
)
values
[
0
];
ReSetPos_Btn
.
gameObject
.
SetActive
(
ShowBtnScale
<=
scale
);
}
private
void
ReSetPos_Btn_Click
()
{
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_ReSetPicPos_Scale
);
}
}
Assets/scripts/Views/gameScene/Gameing.cs.meta
0 → 100644
View file @
451e1ae3
fileFormatVersion: 2
guid: 0abda17aa99f2ed40ae8f906b43a260f
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