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
ef803ece
Commit
ef803ece
authored
Aug 24, 2023
by
JiangWanZhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
回放录屏更新
parent
8bf9f910
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
423 additions
and
67 deletions
+423
-67
GameMgr.cs
Assets/GameMgr/GameMgr.cs
+2
-1
ReplayCam.cs
Assets/NatCorder/Examples/ReplayCam/ReplayCam.cs
+21
-10
gameScene.unity
Assets/Scenes/gameScene.unity
+269
-51
EventName.cs
Assets/scripts/EventName.cs
+5
-0
ScaleToImage.cs
Assets/scripts/ScaleToImage.cs
+2
-2
GameEndPanel.cs
Assets/scripts/Views/GameEnd/GameEndPanel.cs
+104
-1
Gameing.cs
Assets/scripts/Views/gameScene/Gameing.cs
+8
-1
GroupListManager.cs
Assets/scripts/Views/maingame/GroupListManager.cs
+12
-1
No files found.
Assets/GameMgr/GameMgr.cs
View file @
ef803ece
...
...
@@ -65,7 +65,7 @@ public class GameMgr : MonoBehaviour
curTime
=
0
;
}
//停止重播
p
rivate
void
StopRePlay
()
p
ublic
void
StopRePlay
()
{
md
.
StopRePlay
();
stepIndex
=
-
1
;
...
...
@@ -201,6 +201,7 @@ public class GameMgr : MonoBehaviour
if
(
stepIndex
>=
md
.
dynamic
.
step
.
Count
)
{
stepIndex
=
-
1
;
EventDispatcher
.
Dispatch
(
EventName
.
Event
.
Event_StopRecording
);
}
}
}
...
...
Assets/NatCorder/Examples/ReplayCam/ReplayCam.cs
View file @
ef803ece
...
...
@@ -21,14 +21,14 @@ namespace NatSuite.Examples {
{
get
{
return
Screen
.
width
;
//
(int)targetpos.GetComponent<RectTransform>().sizeDelta.x;
return
(
int
)
targetpos
.
GetComponent
<
RectTransform
>().
sizeDelta
.
x
;
}
}
public
int
videoHeight
{
get
{
return
Screen
.
height
;
//
(int)targetpos.GetComponent<RectTransform>().sizeDelta.y;
return
(
int
)
targetpos
.
GetComponent
<
RectTransform
>().
sizeDelta
.
y
;
}
}
public
bool
recordMicrophone
;
...
...
@@ -73,23 +73,22 @@ namespace NatSuite.Examples {
{
float
x
=
targetpos
.
GetComponent
<
RectTransform
>().
sizeDelta
.
x
;
float
y
=
targetpos
.
GetComponent
<
RectTransform
>().
sizeDelta
.
y
;
targetpos
.
GetComponent
<
BoxCollider2D
>().
size
=
new
Vector2
(
x
,
y
);
val
=
(
float
)
Screen
.
width
/
x
;
cam
.
targetTexture
=
new
RenderTexture
((
int
)
x
,
(
int
)
y
,
24
,
RenderTextureFormat
.
ARGB32
);
//
cam.targetTexture = new RenderTexture((int)x, (int)y, 24, RenderTextureFormat.ARGB32);
transform
.
position
=
new
Vector3
(
targetpos
.
position
.
x
,
targetpos
.
position
.
y
,
transform
.
position
.
z
);
cam
.
orthographicSize
=
5f
/
val
+
0.9f
;
//
cam.orthographicSize = 5f / val + 0.9f;
}
public
void
StartRecording
()
{
Debug
.
Log
(
$"开始录屏"
);
//
SetCamPos();
SetCamPos
();
// Start recording
var
frameRate
=
Application
.
targetFrameRate
;
var
frameRate
=
30
;
//var sampleRate = recordMicrophone ? AudioSettings.outputSampleRate : 0;
//var channelCount = recordMicrophone ? (int)AudioSettings.speakerMode : 0;
var
sampleRate
=
AudioSettings
.
outputSampleRate
;
...
...
@@ -102,9 +101,21 @@ namespace NatSuite.Examples {
//webCamTextureInput = new WebCamTextureInput(recorder, clock, (WebCamTexture)tex);
//audioInput = recordMicrophone ? new AudioInput(recorder, clock, microphoneSource, true) : null;
//
audioInput = new AudioInput(recorder, clock, audioListener);
audioInput
=
new
AudioInput
(
recorder
,
clock
,
audioListener
);
// Unmute microphone
//microphoneSource.mute = audioInput == null;
microphoneSource
.
mute
=
true
;
// audioInput == null;
}
public
void
InterruptRecording
()
//停止录屏,但是不保存
{
Debug
.
Log
(
"停止录屏"
);
// Mute microphone
microphoneSource
.
mute
=
true
;
// Stop recording
audioInput
?.
Dispose
();
cameraInput
?.
Dispose
();
recorder
=
null
;
}
public
async
void
StopRecording
()
...
...
@@ -114,7 +125,7 @@ namespace NatSuite.Examples {
microphoneSource
.
mute
=
true
;
// Stop recording
audioInput
?.
Dispose
();
cameraInput
.
Dispose
();
cameraInput
?
.
Dispose
();
var
path
=
await
recorder
.
FinishWriting
();
// Playback recording
Debug
.
Log
(
$"Saved recording to:
{
path
}
"
);
...
...
Assets/Scenes/gameScene.unity
View file @
ef803ece
This diff is collapsed.
Click to expand it.
Assets/scripts/EventName.cs
View file @
ef803ece
...
...
@@ -43,6 +43,11 @@ public static class EventName
public
const
string
Event_ImageScallChange
=
"Event_ImageScallChange"
;
//图片的缩放改变
public
const
string
Event_ReSetPicPos_Scale
=
"Event_ReSetPicPos_Scale"
;
//重新设置图片的位置和缩放
public
const
string
Event_StrtRecording
=
"Event_StrtRecording"
;
//开始录屏
public
const
string
Event_StopRecording
=
"Event_StopRecording"
;
//停止录屏
public
const
string
Event_InterruptRecording
=
"Event_InterruptRecording"
;
//中断录屏
public
const
string
Event_ReSetPicSize
=
"Event_ReSetPicSize"
;
//重置图片位置和大小
}
public
class
DataName
...
...
Assets/scripts/ScaleToImage.cs
View file @
ef803ece
...
...
@@ -75,15 +75,14 @@ public class ScaleToImage : MonoBehaviour
target
.
gameObject
.
SetActive
(
true
);
}
private
bool
FirstFlag
;
private
void
Update
()
{
#if UNITY_EDITOR
MouseScale
();
#endif
if
(
Input
.
touchCount
==
2
)
{
RefreshScrollview
();
Scale
();
flag
=
true
;
scrollRect
.
inertia
=
false
;
...
...
@@ -170,6 +169,7 @@ public class ScaleToImage : MonoBehaviour
{
if
(!
isInit_Scale
)
{
RefreshScrollview
();
SetscrollRectEnable
(
false
);
//两指点位
touch1
=
canvasCamera
.
ScreenToWorldPoint
(
Input
.
GetTouch
(
0
).
position
);
...
...
Assets/scripts/Views/GameEnd/GameEndPanel.cs
View file @
ef803ece
using
NatSuite.Examples
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
...
...
@@ -6,17 +7,33 @@ using UnityEngine.UI;
public
class
GameEndPanel
:
MonoBehaviour
{
private
static
GameEndPanel
instance
;
public
static
GameEndPanel
Instance
=>
instance
;
public
GameObject
BG
;
public
Button
SaveVideo_Btn
;
public
Button
RePlayVideo_Btn
;
public
Button
Share_Btn
;
public
Button
Continue_Btn
;
public
Button
interruptRecording_Btn
;
//中断录屏的按钮
public
Transform
PicParent
;
public
ScrollRect
scrollRect
;
public
HorizontalLayoutGroup
ItemParent
;
public
GameObject
item_obj
;
public
RectTransform
Mask
;
//遮罩
public
RectTransform
Mask_BG
;
//遮罩前面的白框
public
ReplayCam
replayCam
;
public
GameObject
[]
sHow_OnRecorder
;
//在录屏的时候显示的节点
public
GameObject
[]
nOtShow_OnRecorder
;
//在录屏的时候不显示的节点
private
void
Awake
()
{
instance
=
this
;
}
private
void
Start
()
{
ResiterEvent
(
true
);
...
...
@@ -25,9 +42,76 @@ public class GameEndPanel : MonoBehaviour
RePlayVideo_Btn
.
onClick
.
AddListener
(
RePlayVideo_Btn_Click
);
Share_Btn
.
onClick
.
AddListener
(
Share_Btn_Click
);
Continue_Btn
.
onClick
.
AddListener
(
Continue_Btn_Click
);
interruptRecording_Btn
.
onClick
.
AddListener
(
InterruptRecording
);
RegisterEvent
(
true
);
IsRecorder
(
false
);
}
private
void
Update
()
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
S
))
//测试把图片移到结束界面下来
{
BG
.
SetActive
(
true
);
MovePic
();
}
}
public
void
OpenPanel
()
{
BG
.
SetActive
(
true
);
MovePic
();
}
private
void
MovePic
()
{
GameMgr
.
Ins
.
transform
.
parent
=
PicParent
;
GameMgr
.
Ins
.
transform
.
position
=
PicParent
.
position
;
var
Scaletoimage
=
GameMgr
.
Ins
.
GetComponent
<
ScaleToImage
>();
Scaletoimage
.
target
.
localScale
=
Vector3
.
one
*
0.3f
;
float
scale
=
Scaletoimage
.
target
.
localScale
.
x
;
float
picsize_x
=
GameMgr
.
Ins
.
md
.
png
.
width
;
float
picsize_y
=
GameMgr
.
Ins
.
md
.
png
.
height
;
Mask
.
sizeDelta
=
new
Vector2
(
picsize_x
*
scale
,
picsize_y
*
scale
);
Mask_BG
.
sizeDelta
=
new
Vector2
(
picsize_x
*
scale
+
10
,
picsize_y
*
scale
+
10
);
}
private
void
RegisterEvent
(
bool
flag
)
{
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_StopRecording
,
StopRecording
,
flag
);
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_InterruptRecording
,
InterruptRecording
,
flag
);
}
private
void
InterruptRecording
(
object
[]
values
)
{
InterruptRecording
();
}
private
void
InterruptRecording
()
{
Debug
.
Log
(
"中断录屏"
);
GameMgr
.
Ins
.
StopRePlay
();
replayCam
.
InterruptRecording
();
IsRecorder
(
false
);
}
private
void
StopRecording
(
object
[]
values
)
{
Debug
.
Log
(
"录屏完成"
);
StartCoroutine
(
DelayToStop
());
}
IEnumerator
DelayToStop
()
{
yield
return
new
WaitForSeconds
(
1
);
replayCam
.
StopRecording
();
IsRecorder
(
false
);
}
private
void
CreateItem
()
//创建列表item
{
int
childNum
=
10
;
...
...
@@ -56,13 +140,32 @@ public class GameEndPanel : MonoBehaviour
private
void
RePlayVideo_Btn_Click
()
{
Debug
.
Log
(
"点击回放动画"
);
GameMgr
.
Ins
.
RePlay
();
}
private
void
SaveVideo_Btn_Click
()
{
Debug
.
Log
(
"点击保存视频"
);
Debug
.
Log
(
"点击保存视频 ,开始录屏了"
);
GameMgr
.
Ins
.
RePlay
();
replayCam
.
StartRecording
();
IsRecorder
(
true
);
}
private
void
IsRecorder
(
bool
flag
)
{
foreach
(
var
item
in
nOtShow_OnRecorder
)
{
item
.
SetActive
(!
flag
);
}
foreach
(
var
item
in
sHow_OnRecorder
)
{
item
.
SetActive
(
flag
);
}
}
private
void
ResiterEvent
(
bool
flag
)
{
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_AllGroupOver
,
GameEnd
,
flag
);
...
...
Assets/scripts/Views/gameScene/Gameing.cs
View file @
ef803ece
...
...
@@ -6,10 +6,16 @@ using UnityEngine.UI;
public
class
Gameing
:
MonoBehaviour
{
private
static
Gameing
instance
;
public
static
Gameing
Instance
=>
instance
;
public
Button
ReSetPos_Btn
;
public
float
ShowBtnScale
;
//显示重设位置按钮的缩放值
public
GameObject
AutoFille_Btn
;
//自动涂色的按钮
// Start is called before the first frame update
private
void
Awake
()
{
instance
=
this
;
}
void
Start
()
{
ResiterEvent
(
true
);
...
...
@@ -23,6 +29,7 @@ public class Gameing : MonoBehaviour
EventDispatcher
.
RegisterEvent
(
EventName
.
Event
.
Event_GroupItemSelect
,
ShowAutoFill_Btn
,
flag
);
}
private
void
ShowAutoFill_Btn
(
object
[]
values
)
{
if
(!
AutoFille_Btn
.
activeSelf
)
...
...
Assets/scripts/Views/maingame/GroupListManager.cs
View file @
ef803ece
...
...
@@ -140,6 +140,11 @@ public class GroupListManager : MonoBehaviour
float
value
=
ClickAreaCount
/
AllAreaCount
;
AllProcress
.
value
=
value
;
AllProcress_Text
.
text
=
value
.
ToString
(
"P0"
);
if
(
value
==
1
)
{
GameEndPanel
.
Instance
.
OpenPanel
();
}
}
public
float
bigvalue
=
1
;
...
...
@@ -201,6 +206,9 @@ public class GroupListManager : MonoBehaviour
}
};
};
Vibration
.
VibrateNope
();
//现在没有开关,直接震动
}
IEnumerator
DelayToSetContent
()
...
...
@@ -267,7 +275,7 @@ public class GroupListManager : MonoBehaviour
{
var
item
=
roomGroupsData
[
i
];
NowJindu
=
(
float
)
dynamic
.
GetCountById
(
item
.
id
)
/
item
.
roomIds
.
Count
;
AllAreaCount
=
AllAreaCount
+
item
.
roomIds
.
Count
+
dynamic
.
GetCountById
(
item
.
id
)
;
AllAreaCount
=
AllAreaCount
+
item
.
roomIds
.
Count
;
ClickAreaCount
=
ClickAreaCount
+
dynamic
.
GetCountById
(
item
.
id
);
if
(
NowJindu
>=
1
)
continue
;
...
...
@@ -414,5 +422,8 @@ public class GroupListManager : MonoBehaviour
public
void
Test_Btn_RePlay
()
{
GameMgr
.
Ins
.
RePlay
();
EventDispatcher
.
Dispatch
(
"Test"
);
}
}
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