-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Unity player added resync button added reload button added auto resync button added auto resync on stutter (if auto resync is on)
- Loading branch information
1 parent
b62f3f9
commit 4c4349f
Showing
7 changed files
with
579 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
| ||
using System; | ||
using UdonSharp; | ||
using UnityEngine; | ||
using VRC.SDK3.Components; | ||
using VRC.SDKBase; | ||
using VRC.Udon; | ||
|
||
namespace UdonVR.Takato.VideoPlayer | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class PanelController : UdonSharpBehaviour | ||
{ | ||
public PanelUI[] panels; | ||
|
||
public void AutoResyncToggle(bool value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.AutoResyncToggle(value); | ||
} | ||
} | ||
public void AutoResyncRateInput(int value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.AutoResyncRateInput(value); | ||
} | ||
} | ||
|
||
public void SetOwnerText(string displayName) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.SetOwnerText(displayName); | ||
} | ||
} | ||
|
||
public void SetVideoTimeBarMaxValue(float value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.SetVideoTimeBarMaxValue(value); | ||
} | ||
} | ||
|
||
public void SetVideoTimeBarValue(int value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.SetVideoTimeBarValue(value); | ||
} | ||
} | ||
|
||
public void VideoTimeBarInteractable(bool value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.VideoTimeBarInteractable(value); | ||
} | ||
} | ||
|
||
public void SetResyncText(string value) | ||
{ | ||
foreach (PanelUI Panel in panels) | ||
{ | ||
Panel.SetResyncText(value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using TMPro; | ||
using UdonSharp; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using VRC.SDK3.Components; | ||
using VRC.SDKBase; | ||
using VRC.Udon; | ||
|
||
namespace UdonVR.Takato.VideoPlayer | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class PanelUI : UdonSharpBehaviour | ||
{ | ||
public UdonSyncVideoPlayer UdonSyncVideoPlayer; | ||
public GameObject autoResyncFilled; | ||
public TextMeshProUGUI resyncText; | ||
public InputField autoResyncRateInput; | ||
public Text ownerText; | ||
public Slider videoTimeBar; | ||
public Text videoTimeBarText; | ||
|
||
public void AutoResyncToggle(bool value) | ||
{ | ||
if (Utilities.IsValid(autoResyncFilled)) | ||
{ | ||
autoResyncFilled.SetActive(value); | ||
} | ||
} | ||
|
||
public void AutoResyncSet() | ||
{ | ||
if (Utilities.IsValid(autoResyncRateInput)) | ||
{ | ||
if (!string.IsNullOrEmpty(autoResyncRateInput.text.Trim())) | ||
return; | ||
|
||
int temp; | ||
int.TryParse(autoResyncRateInput.text, out temp); | ||
UdonSyncVideoPlayer.AutoResyncSet(temp); | ||
autoResyncRateInput.text = string.Empty; | ||
|
||
} | ||
} | ||
public void AutoResyncRateInput(int value) | ||
{ | ||
if (Utilities.IsValid(autoResyncRateInput)) | ||
{ | ||
((Text)autoResyncRateInput.placeholder).text= value.ToString(); | ||
|
||
} | ||
} | ||
|
||
public void SetOwnerText(string displayName) | ||
{ | ||
if (Utilities.IsValid(ownerText)) | ||
{ | ||
ownerText.text = displayName; | ||
} | ||
} | ||
|
||
public void SetVideoTimeBarValue(int value) | ||
{ | ||
if (Utilities.IsValid(videoTimeBar)) | ||
{ | ||
videoTimeBar.value = value; | ||
} | ||
} | ||
|
||
public void SetVideoTimeBarMaxValue(float value) | ||
{ | ||
if (Utilities.IsValid(videoTimeBar)) | ||
{ | ||
videoTimeBar.maxValue = value; | ||
} | ||
} | ||
|
||
public void VideoTimeBarInteractable(bool value) | ||
{ | ||
if (Utilities.IsValid(videoTimeBar)) | ||
{ | ||
videoTimeBar.interactable = value; | ||
} | ||
} | ||
|
||
public void SetResyncText(string value) | ||
{ | ||
if (Utilities.IsValid(resyncText)) | ||
{ | ||
resyncText.text = value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
| ||
using UdonSharp; | ||
using UnityEngine; | ||
using VRC.SDKBase; | ||
using VRC.Udon; | ||
using UnityEngine.UI; | ||
using UdonVR.Takato.VideoPlayer; | ||
|
||
namespace UdonVR | ||
{ | ||
public class StutterDetector : UdonSharpBehaviour | ||
{ | ||
public UdonSyncVideoPlayer VideoPlayer; | ||
public float Target = 2f; | ||
public GameObject TargetObj; | ||
public InputField Inputfeild; | ||
public GameObject ParentDebug; | ||
|
||
private bool isDebug = false; | ||
private Text[] DebugChildren; | ||
private int ChildCount = 0; | ||
private int CurrentChild = 0; | ||
private float OldTime = 10f; | ||
private float CurTime = 0; | ||
void Start() | ||
{ | ||
if (ParentDebug != null) | ||
{ | ||
DebugChildren = ParentDebug.transform.GetComponentsInChildren<Text>(); | ||
ChildCount = DebugChildren.Length - 1; | ||
reset(); | ||
isDebug = true; | ||
} | ||
} | ||
|
||
private void Update() | ||
{ | ||
if (VideoPlayer.autoResync) | ||
{ | ||
CurTime = Time.deltaTime; | ||
|
||
if (CurTime > OldTime * Target) | ||
{ | ||
VideoPlayer.ForceSyncVideo(); | ||
} | ||
|
||
if (isDebug) DebugOut(); | ||
|
||
OldTime = Time.deltaTime; | ||
} | ||
} | ||
|
||
public void reset() | ||
{ | ||
if (TargetObj != null) | ||
TargetObj.SetActive(false); | ||
} | ||
|
||
public void SetTarget() | ||
{ | ||
Target = float.Parse(Inputfeild.text); | ||
} | ||
|
||
private void DebugOut() | ||
{ | ||
if (CurTime > OldTime * Target) | ||
{ | ||
if (TargetObj != null) | ||
TargetObj.SetActive(true); | ||
} | ||
DebugChildren[CurrentChild].text = CurTime.ToString(); | ||
CurrentChild++; | ||
if (CurrentChild > ChildCount) CurrentChild = 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.