Browse Source

未编辑时禁止拖动,

蓝色星空 1 year ago
parent
commit
a2109d5f82

+ 16 - 0
Assets/Resources/Template/Prefab/Image.prefab

@@ -13,6 +13,7 @@ GameObject:
   - component: {fileID: 7223857886156994697}
   - component: {fileID: 415156925351255577}
   - component: {fileID: 8376925436645686227}
+  - component: {fileID: 7706840194356506355}
   m_Layer: 0
   m_Name: Image
   m_TagString: Untagged
@@ -154,6 +155,21 @@ MonoBehaviour:
   canTwoHandScale: 0
   minScaleRatio: 0.5
   maxScaleRatio: 3
+--- !u!114 &7706840194356506355
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 227738178650662433}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: f2c924915f6be274b8af2986784ee2c1, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  boundingBox: {fileID: 7223857886156994697}
+  manipulationHandler: {fileID: 8376925436645686227}
+  obj_BoundingBox: {fileID: 0}
 --- !u!1 &5709561373420343274
 GameObject:
   m_ObjectHideFlags: 0

+ 13 - 0
Assets/Scripts/Blue/Patch/PosRotScale.cs

@@ -0,0 +1,13 @@
+using UnityEngine;
+using System.Collections.Generic;
+
+public static class PosRotScale
+{
+    public static List<PosRotScalePatch> PosRotScalePatchList = new List<PosRotScalePatch>();
+}
+public class PosRotScalePatch
+{
+    public Vector3 PosPatch;
+    public Vector3 RotPatch;
+    public Vector3 ScalePatch;
+}

+ 11 - 0
Assets/Scripts/Blue/Patch/PosRotScale.cs.meta

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

+ 40 - 18
Assets/Scripts/Blue/Patch/Video/Patch_VideoController.cs

@@ -1,8 +1,8 @@
 using System.Collections;
-using System.Collections.Generic;
 using Blue;
 using SC.XR.Unity.Module_InputSystem;
 using UnityEngine;
+using UnityEngine.UI;
 
 public class Patch_VideoController : AbstractController
 {
@@ -11,35 +11,57 @@ public class Patch_VideoController : AbstractController
     [SerializeField] private GameObject obj_BoundingBox;
     void Start()
     {
+        if (GetComponent<ManipulationHandler>() != null)
+        {
+            Destroy(manipulationHandler);
+        }
+        /*
         this.RegisterEvent<Patch_VideoEvent>(e=>
         {
             if(e.set)
             {
-                if(obj_BoundingBox!=null)
-                {
-                    obj_BoundingBox.SetActive(true);
-                    manipulationHandler.enabled = true;
-                }
-                else
-                {
-                    boundingBox.enabled = true;
-                    manipulationHandler.enabled = true;
-                    StartCoroutine(GetBoundingBox());
-                }
+                manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
+                //Debug.LogError("manipulationHandler:"+manipulationHandler==null);
+                boundingBox.enabled = true;
+                manipulationHandler.enabled = true;
             }
             else
             {
-                obj_BoundingBox.SetActive(false);
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
                 boundingBox.enabled = false;
-                manipulationHandler.enabled = false;
+                Destroy(manipulationHandler);
             }
         });
+        */
+        toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
     }
 
-    private IEnumerator GetBoundingBox()
+    private Toggle toggle;
+    private bool des;
+    private void Update()
     {
-        yield return null;
-        if(transform.Find("BoundingBox").gameObject!=null)
-            obj_BoundingBox = transform.Find("BoundingBox").gameObject;
+        if(!toggle.isOn)
+        {
+            if(des)
+            {
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
+                boundingBox.enabled = false;
+                Destroy(manipulationHandler);
+                des = false;
+            }
+        }
+        else
+        {
+            if(!des)
+            {
+                manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
+                //Debug.LogError("manipulationHandler:"+manipulationHandler==null);
+                boundingBox.enabled = true;
+                manipulationHandler.enabled = true;
+                des = true;
+            }
+        }
     }
 }

+ 19 - 0
Assets/Scripts/UI/EdirPanel/UIEditorPanel.cs

@@ -320,6 +320,25 @@ public class UIEditorPanel : AbstractController, EventObserver
                 InstantiateSystem.Instance.BlueObject.WarningPopUp,
                 InstantiateSystem.Instance.BlueObject.SuccessText);
         CommandSystem.Instance.Send(Command);
+
+        PosRotScale.PosRotScalePatchList.Clear();
+        for (int i = 0; i < GameManager.Instance.ObjsParent.childCount;i++)
+        {
+            if (i != 0)
+            {
+                for (int j = 0; j < GameManager.Instance.ObjsParent.GetChild(i).childCount; j++)
+                {
+                    for (int k = 0; k < GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).childCount; k++)
+                    {
+                        PosRotScalePatch PosRotScalePatch = new PosRotScalePatch();
+                        PosRotScalePatch.PosPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
+                        PosRotScalePatch.RotPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
+                        PosRotScalePatch.ScalePatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
+                        PosRotScale.PosRotScalePatchList.Add(PosRotScalePatch);
+                    }
+                }
+            }
+        }
     }
 
     /// <summary>