Forráskód Böngészése

Consolidate making dragpoint and adding component

habeebweeb 4 éve
szülő
commit
2e8d997ccf

+ 1 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MPSLight.cs

@@ -132,11 +132,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             this.light.transform.position = LightProperty.DefaultPosition;
             this.light.transform.rotation = LightProperty.DefaultRotation;
 
-            GameObject dragPoint = BaseDrag.MakeDragPoint(
+            DragLight = BaseDrag.MakeDragPoint<DragDogu>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
             );
-
-            DragLight = dragPoint.AddComponent<DragDogu>();
             DragLight.Initialize(this.light.gameObject, this.IsMain, CustomGizmo.GizmoMode.World,
                 () => this.light.transform.position,
                 () => this.light.transform.eulerAngles

+ 1 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -71,11 +71,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             bgObject = GameObject.Find("__GameMain__/BG");
             bg = bgObject.transform;
 
-            GameObject dragPoint = BaseDrag.MakeDragPoint(
+            bgDragPoint = BaseDrag.MakeDragPoint<DragDogu>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
             );
-
-            bgDragPoint = dragPoint.AddComponent<DragDogu>();
             bgDragPoint.Initialize(bgObject, true);
             bgDragPoint.SetDragProp(false, false, false);
 

+ 1 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -276,11 +276,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
                 finalDogu.transform.position = doguPosition;
 
-                GameObject dragPoint = BaseDrag.MakeDragPoint(
+                DragDogu dragDogu = BaseDrag.MakeDragPoint<DragDogu>(
                     PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
                 );
-
-                DragDogu dragDogu = dragPoint.AddComponent<DragDogu>();
                 dragDogu.Initialize(finalDogu);
                 dragDogu.Delete += DeleteDogu;
                 dragDogu.SetDragProp(showGizmos, false, false);

+ 8 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/BaseDrag.cs

@@ -139,6 +139,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             return dragPoint;
         }
 
+        public static T MakeDragPoint<T>(
+            PrimitiveType primitiveType, Vector3 scale, Material material
+        ) where T : BaseDrag
+        {
+            GameObject dragPoint = MakeDragPoint(primitiveType, scale, material);
+            return dragPoint.AddComponent<T>();
+        }
+
         public BaseDrag Initialize(Meido meido, Func<Vector3> position, Func<Vector3> rotation)
         {
             this.InitializeDragPoint(position, rotation);