Skip to content

Commit

Permalink
Merge pull request #160 from LeZi9916/sensor-perf
Browse files Browse the repository at this point in the history
JsonDataLoader optimization
  • Loading branch information
LingFeng-bbben authored Aug 12, 2024
2 parents b79cf54 + bbc8438 commit 5f0299d
Show file tree
Hide file tree
Showing 16 changed files with 292 additions and 815 deletions.
18 changes: 18 additions & 0 deletions Assets/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<config>
<add key="packageInstallLocation" value="CustomWithinAssets" />
<add key="repositoryPath" value="./Packages" />
<add key="PackagesConfigDirectoryPath" value="." />
<add key="slimRestore" value="true" />
<add key="PreferNetStandardOverNetFramework" value="true" />
</config>
</configuration>
32 changes: 32 additions & 0 deletions Assets/NuGet.config.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -8905,6 +8905,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
CutoffTime: 0
APObj: {fileID: 1153691776}
--- !u!4 &1463030766
Transform:
m_ObjectHideFlags: 0
Expand Down
149 changes: 72 additions & 77 deletions Assets/Scripts/HttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ private void Start()

private void Update()
{
if (request == "") return;
if (string.IsNullOrEmpty(request)) return;

IsReloding = false;
var data = JsonConvert.DeserializeObject<EditRequestjson>(request);
request = string.Empty;

var loader = GameObject.Find("DataLoader").GetComponent<JsonDataLoader>();
var timeProvider = GameObject.Find("AudioTimeProvider").GetComponent<AudioTimeProvider>();
Expand All @@ -39,84 +41,77 @@ private void Update()
var multTouchHandler = GameObject.Find("MultTouchHandler").GetComponent<MultTouchHandler>();
var objectCounter = GameObject.Find("ObjectCounter").GetComponent<ObjectCounter>();

if (data.control == EditorControlMethod.Start)
{
request = "";
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
GameObject.Find("Notes").GetComponent<PlayAllPerfect>().enabled = false;
GameObject.Find("MultTouchHandler").GetComponent<MultTouchHandler>().clearSlots();

bgManager.LoadBGFromPath(new FileInfo(data.jsonPath).DirectoryName, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}

if (data.control == EditorControlMethod.OpStart)
{
request = "";
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
GameObject.Find("MultTouchHandler").GetComponent<MultTouchHandler>().clearSlots();

bgManager.LoadBGFromPath(new FileInfo(data.jsonPath).DirectoryName, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
bgManager.PlaySongDetail();
GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}

if (data.control == EditorControlMethod.Record)
{
request = "";
var maidataPath = new FileInfo(data.jsonPath).DirectoryName;
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed, true);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
multTouchHandler.clearSlots();

screenRecorder.CutoffTime = getChartLength();
screenRecorder.CutoffTime += 10f;
screenRecorder.StartRecording(maidataPath);

bgManager.LoadBGFromPath(maidataPath, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
bgManager.PlaySongDetail();
GameObject.Find("CanvasButtons").SetActive(false);
GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}

if (data.control == EditorControlMethod.Pause)
{
timeProvider.isStart = false;
bgManager.PauseVideo();
}

if (data.control == EditorControlMethod.Stop)
{
screenRecorder.StopRecording();
timeProvider.ResetStartTime();
IsReloding = true;
SceneManager.LoadScene(1);
}

if (data.control == EditorControlMethod.Continue)
switch(data.control)
{
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
bgManager.ContinueVideo(data.audioSpeed);
case EditorControlMethod.Start:
{
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
GameObject.Find("Notes").GetComponent<PlayAllPerfect>().enabled = false;
GameObject.Find("MultTouchHandler").GetComponent<MultTouchHandler>().clearSlots();

bgManager.LoadBGFromPath(new FileInfo(data.jsonPath).DirectoryName, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
//GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}
break;
case EditorControlMethod.OpStart:
{
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
GameObject.Find("MultTouchHandler").GetComponent<MultTouchHandler>().clearSlots();

bgManager.LoadBGFromPath(new FileInfo(data.jsonPath).DirectoryName, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
bgManager.PlaySongDetail();
//GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}
break;
case EditorControlMethod.Record:
{
var maidataPath = new FileInfo(data.jsonPath).DirectoryName;
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed, true);
loader.noteSpeed = (float)(107.25 / (71.4184491 * Mathf.Pow(data.noteSpeed + 0.9975f, -0.985558604f)));
loader.touchSpeed = data.touchSpeed;
loader.smoothSlideAnime = data.smoothSlideAnime;
objectCounter.ComboSetActive(data.comboStatusType);
loader.LoadJson(File.ReadAllText(data.jsonPath), data.startTime);
multTouchHandler.clearSlots();

screenRecorder.CutoffTime = getChartLength();
screenRecorder.CutoffTime += 10f;
screenRecorder.StartRecording(maidataPath);

bgManager.LoadBGFromPath(maidataPath, data.audioSpeed);
bgCover.color = new Color(0f, 0f, 0f, data.backgroundCover);
bgManager.PlaySongDetail();
GameObject.Find("CanvasButtons").SetActive(false);
//GameObject.Find("Notes").GetComponent<NoteManager>().Refresh();
}
break;
case EditorControlMethod.Pause:
timeProvider.isStart = false;
bgManager.PauseVideo();
break;
case EditorControlMethod.Stop:
screenRecorder.StopRecording();
timeProvider.ResetStartTime();
IsReloding = true;
SceneManager.LoadScene(1);
break;
case EditorControlMethod.Continue:
timeProvider.SetStartTime(data.startAt, data.startTime, data.audioSpeed);
bgManager.ContinueVideo(data.audioSpeed);
break;
}

request = "";
}

private void OnDestroy()
Expand Down
Loading

0 comments on commit 5f0299d

Please sign in to comment.