Переглянути джерело

Remove subcamera and change drag point layer

Subcamera was only used to render objects on the NGUI Layer (8), which
only the drag points and NGUI stuff reside.

This fixes drag points position being distorted when the main
camera's FOV changes.

This also prevents NGUI things from showing up in the world.
habeebweeb 3 роки тому
батько
коміт
a7cf20ec73

+ 2 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPoint.cs

@@ -6,6 +6,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     using static CustomGizmo;
     public abstract class DragPoint : MonoBehaviour
     {
+        private static readonly int layer = (int) Mathf.Log(LayerMask.GetMask("AbsolutFront"), 2);
         public const float defaultAlpha = 0.75f;
         private static GameObject dragPointParent;
         private const float doubleClickSensitivity = 0.3f;
@@ -128,7 +129,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GameObject dragPointGo = GameObject.CreatePrimitive(primitiveType);
             dragPointGo.transform.SetParent(DragPointParent().transform, false);
             dragPointGo.transform.localScale = scale;
-            dragPointGo.layer = 8;
+            dragPointGo.layer = layer;
 
             T dragPoint = dragPointGo.AddComponent<T>();
             dragPoint.renderer.material = dragPointMaterial;

+ 0 - 16
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/CameraManager.cs

@@ -1,6 +1,5 @@
 using System;
 using UnityEngine;
-using Object = UnityEngine.Object;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
@@ -11,8 +10,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public const string header = "CAMERA";
         private static readonly CameraMain mainCamera = CameraUtility.MainCamera;
         private static readonly UltimateOrbitCamera ultimateOrbitCamera = CameraUtility.UOCamera;
-        private GameObject cameraObject;
-        private Camera subCamera;
         private float defaultCameraMoveSpeed;
         private float defaultCameraZoomSpeed;
         private const float cameraFastMoveSpeed = 0.1f;
@@ -52,16 +49,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Activate()
         {
-            cameraObject = new GameObject("subCamera");
-            subCamera = cameraObject.AddComponent<Camera>();
-            subCamera.CopyFrom(mainCamera.camera);
-            subCamera.clearFlags = CameraClearFlags.Depth;
-            subCamera.cullingMask = 256;
-            subCamera.depth = 1f;
-            subCamera.transform.parent = mainCamera.transform;
-
-            cameraObject.SetActive(true);
-
             ultimateOrbitCamera.enabled = true;
 
             defaultCameraMoveSpeed = ultimateOrbitCamera.moveSpeed;
@@ -78,9 +65,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Deactivate()
         {
-            Object.Destroy(cameraObject);
-            Object.Destroy(subCamera);
-
             mainCamera.camera.backgroundColor = Color.black;
 
             ultimateOrbitCamera.moveSpeed = defaultCameraMoveSpeed;