Browse Source

优化视频模型编辑模式

蓝色星空 1 year ago
parent
commit
2965e41379

+ 20 - 6
Assets/Scripts/Blue/Patch/Patch_ModelController.cs

@@ -1,11 +1,11 @@
-using System.Collections;
-using Blue;
 using SC.XR.Unity.Module_InputSystem;
 using UnityEngine;
 using UnityEngine.UI;
+using static BoundingBox;
 
 public class Patch_ModelController : AbstractController
 {
+    [SerializeField] private BoundingBox boundingBox;
     [SerializeField] private ManipulationHandler manipulationHandler;
     void Start()
     {
@@ -13,6 +13,12 @@ public class Patch_ModelController : AbstractController
         {
             Destroy(manipulationHandler);
         }
+
+        if (GetComponent<BoundingBox>() != null)
+        {
+            Destroy(boundingBox);
+        }
+
         toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
     }
 
@@ -24,16 +30,24 @@ public class Patch_ModelController : AbstractController
         {
             if(manipulationHandler!=null)
                 Destroy(manipulationHandler);
+            if (boundingBox != null)
+            {
+                Destroy(boundingBox);
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
+            }
         }
         else
         {
             if (manipulationHandler == null)
             {
                 manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
-                if(manipulationHandler.enabled==false)
-                {
-                    manipulationHandler.enabled = true;
-                }
+            }
+            if (boundingBox == null)
+            {
+                boundingBox = gameObject.AddComponent<BoundingBox>();
+                boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten;
+                boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
             }
         }
     }

+ 9 - 49
Assets/Scripts/Blue/Patch/Video/Patch_VideoController.cs

@@ -1,6 +1,3 @@
-using System.Collections.Generic;
-using System.Collections;
-using Blue;
 using SC.XR.Unity.Module_InputSystem;
 using UnityEngine;
 using UnityEngine.UI;
@@ -10,7 +7,7 @@ public class Patch_VideoController : AbstractController
 {
     [SerializeField] private BoundingBox boundingBox;
     [SerializeField] private ManipulationHandler manipulationHandler;
-    [SerializeField] private GameObject obj_BoundingBox;
+
     void Start()
     {
         if (GetComponent<ManipulationHandler>() != null)
@@ -22,26 +19,7 @@ public class Patch_VideoController : AbstractController
         {
             Destroy(boundingBox);
         }
-        
-        /*
-        this.RegisterEvent<Patch_VideoEvent>(e=>
-        {
-            if(e.set)
-            {
-                manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
-                //Debug.LogError("manipulationHandler:"+manipulationHandler==null);
-                boundingBox.enabled = true;
-                manipulationHandler.enabled = true;
-            }
-            else
-            {
-                if (transform.Find("BoundingBox").gameObject != null)
-                    Destroy(transform.Find("BoundingBox").gameObject);
-                boundingBox.enabled = false;
-                Destroy(manipulationHandler);
-            }
-        });
-        */
+
         toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
     }
 
@@ -50,45 +28,27 @@ public class Patch_VideoController : AbstractController
     {
         if(!toggle.isOn)
         {
-            if (transform.Find("BoundingBox").gameObject != null)
-                Destroy(transform.Find("BoundingBox").gameObject);
             if(manipulationHandler!=null)
                 Destroy(manipulationHandler);
-            if(boundingBox!=null)
+            if (boundingBox != null)
+            {
                 Destroy(boundingBox);
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
+            }
         }
         else
         {
             if (manipulationHandler == null)
             {
                 manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
-                if(manipulationHandler.enabled==false)
-                {
-                    manipulationHandler.enabled = true;
-                }
             }
             if (boundingBox == null)
             {
                 boundingBox = gameObject.AddComponent<BoundingBox>();
-                if(boundingBox.enabled==false)
-                {
-                    boundingBox.enabled = true;
-                    StartCoroutine(Set());
-                    Debug.LogError(boundingBox.ActiveHandle);
-                }
-                else
-                {
-                    boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
-                    boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
-                }
+                boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
+                boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
             }
         }
     }
-
-    private IEnumerator Set()
-    {
-        yield return null;
-        boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
-        boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
-    }
 }

+ 2 - 2
Assets/Scripts/LayoutTemplate/TemplateModel.cs

@@ -71,9 +71,9 @@ public class TemplateModel : BaseTemPlate
                 //if (ab.LoadAllAssets<GameObject>()[0].name == "MRVideo")
                 //m_ModelObj.AddComponent<MovieScreen>();
 
-                //gameObject.AddComponent<ManipulationHandler>();
-                gameObject.AddComponent<Patch_ModelController>();
+                gameObject.AddComponent<ManipulationHandler>();
                 gameObject.AddComponent<BoundingBox>();
+                gameObject.AddComponent<Patch_ModelController>();
                 yield return new WaitForSeconds(0.3f);
                 ab.Unload(false);
                 HideCollider();

+ 1 - 2
Assets/Scripts/UI/GameManager.cs

@@ -1314,8 +1314,7 @@ public class GameManager : MonoSingleton<GameManager>
                 SpoitIndex = i;
                 ListCrystals[SpoitIndex].gameObject.SetActive(false);
                 m_EditorPanel.SetSpoit(SpoitValues[i]);
-                if(!EditorToggle.isOn)
-                    StartCoroutine(patch());
+                StartCoroutine(patch());
                 return;
             }
         }