Commit ef803ece authored by JiangWanZhi's avatar JiangWanZhi

回放录屏更新

parent 8bf9f910
...@@ -65,7 +65,7 @@ public class GameMgr : MonoBehaviour ...@@ -65,7 +65,7 @@ public class GameMgr : MonoBehaviour
curTime = 0; curTime = 0;
} }
//停止重播 //停止重播
private void StopRePlay() public void StopRePlay()
{ {
md.StopRePlay(); md.StopRePlay();
stepIndex = -1; stepIndex = -1;
...@@ -201,6 +201,7 @@ public class GameMgr : MonoBehaviour ...@@ -201,6 +201,7 @@ public class GameMgr : MonoBehaviour
if (stepIndex >= md.dynamic.step.Count) if (stepIndex >= md.dynamic.step.Count)
{ {
stepIndex = -1; stepIndex = -1;
EventDispatcher.Dispatch(EventName.Event.Event_StopRecording);
} }
} }
} }
......
...@@ -21,14 +21,14 @@ namespace NatSuite.Examples { ...@@ -21,14 +21,14 @@ namespace NatSuite.Examples {
{ {
get get
{ {
return Screen.width;//(int)targetpos.GetComponent<RectTransform>().sizeDelta.x; return (int)targetpos.GetComponent<RectTransform>().sizeDelta.x;
} }
} }
public int videoHeight public int videoHeight
{ {
get get
{ {
return Screen.height;//(int)targetpos.GetComponent<RectTransform>().sizeDelta.y; return (int)targetpos.GetComponent<RectTransform>().sizeDelta.y;
} }
} }
public bool recordMicrophone; public bool recordMicrophone;
...@@ -73,23 +73,22 @@ namespace NatSuite.Examples { ...@@ -73,23 +73,22 @@ namespace NatSuite.Examples {
{ {
float x = targetpos.GetComponent<RectTransform>().sizeDelta.x; float x = targetpos.GetComponent<RectTransform>().sizeDelta.x;
float y = targetpos.GetComponent<RectTransform>().sizeDelta.y; float y = targetpos.GetComponent<RectTransform>().sizeDelta.y;
targetpos.GetComponent<BoxCollider2D>().size = new Vector2(x, y);
val = (float)Screen.width / x; 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); 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 () public void StartRecording ()
{ {
Debug.Log($"开始录屏"); Debug.Log($"开始录屏");
//SetCamPos(); SetCamPos();
// Start recording // Start recording
var frameRate = Application.targetFrameRate; var frameRate = 30;
//var sampleRate = recordMicrophone ? AudioSettings.outputSampleRate : 0; //var sampleRate = recordMicrophone ? AudioSettings.outputSampleRate : 0;
//var channelCount = recordMicrophone ? (int)AudioSettings.speakerMode : 0; //var channelCount = recordMicrophone ? (int)AudioSettings.speakerMode : 0;
var sampleRate = AudioSettings.outputSampleRate; var sampleRate = AudioSettings.outputSampleRate;
...@@ -102,9 +101,21 @@ namespace NatSuite.Examples { ...@@ -102,9 +101,21 @@ namespace NatSuite.Examples {
//webCamTextureInput = new WebCamTextureInput(recorder, clock, (WebCamTexture)tex); //webCamTextureInput = new WebCamTextureInput(recorder, clock, (WebCamTexture)tex);
//audioInput = recordMicrophone ? new AudioInput(recorder, clock, microphoneSource, true) : null; //audioInput = recordMicrophone ? new AudioInput(recorder, clock, microphoneSource, true) : null;
//audioInput = new AudioInput(recorder, clock, audioListener); audioInput = new AudioInput(recorder, clock, audioListener);
// Unmute microphone // 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 () public async void StopRecording ()
...@@ -114,7 +125,7 @@ namespace NatSuite.Examples { ...@@ -114,7 +125,7 @@ namespace NatSuite.Examples {
microphoneSource.mute = true; microphoneSource.mute = true;
// Stop recording // Stop recording
audioInput?.Dispose(); audioInput?.Dispose();
cameraInput.Dispose(); cameraInput?.Dispose();
var path = await recorder.FinishWriting(); var path = await recorder.FinishWriting();
// Playback recording // Playback recording
Debug.Log($"Saved recording to: {path}"); Debug.Log($"Saved recording to: {path}");
......
This diff is collapsed.
...@@ -43,6 +43,11 @@ public static class EventName ...@@ -43,6 +43,11 @@ public static class EventName
public const string Event_ImageScallChange = "Event_ImageScallChange"; //图片的缩放改变 public const string Event_ImageScallChange = "Event_ImageScallChange"; //图片的缩放改变
public const string Event_ReSetPicPos_Scale = "Event_ReSetPicPos_Scale"; //重新设置图片的位置和缩放 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 public class DataName
......
...@@ -75,15 +75,14 @@ public class ScaleToImage : MonoBehaviour ...@@ -75,15 +75,14 @@ public class ScaleToImage : MonoBehaviour
target.gameObject.SetActive(true); target.gameObject.SetActive(true);
} }
private bool FirstFlag;
private void Update() private void Update()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
MouseScale(); MouseScale();
#endif #endif
if (Input.touchCount == 2) if (Input.touchCount == 2)
{ {
RefreshScrollview();
Scale(); Scale();
flag = true; flag = true;
scrollRect.inertia = false; scrollRect.inertia = false;
...@@ -170,6 +169,7 @@ public class ScaleToImage : MonoBehaviour ...@@ -170,6 +169,7 @@ public class ScaleToImage : MonoBehaviour
{ {
if (!isInit_Scale) if (!isInit_Scale)
{ {
RefreshScrollview();
SetscrollRectEnable(false); SetscrollRectEnable(false);
//两指点位 //两指点位
touch1 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position); touch1 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position);
......
using NatSuite.Examples;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -6,17 +7,33 @@ using UnityEngine.UI; ...@@ -6,17 +7,33 @@ using UnityEngine.UI;
public class GameEndPanel : MonoBehaviour public class GameEndPanel : MonoBehaviour
{ {
private static GameEndPanel instance;
public static GameEndPanel Instance => instance;
public GameObject BG; public GameObject BG;
public Button SaveVideo_Btn; public Button SaveVideo_Btn;
public Button RePlayVideo_Btn; public Button RePlayVideo_Btn;
public Button Share_Btn; public Button Share_Btn;
public Button Continue_Btn; public Button Continue_Btn;
public Button interruptRecording_Btn; //中断录屏的按钮
public Transform PicParent; public Transform PicParent;
public ScrollRect scrollRect; public ScrollRect scrollRect;
public HorizontalLayoutGroup ItemParent; public HorizontalLayoutGroup ItemParent;
public GameObject item_obj; 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() private void Start()
{ {
ResiterEvent(true); ResiterEvent(true);
...@@ -25,7 +42,74 @@ public class GameEndPanel : MonoBehaviour ...@@ -25,7 +42,74 @@ public class GameEndPanel : MonoBehaviour
RePlayVideo_Btn.onClick.AddListener(RePlayVideo_Btn_Click); RePlayVideo_Btn.onClick.AddListener(RePlayVideo_Btn_Click);
Share_Btn.onClick.AddListener(Share_Btn_Click); Share_Btn.onClick.AddListener(Share_Btn_Click);
Continue_Btn.onClick.AddListener(Continue_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 private void CreateItem() //创建列表item
...@@ -56,13 +140,32 @@ public class GameEndPanel : MonoBehaviour ...@@ -56,13 +140,32 @@ public class GameEndPanel : MonoBehaviour
private void RePlayVideo_Btn_Click() private void RePlayVideo_Btn_Click()
{ {
Debug.Log("点击回放动画"); Debug.Log("点击回放动画");
GameMgr.Ins.RePlay();
} }
private void SaveVideo_Btn_Click() 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) private void ResiterEvent(bool flag)
{ {
EventDispatcher.RegisterEvent(EventName.Event.Event_AllGroupOver, GameEnd, flag); EventDispatcher.RegisterEvent(EventName.Event.Event_AllGroupOver, GameEnd, flag);
......
...@@ -6,10 +6,16 @@ using UnityEngine.UI; ...@@ -6,10 +6,16 @@ using UnityEngine.UI;
public class Gameing : MonoBehaviour public class Gameing : MonoBehaviour
{ {
private static Gameing instance;
public static Gameing Instance=>instance;
public Button ReSetPos_Btn; public Button ReSetPos_Btn;
public float ShowBtnScale;//显示重设位置按钮的缩放值 public float ShowBtnScale;//显示重设位置按钮的缩放值
public GameObject AutoFille_Btn; //自动涂色的按钮 public GameObject AutoFille_Btn; //自动涂色的按钮
// Start is called before the first frame update private void Awake()
{
instance = this;
}
void Start() void Start()
{ {
ResiterEvent(true); ResiterEvent(true);
...@@ -23,6 +29,7 @@ public class Gameing : MonoBehaviour ...@@ -23,6 +29,7 @@ public class Gameing : MonoBehaviour
EventDispatcher.RegisterEvent(EventName.Event.Event_GroupItemSelect, ShowAutoFill_Btn, flag); EventDispatcher.RegisterEvent(EventName.Event.Event_GroupItemSelect, ShowAutoFill_Btn, flag);
} }
private void ShowAutoFill_Btn(object[] values) private void ShowAutoFill_Btn(object[] values)
{ {
if (!AutoFille_Btn.activeSelf) if (!AutoFille_Btn.activeSelf)
......
...@@ -140,6 +140,11 @@ public class GroupListManager : MonoBehaviour ...@@ -140,6 +140,11 @@ public class GroupListManager : MonoBehaviour
float value = ClickAreaCount / AllAreaCount; float value = ClickAreaCount / AllAreaCount;
AllProcress.value = value; AllProcress.value = value;
AllProcress_Text.text = value.ToString("P0"); AllProcress_Text.text = value.ToString("P0");
if (value == 1)
{
GameEndPanel.Instance.OpenPanel();
}
} }
public float bigvalue=1; public float bigvalue=1;
...@@ -201,6 +206,9 @@ public class GroupListManager : MonoBehaviour ...@@ -201,6 +206,9 @@ public class GroupListManager : MonoBehaviour
} }
}; };
}; };
Vibration.VibrateNope(); //现在没有开关,直接震动
} }
IEnumerator DelayToSetContent() IEnumerator DelayToSetContent()
...@@ -267,7 +275,7 @@ public class GroupListManager : MonoBehaviour ...@@ -267,7 +275,7 @@ public class GroupListManager : MonoBehaviour
{ {
var item = roomGroupsData[i]; var item = roomGroupsData[i];
NowJindu = (float)dynamic.GetCountById(item.id) / item.roomIds.Count; 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); ClickAreaCount = ClickAreaCount + dynamic.GetCountById(item.id);
if (NowJindu >= 1) if (NowJindu >= 1)
continue; continue;
...@@ -414,5 +422,8 @@ public class GroupListManager : MonoBehaviour ...@@ -414,5 +422,8 @@ public class GroupListManager : MonoBehaviour
public void Test_Btn_RePlay() public void Test_Btn_RePlay()
{ {
GameMgr.Ins.RePlay(); GameMgr.Ins.RePlay();
EventDispatcher.Dispatch("Test");
} }
} }
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