Browse Source

视频播放

guodong 1 year ago
parent
commit
e100bf5002

+ 50 - 3
GameClient/Assets/Game/HotUpdate/UGUI/UICGView.cs

@@ -1,12 +1,14 @@
-using System;
-using UnityEngine;
+using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Video;
 using YooAsset;
+using GFGGame.Launcher;
+using System.Collections;
+using System;
 
 namespace GFGGame
 {
-    public class UICGView : SingletonBase<UICGView>
+    public class UICGView : SingletonMonoBase<UICGView>
     {
         private const float VideoWidth = 1920f;
         private const float VideoHeight = 1080f;
@@ -19,6 +21,7 @@ namespace GFGGame
 
         public void Show()
         {
+            MusicManager.Instance.Stop();
             string path = ResPathUtil.GetUUIPrefabPath("UICG");
             handle = YooAssets.LoadAssetSync<GameObject>(path);
             _ui = handle.InstantiateSync(UGUIManager.Instance.desktop.transform);
@@ -39,15 +42,59 @@ namespace GFGGame
 
             videoPlayer = _ui.transform.Find("VideoPlayer").GetComponent<VideoPlayer>();
             videoPlayer.loopPointReached += OnVideoEnded;
+            videoPlayer.prepareCompleted += OnVideoPrepared;
 
             string assetPath = ResPathUtil.GetVideoPath("cg");
             videoHandle = YooAssets.LoadRawFileSync(assetPath);
             videoPlayer.url = videoHandle.GetRawFilePath();
             videoPlayer.Play();
+
+            
+        }
+
+        private void OnVideoPrepared(VideoPlayer source)
+        {
+            videoPlayer.prepareCompleted -= OnVideoPrepared;
+            StartCoroutine(FadeButtonOverTime());
+        }
+
+        IEnumerator FadeButtonOverTime()
+        {
+            Image buttonImage = btnFullScreen.GetComponent<Image>();
+            Text buttonText = btnFullScreen.GetComponentInChildren<Text>();
+            yield return new WaitForSeconds((float)videoPlayer.length - 3f);
+            if (buttonImage != null)
+            {
+                // 获取初始颜色
+                Color startColor = buttonImage.color;
+                Color startColorText = buttonText.color;
+
+                // 目标颜色,透明度设为 0
+                Color targetColor = new Color(startColor.r, startColor.g, startColor.b, 0f);
+                Color targetColorText = new Color(startColorText.r, startColorText.g, startColorText.b, 0f);
+
+                float fadeDuration = 1f;
+                // 记录开始时间
+                float startTime = Time.time;
+
+                while (Time.time - startTime < fadeDuration)
+                {
+                    // 在一定时间内逐渐插值颜色
+                    float t = (Time.time - startTime) / fadeDuration;
+                    buttonImage.color = Color.Lerp(startColor, targetColor, t);
+                    buttonText.color = Color.Lerp(startColorText, targetColorText, t);
+                    yield return null; // 等待下一帧
+                }
+
+                // 设置最终颜色,确保透明度为 0
+                buttonImage.color = targetColor;
+                buttonText.color = targetColorText;
+            }
         }
 
         private void OnVideoEnded(VideoPlayer source)
         {
+            videoPlayer.loopPointReached -= OnVideoEnded;
             this.Hide();
             StoryController.ShowLevelView(100001001);
         }

+ 5 - 5
GameClient/Assets/ResIn/UUI/UICG.prefab

@@ -84,7 +84,7 @@ MonoBehaviour:
   m_FallbackScreenDPI: 96
   m_DefaultSpriteDPI: 96
   m_DynamicPixelsPerUnit: 1
-  m_PresetInfoIsWorld: 0
+  m_PresetInfoIsWorld: 1
 --- !u!114 &7362622180705135904
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -205,7 +205,7 @@ RectTransform:
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
   m_AnchoredPosition: {x: 0, y: -339}
-  m_SizeDelta: {x: 180, y: 55}
+  m_SizeDelta: {x: 160, y: 50}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &5442437178465132142
 CanvasRenderer:
@@ -228,7 +228,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0.8301887, g: 0.8262727, b: 0.8262727, a: 1}
+  m_Color: {r: 0.21698111, g: 0.21698111, b: 0.21698111, a: 0.36862746}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
@@ -419,7 +419,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0.2735849, g: 0.2735849, b: 0.2735849, a: 1}
+  m_Color: {r: 1, g: 1, b: 1, a: 0.8352941}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
@@ -428,7 +428,7 @@ MonoBehaviour:
       m_Calls: []
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
-    m_FontSize: 30
+    m_FontSize: 26
     m_FontStyle: 0
     m_BestFit: 0
     m_MinSize: 2