蓝色星空 1 سال پیش
والد
کامیت
ef32e07b7a

+ 47 - 5
Assets/Game/Blue/Controller/Item/ShowXunJian_UIItem.cs

@@ -5,6 +5,8 @@ using GHZLangChao;
 using SC.XR.Unity;
 using UnityEngine;
 using UnityEngine.UI;
+using System.Collections.Generic;
+using Google.Protobuf;
 
 public class ShowXunJian_UIItem : MonoBehaviour, IController
 {
@@ -22,9 +24,7 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
 
     [SerializeField] private GameObject mErrorBtn_go;
 
-    public Image Screenshot_0_Image;
-    public Image Screenshot_1_Image;
-    public Image Screenshot_2_Image;
+    private List<Image> ScreenshotList;
 
     private void Start()
     {
@@ -50,6 +50,40 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
     public void Set()
     {
         this.GetService<IInspectionService>().Set(mItemID, mNormal, mOutliers, mInspectionId, new string[3] { "1", "2", "3" });
+
+        foreach (var ByteClass in byteDic)
+        {
+            Debug.LogError($"是否上传:{ByteClass.Value.upload}");
+            if (ByteClass.Value.upload)
+            {
+                LangChaoMinIo.Instance.saveFile(ByteClass.Value.bytes,
+                                         this.GetService<IInspectionService>().InspectionInfo.id,
+                                         mItemID.ToString(),
+                                         ByteClass.Key,
+                                         msg =>
+                                         {
+                                             Debug.LogError("Set:" + msg);
+                                         });
+            }
+        }
+    }
+    class ByteClass
+    {
+        public bool upload;
+        public byte[] bytes;
+    }
+    Dictionary<int, ByteClass> byteDic = new Dictionary<int, ByteClass>();
+    public void ChangeSprite(int id, Texture2D Texture2D)
+    {
+        Debug.LogError($"ID:{id}");
+        if (byteDic.ContainsKey(id))
+        {
+            byteDic[id] = new ByteClass() { upload = true, bytes = Texture2D.EncodeToPNG() };
+        }
+        else
+        {
+            byteDic.Add(id, new ByteClass() { upload = true, bytes = Texture2D.EncodeToPNG() });
+        }
     }
 
     public void InitData(int ItemID, int InspectionId, InspectionStep InspectionStep = null)
@@ -68,10 +102,18 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
                 mOutliers = InspectionStep.outliers;
             }
 
-            foreach (var imageIndex in InspectionStep.images)
+            for (int i = 0; i < InspectionStep.images.Length; i++)
             {
-                LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id , mItemID.ToString(), imageIndex, Texture2D => 
+                Debug.LogError("getFile");
+                LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id, mItemID.ToString(), InspectionStep.images[i], Texture2D =>
                 {
+                    if (Texture2D != null)
+                    {
+                        byteDic.Add(i, new ByteClass() { upload = false, bytes = Texture2D.EncodeToPNG() });
+                        Sprite sprite = Sprite.Create(Texture2D, new Rect(0, 0, Texture2D.width, Texture2D.height), Vector2.zero);
+                        ScreenshotList[i].sprite = sprite;
+                        Destroy(Texture2D);
+                    }
                 });
             }
         }

+ 19 - 20
Assets/Game/Blue/Controller/LangChaoMinIo.cs

@@ -39,15 +39,6 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
         {
             if (minio == null)
             {
-                if (projectId != 0 && !isminioUpdate)
-                {
-                    isminioUpdate = true;
-                    initMinIo((bool b) =>
-                    {
-                        isminioUpdate = false;
-                    });
-
-                }
             }
             else
             {
@@ -106,7 +97,7 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
     }
 
     Queue<FileData> fdQueue = new Queue<FileData>();
-    void putFile(string filePath, string fileName, Action<bool> callBack)
+    void putFile(string filePath, string fileName, Action<string> callBack)
     {
         FileData fd = new FileData();
         fd.filePath = filePath;
@@ -115,20 +106,16 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
         fdQueue.Enqueue(fd);
     }
     string DicName = "XunJian";
-    public void saveFile(Texture tex, int projectId, string Index, int imgIndex, Action<bool> callBack)
+    public void saveFile(byte[] bytes, int projectId, string Index, int imgIndex, Action<string> callBack)
     {
         this.projectId = projectId;
-
-
-        Texture2D texture2D = TextureToTexture2D(tex);
-        byte[] bytes = texture2D.EncodeToPNG();
         if (!Directory.Exists(Application.persistentDataPath + "/" + DicName))
             Directory.CreateDirectory(Application.persistentDataPath + "/" + DicName);
 
         string fileName = DicName + "_" + projectId + "_" + Index + "_" + imgIndex + ".png";
         string filePathname = Application.persistentDataPath + "/" + DicName + "/" + fileName;
-        if (File.Exists(filePathname))
-            File.Delete(filePathname);
+      //  if (File.Exists(filePathname))
+      //      File.Delete(filePathname);
         File.WriteAllBytes(filePathname, bytes);
 
         PlayerPrefs.SetString(fileName, filePathname);
@@ -230,15 +217,15 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
             await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
             Debug.Log("33333333333333333");
             isUpdate = false;
+            Nowfd.callBack?.Invoke(Nowfd.fileName);
             Nowfd = null;
-            Nowfd.callBack?.Invoke(true);
         }
         catch
         {
 
+            Nowfd.callBack?.Invoke(null);
             isUpdate = false;
             Nowfd = null;
-            Nowfd.callBack?.Invoke(false);
         }
     }
     FileData Nowfd;
@@ -248,13 +235,25 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
         {
             Nowfd = fdQueue.Dequeue();
         }
+        if (minio == null)
+        {
+            if (projectId != 0 && !isminioUpdate)
+            {
+                isminioUpdate = true;
+                initMinIo((bool b) =>
+                {
+                    isminioUpdate = false;
+                });
+
+            }
+        }
     }
 
     public class FileData
     {
         public string filePath;
         public string fileName;
-        public Action<bool> callBack;
+        public Action<string> callBack;
     }
 
     public class GetFileData

+ 1 - 1
Assets/Game/Blue/RTC/Service/InspectionService.cs

@@ -50,7 +50,7 @@ public class InspectionService : IInspectionService
     /// <param name="Outliers">标签</param>
     /// <param name="InspectionId">巡检编号,巡检开始时返回的id</param>
     /// <param name="ImageIds">图片文件ID 最多三个</param>
-    public void Set(int ItemID, bool Normal, string Outliers, int InspectionId, string[] ImageIds)
+    public void Set(int ItemID, bool Normal, string Outliers, int InspectionId, int[] ImageIds)
     {
         InspectionStepSet mInspectionStepSet = new InspectionStepSet()
         {

+ 1 - 1
Assets/Game/Blue/RTC/Service/接口/IInspectionService.cs

@@ -14,5 +14,5 @@ public interface IInspectionService : IService
     /// <param name="Outliers">标签</param>
     /// <param name="InspectionId">巡检编号,巡检开始时返回的id</param>
     /// <param name="ImageIds">图片文件ID 最多三个</param>
-    void Set(int ItemID, bool Normal, string Label, int InspectionId, string[] ImageIds);
+    void Set(int ItemID, bool Normal, string Label, int InspectionId, int[] ImageIds);
 }

+ 3 - 2
Assets/Game/Blue/Utility/IRawImageForSpriteUtility.cs

@@ -11,6 +11,7 @@ namespace GHZLangChao
     public interface IRawImageForSpriteUtility : IUtility
     {
         Sprite SwitchSprite(RawImage rawImage);
+        Texture2D TextureToTexture2D(Texture texture);
         Sprite PngToSprite(string fullPath, int x, int y);
     }
 
@@ -18,7 +19,7 @@ namespace GHZLangChao
     {
         public Sprite SwitchSprite(RawImage rawImage)
         {
-            SaveLocal(rawImage, "1", "0");
+            //SaveLocal(rawImage, "1", "0");
 
             // 获取RawImage的纹理
             Texture2D rawTexture = TextureToTexture2D(rawImage.texture);
@@ -37,7 +38,7 @@ namespace GHZLangChao
         /// </summary>
         /// <param name="texture"></param>
         /// <returns></returns>
-        private Texture2D TextureToTexture2D(Texture texture)
+        public Texture2D TextureToTexture2D(Texture texture)
         {
             Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);
             RenderTexture currentRT = RenderTexture.active;

+ 3 - 81
Assets/Game/ShowXunJian/ShowXunJian.prefab

@@ -498,82 +498,6 @@ MonoBehaviour:
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
   m_PixelsPerUnitMultiplier: 1
---- !u!1 &340342561173978945
-GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 3671324079101866303}
-  - component: {fileID: 3161229054427595166}
-  - component: {fileID: 5898583298692863183}
-  m_Layer: 5
-  m_Name: bg
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 1
---- !u!224 &3671324079101866303
-RectTransform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 340342561173978945}
-  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_ConstrainProportionsScale: 0
-  m_Children: []
-  m_Father: {fileID: 1604557598583110365}
-  m_RootOrder: 2
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 0, y: 0}
-  m_Pivot: {x: 0.5, y: 0.5}
---- !u!222 &3161229054427595166
-CanvasRenderer:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 340342561173978945}
-  m_CullTransparentMesh: 1
---- !u!114 &5898583298692863183
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 340342561173978945}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 1}
-  m_RaycastTarget: 1
-  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
-  m_Maskable: 1
-  m_OnCullStateChanged:
-    m_PersistentCalls:
-      m_Calls: []
-  m_Sprite: {fileID: 21300000, guid: b6306d43fbcbb90428c13e7d8e4b69ab, type: 3}
-  m_Type: 0
-  m_PreserveAspect: 0
-  m_FillCenter: 1
-  m_FillMethod: 4
-  m_FillAmount: 1
-  m_FillClockwise: 1
-  m_FillOrigin: 0
-  m_UseSpriteMesh: 0
-  m_PixelsPerUnitMultiplier: 1
 --- !u!1 &354958024822014578
 GameObject:
   m_ObjectHideFlags: 0
@@ -683,7 +607,6 @@ RectTransform:
   m_Children:
   - {fileID: 8560100870857192279}
   - {fileID: 7557512296016039854}
-  - {fileID: 3671324079101866303}
   - {fileID: 6007970590168449410}
   - {fileID: 3435097039171749597}
   m_Father: {fileID: 4629186307896980025}
@@ -791,7 +714,7 @@ MonoBehaviour:
           m_StringArgument: 
           m_BoolArgument: 0
         m_CallState: 2
-      - m_Target: {fileID: 340342561173978945}
+      - m_Target: {fileID: 0}
         m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
         m_MethodName: SetActive
         m_Mode: 6
@@ -7057,7 +6980,7 @@ RectTransform:
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 1604557598583110365}
-  m_RootOrder: 3
+  m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
@@ -7345,7 +7268,6 @@ MonoBehaviour:
         m_CallState: 2
   currentUIItem: {fileID: 0}
   LastUIItem: {fileID: 0}
-  imageTest: {fileID: 731099477028635128}
   ItemNameTextList:
   - {fileID: 1108556361098302881}
   - {fileID: 5578992365418269874}
@@ -7943,7 +7865,7 @@ RectTransform:
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 1604557598583110365}
-  m_RootOrder: 4
+  m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 1, y: 1}
   m_AnchorMax: {x: 1, y: 1}

+ 9 - 7
Assets/Game/ShowXunJian/StartXunJian.cs

@@ -10,10 +10,10 @@ namespace GHZLangChao
     public class StartXunJian : AbstractController
     {
         public bool Test = false;
-        [SerializeField] private RawImage ShowRawImage; // 显示的视频画面
+        public RawImage ShowRawImage; // 显示的视频画面
         [SerializeField] private GameObject ShowRaw_go; // 显示的视频画面父物体
 
-        [SerializeField] private Image[] arrayImage; // 截图显示的画面
+        public Image[] arrayImage; // 截图显示的画面
         //[SerializeField] private Image ScreenshotImage; // 截图的画面
         private int arrayImageIndex = 0; // 截图显示时要显示在哪个Image上的下标
         [SerializeField] private Button[] ScreenshotBtnList;
@@ -37,11 +37,9 @@ namespace GHZLangChao
 
         public static StartXunJian Instance;
 
-        public Image imageTest;
         private void Awake()
         {
             Instance = this;
-            imageTest.sprite = this.GetUtility<IRawImageForSpriteUtility>().PngToSprite(Application.persistentDataPath+"/0.png",500,500);
         }
         void Start()
         {
@@ -105,7 +103,7 @@ namespace GHZLangChao
         {
             foreach (var item in InspectionInfo.items)
             {
-                ItemNameTextList[int.Parse(item.Key) - 1].text = item.Value.name + "接口";
+                ItemNameTextList[int.Parse(item.Key) - 1].text = item.Value.name;
                 ItemUIList[int.Parse(item.Key) - 1].text = item.Key + "、" + item.Value.question;
                 if (InspectionInfo.steps.ContainsKey(item.Key)) //是否执行到此步骤
                 {
@@ -126,7 +124,6 @@ namespace GHZLangChao
         }
 
         #region 按钮点击
-        [SerializeField] private Sprite mScreenshotSprite;
         private void ClickScreenshot()
         {
             if (!ShowRaw_go.activeSelf)
@@ -143,13 +140,18 @@ namespace GHZLangChao
             var sprite = this.GetUtility<IRawImageForSpriteUtility>().SwitchSprite(ShowRawImage);
             //ScreenshotImage.gameObject.SetActive(true);
             //ScreenshotImage.sprite = sprite;
-
+            sprite.name = arrayImageIndex.ToString();
             arrayImage[arrayImageIndex].sprite = sprite;
+
+            Debug.LogError("第几个:"+ arrayImageIndex / 3+"ID:"+ arrayImageIndex % 3);
+            ItemList[arrayImageIndex / 3].ChangeSprite(arrayImageIndex % 3, this.GetUtility<IRawImageForSpriteUtility>().TextureToTexture2D(ShowRawImage.texture));
+            
             arrayImageIndex++;
             if (arrayImageIndex % 3 == 0)
             {
                 arrayImageIndex -= 3;
             }
+
         }
         public void SetIndex(int index)
         {