Initial commit

This commit is contained in:
Thorbjoern
2025-05-26 00:46:28 +02:00
commit e5bca03433
3896 changed files with 1434297 additions and 0 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 42158b7ede61a48479531cb08189b842
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8616146354579747861
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 9
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Video_Material_Unlit
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _SURFACE_TYPE_TRANSPARENT
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- DepthOnly
- SHADOWCASTER
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BlendOp: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlendAlpha: 10
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _SampleGI: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _SrcBlendAlpha: 1
- _Surface: 1
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e041278372347f446a19c64f6ffc27e5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 362ea76c0af49684f8ec39e5a91e9e17
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a1adb4a6fb2422d47b8534d95732c77e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 404a6c7fad28b6a40935172065ba923a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
namespace XRMultiplayer
{
/// <summary>
/// Create a RenderTexture for rendering video to a target renderer.
/// </summary>
[RequireComponent(typeof(VideoPlayer))]
public class VideoPlayerRenderTexture : MonoBehaviour
{
const string k_ShaderName = "Unlit/Texture";
[SerializeField]
[Tooltip("The target Image which will display the video.")]
RawImage m_Image;
[SerializeField] Vector2 m_ImageSize = new Vector2(1920, 1080);
[SerializeField] float m_Scale = 1.0f;
[SerializeField] float m_ZOffset = -1;
[SerializeField]
[Tooltip("The width of the RenderTexture which will be created.")]
int m_RenderTextureWidth = 1920;
[SerializeField]
[Tooltip("The height of the RenderTexture which will be created.")]
int m_RenderTextureHeight = 1080;
[SerializeField]
[Tooltip("The bit depth of the depth channel for the RenderTexture which will be created.")]
int m_RenderTextureDepth;
VideoPlayer m_VideoPlayer;
void OnValidate()
{
if (m_Image == null) return;
m_Image.rectTransform.sizeDelta = m_ImageSize * m_Scale;
m_Image.rectTransform.localPosition = new Vector3(m_Image.rectTransform.localPosition.x, m_Image.rectTransform.localPosition.y, m_ZOffset);
}
void Awake()
{
if (!TryGetComponent(out m_VideoPlayer))
{
Utils.Log("VideoPlayerRenderTexture requires a VideoPlayer component.", 2);
return;
}
var renderTexture = new RenderTexture(m_RenderTextureWidth, m_RenderTextureHeight, m_RenderTextureDepth);
renderTexture.Create();
m_Image.material.mainTexture = renderTexture;
m_VideoPlayer.targetTexture = renderTexture;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e9f926e9bbc6b3149869d0f7ecdf53a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,165 @@
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
namespace XRMultiplayer
{
public class VideoPlayerTutorial : MonoBehaviour
{
[SerializeField] GameObject m_InfoButtonObject;
[SerializeField] GameObject m_VideoPlayerObject;
[SerializeField] TMP_Dropdown m_Dropdown;
[SerializeField] TMP_Text m_HeaderText;
[SerializeField] VideoClip[] m_VideoClips;
[SerializeField] float m_HideDistance = 10.0f;
[SerializeField] bool m_AutoDisplay = false;
[SerializeField] CanvasGroup m_InfoButtonFadeGroup;
[SerializeField] CanvasGroup m_VideoFadeGroup;
[SerializeField] RawImage m_VideoImage;
[SerializeField] VideoPlayer m_VideoPlayer;
[SerializeField] float m_FadeSpeedVideo = 5.0f;
[SerializeField] float m_FadeSpeedButton = 5.0f;
Camera m_MainCam;
bool m_IsHidden = false;
IEnumerator m_FadeEnumerator;
void Start()
{
m_MainCam = Camera.main;
if (m_VideoClips.Length < 2)
{
m_Dropdown.gameObject.SetActive(false);
}
else
{
// Clear the dropdown options
m_Dropdown.ClearOptions();
foreach (var c in m_VideoClips)
{
TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(c.name);
m_Dropdown.options.Add(optionData);
}
m_Dropdown.onValueChanged.AddListener(PickVideo);
}
Hide();
}
void PickVideo(int index)
{
m_VideoPlayer.Stop();
m_VideoPlayer.clip = m_VideoClips[index];
m_HeaderText.text = m_VideoClips[index].name;
m_VideoPlayer.targetTexture.Release();
m_VideoPlayer.Play();
}
void Update()
{
if (Vector3.Distance(m_MainCam.transform.position, transform.position) < m_HideDistance)
{
if (m_IsHidden)
{
EnableTutorial();
}
}
else
{
if (!m_IsHidden)
{
HideTutorial();
}
}
}
void HideTutorial()
{
m_IsHidden = true;
if (m_FadeEnumerator != null) StopCoroutine(m_FadeEnumerator);
m_FadeEnumerator = FadeOutRoutine();
StartCoroutine(m_FadeEnumerator);
}
void EnableTutorial()
{
m_IsHidden = false;
ToggleVideo(m_AutoDisplay);
}
/// <summary>
/// Called from UI button press.
/// </summary>
/// <param name="toggle"></param>
public void ToggleVideo(bool toggle)
{
m_InfoButtonObject.SetActive(!toggle);
m_VideoPlayerObject.SetActive(toggle);
if (toggle)
{
m_VideoFadeGroup.alpha = 0.0f;
m_VideoImage.material.color = new Color(1, 1, 1, m_VideoFadeGroup.alpha);
m_VideoPlayer.targetTexture.Release();
if (m_FadeEnumerator != null) StopCoroutine(m_FadeEnumerator);
m_FadeEnumerator = FadeVideoRoutine();
StartCoroutine(m_FadeEnumerator);
}
else
{
m_InfoButtonFadeGroup.alpha = 0.0f;
if (m_FadeEnumerator != null) StopCoroutine(m_FadeEnumerator);
m_FadeEnumerator = FadeButtonRoutine();
StartCoroutine(m_FadeEnumerator);
}
}
IEnumerator FadeButtonRoutine()
{
while (m_InfoButtonFadeGroup.alpha < 1.0f)
{
m_InfoButtonFadeGroup.alpha += Time.deltaTime * m_FadeSpeedButton;
yield return null;
}
}
IEnumerator FadeVideoRoutine()
{
while (m_VideoFadeGroup.alpha < 1.0f)
{
m_VideoFadeGroup.alpha += Time.deltaTime * m_FadeSpeedVideo;
m_VideoImage.material.color = new Color(1, 1, 1, m_VideoFadeGroup.alpha);
yield return null;
}
}
IEnumerator FadeOutRoutine()
{
while (m_VideoFadeGroup.alpha > 0.0f || m_InfoButtonFadeGroup.alpha > 0.0f)
{
float fadeAmount = Time.deltaTime * m_FadeSpeedVideo;
m_VideoFadeGroup.alpha -= fadeAmount;
m_VideoImage.material.color = new Color(1, 1, 1, m_VideoFadeGroup.alpha);
m_InfoButtonFadeGroup.alpha -= fadeAmount;
yield return null;
}
Hide();
m_VideoPlayer.targetTexture.Release();
}
void Hide()
{
m_InfoButtonObject.SetActive(false);
m_VideoPlayerObject.SetActive(false);
m_IsHidden = true;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd3e26a6cf901f645a64b02f39f5c2f1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,180 @@
using System;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
namespace XRMultiplayer
{
/// <summary>
/// Connects a UI slider control to a video player, allowing users to scrub to a particular time in th video.
/// </summary>
[RequireComponent(typeof(VideoPlayer))]
public class VideoTimeScrubControl : MonoBehaviour
{
private const string TIME_FORMAT = "m':'ss";
[SerializeField]
[Tooltip("Video play/pause button GameObject")]
GameObject m_ButtonPlayOrPause;
[SerializeField, Tooltip("Use Play/Pause Butotn")]
bool m_UsePlayPauseButton = true;
[SerializeField]
[Tooltip("Slider that controls the video")]
Slider m_Slider;
[SerializeField]
[Tooltip("Play icon sprite")]
Sprite m_IconPlay;
[SerializeField]
[Tooltip("Pause icon sprite")]
Sprite m_IconPause;
[SerializeField]
[Tooltip("Play or pause button image.")]
Image m_ButtonPlayOrPauseIcon;
[SerializeField]
[Tooltip("If checked, the slider will fade off after a few seconds. If unchecked, the slider will remain on.")]
bool m_HideSliderAfterFewSeconds;
[SerializeField, Tooltip("The Video Player Time Text")]
TMP_Text m_VideoTimeText;
bool m_IsDragging;
bool m_VideoIsPlaying;
bool m_VideoJumpPending;
long m_LastFrameBeforeScrub;
VideoPlayer m_VideoPlayer;
void Start()
{
if (!TryGetComponent(out m_VideoPlayer))
{
Utils.Log("VideoTimeScrubControl: No VideoPlayer component found on this GameObject.", 2);
return;
}
if (!m_VideoPlayer.playOnAwake)
{
m_VideoPlayer.playOnAwake = true; // Set play on awake for next enable.
m_VideoPlayer.Play(); // Play video to load first frame.
VideoStop(); // Stop the video to set correct state and pause frame.
}
else
{
VideoPlay(); // Play to ensure correct state.
}
if (!m_UsePlayPauseButton && m_ButtonPlayOrPause != null)
m_ButtonPlayOrPause.SetActive(false);
}
void OnEnable()
{
if (m_VideoPlayer != null)
{
m_VideoPlayer.frame = 0;
VideoPlay(); // Ensures correct UI state update if paused.
}
m_Slider.value = 0.0f;
m_Slider.gameObject.SetActive(true);
if (m_HideSliderAfterFewSeconds)
StartCoroutine(HideSliderAfterSeconds());
}
void Update()
{
if (m_VideoJumpPending)
{
// We're trying to jump to a new position, but we're checking to make sure the video player is updated to our new jump frame.
if (m_LastFrameBeforeScrub == m_VideoPlayer.frame)
return;
// If the video player has been updated with desired jump frame, reset these values.
m_LastFrameBeforeScrub = long.MinValue;
m_VideoJumpPending = false;
}
if (!m_IsDragging && !m_VideoJumpPending)
{
if (m_VideoPlayer.frameCount > 0)
{
var progress = (float)m_VideoPlayer.frame / m_VideoPlayer.frameCount;
m_Slider.value = progress;
}
}
TimeSpan elapsedTime = TimeSpan.FromSeconds(m_VideoPlayer.time);
TimeSpan totalTime = TimeSpan.FromSeconds(m_VideoPlayer.length);
m_VideoTimeText.text = $"{elapsedTime.ToString(TIME_FORMAT)} / {totalTime.ToString(TIME_FORMAT)}";
}
public void OnPointerDown()
{
m_VideoJumpPending = true;
VideoStop();
VideoJump();
}
public void OnRelease()
{
m_IsDragging = false;
VideoPlay();
VideoJump();
}
IEnumerator HideSliderAfterSeconds(float duration = 1f)
{
yield return new WaitForSeconds(duration);
m_Slider.gameObject.SetActive(false);
}
public void OnDrag()
{
m_IsDragging = true;
m_VideoJumpPending = true;
}
void VideoJump()
{
m_VideoJumpPending = true;
var frame = m_VideoPlayer.frameCount * m_Slider.value;
m_LastFrameBeforeScrub = m_VideoPlayer.frame;
m_VideoPlayer.frame = (long)frame;
}
public void PlayOrPauseVideo()
{
if (m_VideoIsPlaying)
{
VideoStop();
}
else
{
VideoPlay();
}
}
void VideoStop()
{
m_VideoIsPlaying = false;
m_VideoPlayer.Pause();
m_ButtonPlayOrPauseIcon.sprite = m_IconPlay;
if (!m_UsePlayPauseButton && m_ButtonPlayOrPause != null)
m_ButtonPlayOrPause.SetActive(true);
}
void VideoPlay()
{
m_VideoIsPlaying = true;
m_VideoPlayer.Play();
m_ButtonPlayOrPauseIcon.sprite = m_IconPause;
if (!m_UsePlayPauseButton && m_ButtonPlayOrPause != null)
m_ButtonPlayOrPause.SetActive(false);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ca75f292f7449044807f6ba9e6f954c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 919286d1d37402944b2f8cdb7548f380
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:07e74573844b4890595a194d1b0997ad334497ec3bf129b6e9134842ad7b0d01
size 69657730
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 87d11a3bec65c412285b2db5618c1eb9
VideoClipImporter:
externalObjects: {}
serializedVersion: 3
frameRange: 0
startFrame: -1
endFrame: -1
colorSpace: 0
deinterlace: 0
encodeAlpha: 0
flipVertical: 0
flipHorizontal: 0
importAudio: 1
targetSettings:
:
enableTranscoding: 0
codec: 2
resizeFormat: 2
aspectRatio: 0
customWidth: 1280
customHeight: 720
bitrateMode: 2
spatialQuality: 2
userData:
assetBundleName:
assetBundleVariant: