瀏覽代碼

截取场景指定层级像素工具

zhaoyang 2 年之前
父節點
當前提交
27cd2d613a

+ 6 - 0
FGUIProject/assets/Main/StoryFightSingleScoreUI.xml

@@ -1,6 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <component size="1080,1920" designImage="ui://mfvz4q8kuo1t9j" designImageOffsetY="-120">
   <displayList>
+    <loader id="n39_wono" name="loaBg" xy="540,960" pivot="0.5,0.5" anchor="true" size="1080,2400" fill="scaleMatchWidth">
+      <relation target="" sidePair="width-width,height-height,center-center,middle-middle"/>
+    </loader>
+    <loader id="n38_wono" name="loaRole" xy="0,0" size="1080,1920">
+      <relation target="" sidePair="center-center,middle-middle"/>
+    </loader>
     <component id="n34_tc53" name="btnBack" src="9xlo8" fileName="components/ButtonBack1.xml" pkg="eg2y0ldp" xy="35,80"/>
     <component id="n0_8xpg" name="selfScore" src="8xpg4e" fileName="components/CompFightScore.xml" xy="419,843" visible="false">
       <relation target="" sidePair="center-center,middle-middle"/>

+ 30 - 2
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 using Live2D.Cubism.Rendering;
 using System.IO;
 using FairyGUI;
+using System.Collections.Generic;
 
 namespace GFGGame
 {
@@ -227,8 +228,12 @@ namespace GFGGame
             var aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
             TryRemoveAnimationObj(parentObj, aniObjName);
             string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
-            AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
-            if (itemCfg.isAni > 0 && showAni)
+          GameObject gameObject=  AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
+            if (itemCfg.subType == (int)ConstDressUpItemType.BEI_JING)
+            {
+                gameObject.layer = 6;//设置bg层
+            }
+                if (itemCfg.isAni > 0 && showAni)
             {
                 AddAnimationObj(res, aniObjName, parentObj, sortingOrder);
                 Timers.inst.Add(0.03f, 1, (obj) =>
@@ -441,5 +446,28 @@ namespace GFGGame
                 }
             }
         }
+
+        public static NTexture GetPrintscreenNTexture(Camera camera)
+        {
+            Rect rect = new Rect(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height);
+            RenderTexture render = new RenderTexture((int)rect.width, (int)rect.height, -1);//创建一个RenderTexture对象 
+
+            camera.gameObject.SetActive(true);//启用截图相机
+            camera.targetTexture = render;//设置截图相机的targetTexture为render
+            camera.Render();//手动开启截图相机的渲染
+
+            RenderTexture.active = render;//激活RenderTexture
+            Texture2D tex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.ARGB32, false);//新建一个Texture2D对象
+            tex.ReadPixels(rect, 0, 0);//读取像素
+            tex.Apply();//保存像素信息
+
+            camera.targetTexture = null;//重置截图相机的targetTexture
+            RenderTexture.active = null;//关闭RenderTexture的激活状态
+            Object.Destroy(render);//删除RenderTexture对象
+            camera.gameObject.SetActive(true);
+          
+            return new NTexture(tex);
+
+        }
     }
 }

+ 6 - 0
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Main/UI_StoryFightSingleScoreUI.cs

@@ -7,6 +7,8 @@ namespace UI.Main
     public partial class UI_StoryFightSingleScoreUI
     {
         public GComponent target;
+        public GLoader m_loaBg;
+        public GLoader m_loaRole;
         public GButton m_btnBack;
         public UI_CompFightScore m_selfScore;
         public UI_comClickCircle m_comClickCircle;
@@ -69,6 +71,8 @@ namespace UI.Main
 
         private void Init(GComponent comp)
         {
+            m_loaBg = (GLoader)comp.GetChild("loaBg");
+            m_loaRole = (GLoader)comp.GetChild("loaRole");
             m_btnBack = (GButton)comp.GetChild("btnBack");
             m_selfScore = (UI_CompFightScore)UI_CompFightScore.Create(comp.GetChild("selfScore"));
             m_comClickCircle = (UI_comClickCircle)UI_comClickCircle.Create(comp.GetChild("comClickCircle"));
@@ -87,6 +91,8 @@ namespace UI.Main
         }
         public void Dispose(bool disposeTarget = false)
         {
+            m_loaBg = null;
+            m_loaRole = null;
             m_btnBack = null;
             m_selfScore.Dispose();
             m_selfScore = null;

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

@@ -10,6 +10,7 @@ namespace GFGGame
         public const string UI_DIR_PATH = "Assets/ResIn/UI";
         public const string TEXTURE_DIR_PATH = "Assets/Res/Texture";
         public const string PREFAB_DIR_PATH = "Assets/ResIn/Prefab";
+        public const string TEXTURE_FIGHT_DIR_PATH = "Assets/ResIn/Fight";
         public const string CONFIG_DIR_PATH = "Assets/ResIn/Config";
         public const string ANIMATION_DIR_PATH = "Assets/Res/Animation";
         public const string EFFECT_DIR_PATH = "Assets/Res/Effect";
@@ -38,6 +39,9 @@ namespace GFGGame
         public static string GetBgImgPath(string res, string extName = "png")
         {
             return $"{TEXTURE_DIR_PATH}/BgImg/{res}.{extName}";
+        }public static string GetFightBgImgPath(string res, string extName = "png")
+        {
+            return $"{TEXTURE_FIGHT_DIR_PATH}/{res}.{extName}";
         }
         public static string GetDressUpPath(string res, string extName = "png")
         {

+ 6 - 3
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs

@@ -425,13 +425,16 @@ namespace GFGGame
                 FieldFightDataManager.Instance.currentLevelCfgId = InstanceZonesDataManager.currentLevelCfgId;
                 FieldFightDataManager.Instance.equipDatas = EquipDataCache.cacher.equipDatas;
             }
+            Camera camera = _sceneObject.transform.Find("Camera").gameObject.GetComponent<Camera>();
+            NTexture nTexture = DressUpUtil.GetPrintscreenNTexture(camera);
+
             if (hasFightTarget)
             {
-                ViewManager.Show(ViewName.STORY_FIGHT_TARGET_VIEW);
+                ViewManager.Show(ViewName.STORY_FIGHT_TARGET_VIEW, nTexture);
             }
             else
             {
-                ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_VIEW);
+                ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_VIEW, nTexture);
             }
             this.Hide();
 
@@ -448,7 +451,7 @@ namespace GFGGame
             InstanceZonesDataManager.usedRecommend = true;
             EquipDataCache.cacher.PutOnRecommendItems();
             UpdateListPartsSelected();
-            UpdateListSuitPartsSelected();
+            UpdateListSuitPartsSelected();          
         }
 
         private void InitLists()

+ 7 - 2
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleScoreView.cs

@@ -75,6 +75,8 @@ namespace GFGGame
             _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
             _ui.m_btnBack.onClick.Add(OnBtnBackClick);
             _ui.m_btnSpeedUp.onClick.Add(OnBtnSpeedUp);
+            
+            _ui.m_loaBg.url = ResPathUtil.GetFightBgImgPath("zd_bj_bja_2");
 
             AddEffect();
 
@@ -87,8 +89,11 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            if (_sceneObject == null) _sceneObject = GameObject.Instantiate(_scenePrefab);
-            SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
+            NTexture nTexture = this.viewData as NTexture;
+            //if (_sceneObject == null) _sceneObject = GameObject.Instantiate(_scenePrefab);
+            //SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
+            _ui.m_loaRole.texture = nTexture;
+            _ui.m_loaRole.SetSize(_ui.m_loaRole.width, _ui.m_loaRole.texture.height * _ui.m_loaRole.width / _ui.m_loaRole.texture.width);
 
             _gameObject2.SetActive(false);
             _ui.m_comClickCircle.target.onClick.Add(CircleScoreEnd);

+ 2 - 1
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleView.cs

@@ -43,6 +43,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
+            NTexture nTexture = this.viewData as NTexture;
             if (_sceneObject == null)
             {
                 _sceneObject = GameObject.Instantiate(_scenePrefab);
@@ -58,7 +59,7 @@ namespace GFGGame
             Timers.inst.Add(0.9f, 1, (object param) =>
             {
                 this.Hide();
-                ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_SCORE_VIEW);
+                ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_SCORE_VIEW, nTexture);
             });
         }
 

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetView.cs

@@ -43,7 +43,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-
+            NTexture nTexture = this.viewData as NTexture;
             if (_sceneObject == null)
             {
                 _sceneObject = GameObject.Instantiate(_scenePrefab);
@@ -61,7 +61,7 @@ namespace GFGGame
             Timers.inst.Add(1.1f, 1, (object param) =>
             {
                 this.Hide();
-                ViewManager.Show(ViewName.STORY_FIGHT_TARGET_SCORE_VIEW);
+                ViewManager.Show(ViewName.STORY_FIGHT_TARGET_SCORE_VIEW, nTexture);
             });
         }
 

+ 88 - 0
GameClient/Assets/ResIn/Prefab/SceneDressUp.prefab

@@ -1,5 +1,92 @@
 %YAML 1.1
 %TAG !u! tag:unity3d.com,2011:
+--- !u!1 &1782485218948418575
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 4137215948490320690}
+  - component: {fileID: 4998747912282688621}
+  - component: {fileID: 2991529157538614571}
+  m_Layer: 0
+  m_Name: Camera
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 0
+--- !u!4 &4137215948490320690
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1782485218948418575}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 8934048990737965464}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!20 &4998747912282688621
+Camera:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1782485218948418575}
+  m_Enabled: 1
+  serializedVersion: 2
+  m_ClearFlags: 3
+  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
+  m_projectionMatrixMode: 1
+  m_GateFitMode: 2
+  m_FOVAxisMode: 0
+  m_SensorSize: {x: 36, y: 24}
+  m_LensShift: {x: 0, y: 0}
+  m_FocalLength: 50
+  m_NormalizedViewPortRect:
+    serializedVersion: 2
+    x: 0
+    y: 0
+    width: 1
+    height: 1
+  near clip plane: -1
+  far clip plane: 1000
+  field of view: 60
+  orthographic: 1
+  orthographic size: 9.6
+  m_Depth: 0
+  m_CullingMask:
+    serializedVersion: 2
+    m_Bits: 23
+  m_RenderingPath: -1
+  m_TargetTexture: {fileID: 0}
+  m_TargetDisplay: 0
+  m_TargetEye: 0
+  m_HDR: 1
+  m_AllowMSAA: 0
+  m_AllowDynamicResolution: 0
+  m_ForceIntoRT: 0
+  m_OcclusionCulling: 0
+  m_StereoConvergence: 10
+  m_StereoSeparation: 0.022
+--- !u!114 &2991529157538614571
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1782485218948418575}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 03a74e9be952781499f1c48566c89209, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1 &8934048990737965465
 GameObject:
   m_ObjectHideFlags: 0
@@ -28,6 +115,7 @@ Transform:
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
   - {fileID: 8934048988926551774}
+  - {fileID: 4137215948490320690}
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

二進制
GameClient/Assets/ResIn/UI/Main/Main_fui.bytes


+ 1 - 1
GameClient/Assets/Scenes/GameLauncher.unity

@@ -354,7 +354,7 @@ Camera:
   m_Depth: -1
   m_CullingMask:
     serializedVersion: 2
-    m_Bits: 23
+    m_Bits: 87
   m_RenderingPath: -1
   m_TargetTexture: {fileID: 0}
   m_TargetDisplay: 0

+ 1 - 1
GameClient/ProjectSettings/TagManager.asset

@@ -11,7 +11,7 @@ TagManager:
   - 
   - Water
   - UI
-  - 
+  - Bg
   - 
   - 
   -