guodong 1 жил өмнө
parent
commit
359ea36216

+ 13 - 0
GameClient/Assets/AssetBundleCollectorSetting.asset

@@ -203,3 +203,16 @@ MonoBehaviour:
         FilterRuleName: CollectAll
         AssetTags: 
         UserData: 
+    - GroupName: video
+      GroupDesc: 
+      AssetTags: preload
+      ActiveRuleName: EnableGroup
+      Collectors:
+      - CollectPath: Assets/Res/video
+        CollectorGUID: 75ef5add5a95a8c459409ffa4c638de9
+        CollectorType: 0
+        AddressRuleName: AddressByFileName
+        PackRuleName: PackVideo
+        FilterRuleName: CollectAll
+        AssetTags: 
+        UserData: 

+ 1 - 0
GameClient/Assets/GFGAsset/AssetBundleCollectRuler.asset

@@ -21,6 +21,7 @@ MonoBehaviour:
   - Assets/Res/Texture/Card/Bg
   - Assets/Res/model
   - Assets/Res/Material
+  - Assets/Res/video
   PackByTopDir:
   - Assets/Res/Effect/UI
   - Assets/Res/Texture/FieldGuide

+ 8 - 0
GameClient/Assets/Game/HotUpdate/UGUI/UICGView.cs

@@ -12,6 +12,7 @@ namespace GFGGame
         private const float VideoHeight = 1080f;
         private GameObject _ui;
         private AssetOperationHandle handle;
+        private RawFileOperationHandle videoHandle;
         private RawImage imgVideo;
         private Button btnFullScreen;
         private VideoPlayer videoPlayer;
@@ -38,6 +39,11 @@ namespace GFGGame
 
             videoPlayer = _ui.transform.Find("VideoPlayer").GetComponent<VideoPlayer>();
             videoPlayer.loopPointReached += OnVideoEnded;
+
+            string assetPath = ResPathUtil.GetVideoPath("cg");
+            videoHandle = YooAssets.LoadRawFileSync(assetPath);
+            videoPlayer.url = videoHandle.GetRawFilePath();
+            videoPlayer.Play();
         }
 
         private void OnVideoEnded(VideoPlayer source)
@@ -65,6 +71,8 @@ namespace GFGGame
         {
             handle.Release();
             handle = null;
+            videoHandle.Release();
+            videoHandle = null;
             GameObject.Destroy(_ui);
             _ui = null;
         }

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Utils/ResPathUtil.cs

@@ -18,6 +18,7 @@ namespace GFGGame
 
         public static readonly string MUSIC_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Music";
         public static readonly string SOUND_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Sound";
+        public static readonly string VIDEO_DIR_PATH = $"{RES_ROOT_DIR_PATH}/video";
         public static readonly string TEXTURE_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Texture";
         public static readonly string TEXTURE_DRESSUP_DIR_PATH = $"{TEXTURE_DIR_PATH}/DressUp";
         public static readonly string TEXTURE_SCENEBG_DIR_PATH = $"{TEXTURE_DIR_PATH}/SceneBg";
@@ -127,6 +128,10 @@ namespace GFGGame
         {
             return $"{SOUND_DIR_PATH}/Card/{res}.{extName}";
         }
+        public static string GetVideoPath(string res, string extName = "mp4")
+        {
+            return $"{VIDEO_DIR_PATH}/{res}.{extName}";
+        }
         public static string GetMusicPath(string res, string extName = "mp3")
         {
             return $"{MUSIC_DIR_PATH}/{res}.{extName}";

+ 8 - 0
GameClient/Assets/ResIn/RenderTexture.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 571898b49c734ca4faae8a6e15cdbad9
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 38 - 0
GameClient/Assets/ResIn/RenderTexture/video.renderTexture

@@ -0,0 +1,38 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!84 &8400000
+RenderTexture:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: video
+  m_ImageContentsHash:
+    serializedVersion: 2
+    Hash: 00000000000000000000000000000000
+  m_ForcedFallbackFormat: 4
+  m_DownscaleFallback: 0
+  m_IsAlphaChannelOptional: 0
+  serializedVersion: 3
+  m_Width: 1920
+  m_Height: 1080
+  m_AntiAliasing: 1
+  m_MipCount: -1
+  m_DepthFormat: 2
+  m_ColorFormat: 8
+  m_MipMap: 0
+  m_GenerateMips: 1
+  m_SRGB: 0
+  m_UseDynamicScale: 0
+  m_BindMS: 0
+  m_EnableCompatibleFormat: 1
+  m_TextureSettings:
+    serializedVersion: 2
+    m_FilterMode: 1
+    m_Aniso: 0
+    m_MipBias: 0
+    m_WrapU: 1
+    m_WrapV: 1
+    m_WrapW: 1
+  m_Dimension: 2
+  m_VolumeDepth: 1

+ 8 - 0
GameClient/Assets/ResIn/RenderTexture/video.renderTexture.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1be6a06cb8aae0043be65021f62f91a0
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 8400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

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

@@ -84,7 +84,7 @@ MonoBehaviour:
   m_FallbackScreenDPI: 96
   m_DefaultSpriteDPI: 96
   m_DynamicPixelsPerUnit: 1
-  m_PresetInfoIsWorld: 1
+  m_PresetInfoIsWorld: 0
 --- !u!114 &7362622180705135904
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -141,7 +141,7 @@ VideoPlayer:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 5639216484651693872}
   m_Enabled: 1
-  m_VideoClip: {fileID: 32900000, guid: e3110adc489acaa42b3494cffd1d01b2, type: 3}
+  m_VideoClip: {fileID: 0}
   m_TargetCameraAlpha: 1
   m_TargetCamera3DLayout: 0
   m_TargetCamera: {fileID: 0}
@@ -151,7 +151,7 @@ VideoPlayer:
   m_TargetMaterialProperty: _MainTex
   m_RenderMode: 2
   m_AspectRatio: 2
-  m_DataSource: 0
+  m_DataSource: 1
   m_PlaybackSpeed: 1
   m_AudioOutputMode: 2
   m_TargetAudioSources:

+ 21 - 0
GameClient/Assets/YooAsset/Editor/GFGAsset/Extension/PackVideo.cs

@@ -0,0 +1,21 @@
+using System.IO;
+
+namespace YooAsset.Editor
+{
+    public class PackVideo : IPackRule
+    {
+        public PackRuleResult GetPackRuleResult(PackRuleData data)
+        {
+            string bundleName = data.AssetPath;
+            string fileExtension = Path.GetExtension(data.AssetPath);
+            fileExtension = fileExtension.Remove(0, 1);
+            PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
+            return result;
+        }
+
+        public bool IsRawFilePackRule()
+        {
+            return true; //视频文件作为原生文件管理
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/YooAsset/Editor/GFGAsset/Extension/PackVideo.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bac9320546263104a8634880d460d601
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: