Browse Source

camera default postion

Виктор Шейко 4 years ago
parent
commit
5c9311c4be

File diff suppressed because it is too large
+ 1 - 0
Assets/Resources/Image/Icons/control_camera-24px.svg


+ 55 - 0
Assets/Resources/Image/Icons/control_camera-24px.svg.meta

@@ -0,0 +1,55 @@
+fileFormatVersion: 2
+guid: 723cf9e542843a7419a5cf41be875cee
+ScriptedImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 2
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
+  script: {fileID: 11500000, guid: a57477913897c46af95d590f580878bd, type: 3}
+  svgType: 4
+  texturedSpriteMeshType: 0
+  svgPixelsPerUnit: 100
+  gradientResolution: 64
+  alignment: 0
+  customPivot: {x: 0, y: 0}
+  generatePhysicsShape: 0
+  viewportOptions: 1
+  preserveViewport: 0
+  advancedMode: 0
+  predefinedResolutionIndex: 1
+  targetResolution: 1080
+  resolutionMultiplier: 1
+  stepDistance: 10
+  samplingStepDistance: 100
+  maxCordDeviationEnabled: 0
+  maxCordDeviation: 1
+  maxTangentAngleEnabled: 0
+  maxTangentAngle: 5
+  keepTextureAspectRatio: 1
+  textureSize: 256
+  textureWidth: 256
+  textureHeight: 256
+  wrapMode: 0
+  filterMode: 1
+  sampleCount: 4
+  preserveSVGImageAspect: 0
+  useSVGPixelsPerUnit: 0
+  spriteData:
+    TessellationDetail: 0
+    SpriteRect:
+      name: 
+      originalName: 
+      pivot: {x: 0, y: 0}
+      alignment: 0
+      border: {x: 0, y: 0, z: 0, w: 0}
+      rect:
+        serializedVersion: 2
+        x: 0
+        y: 0
+        width: 0
+        height: 0
+      spriteID: cec36e3619ba9cf4e8209940c9bff356
+      internalID: 0
+    PhysicsOutlines: []

File diff suppressed because it is too large
+ 1 - 0
Assets/Resources/Image/Icons/filter_center_focus-24px.svg


+ 55 - 0
Assets/Resources/Image/Icons/filter_center_focus-24px.svg.meta

@@ -0,0 +1,55 @@
+fileFormatVersion: 2
+guid: 113337af786c0854e835a5c6a5b3d9fb
+ScriptedImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 2
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
+  script: {fileID: 11500000, guid: a57477913897c46af95d590f580878bd, type: 3}
+  svgType: 0
+  texturedSpriteMeshType: 0
+  svgPixelsPerUnit: 100
+  gradientResolution: 64
+  alignment: 0
+  customPivot: {x: 0, y: 0}
+  generatePhysicsShape: 0
+  viewportOptions: 0
+  preserveViewport: 0
+  advancedMode: 0
+  predefinedResolutionIndex: 1
+  targetResolution: 1080
+  resolutionMultiplier: 1
+  stepDistance: 10
+  samplingStepDistance: 100
+  maxCordDeviationEnabled: 0
+  maxCordDeviation: 1
+  maxTangentAngleEnabled: 0
+  maxTangentAngle: 5
+  keepTextureAspectRatio: 1
+  textureSize: 256
+  textureWidth: 256
+  textureHeight: 256
+  wrapMode: 0
+  filterMode: 1
+  sampleCount: 4
+  preserveSVGImageAspect: 0
+  useSVGPixelsPerUnit: 0
+  spriteData:
+    TessellationDetail: 0
+    SpriteRect:
+      name: 
+      originalName: 
+      pivot: {x: 0, y: 0}
+      alignment: 0
+      border: {x: 0, y: 0, z: 0, w: 0}
+      rect:
+        serializedVersion: 2
+        x: 0
+        y: 0
+        width: 0
+        height: 0
+      spriteID: d5479a18ab7ef2241892ba84cc5a4de0
+      internalID: 0
+    PhysicsOutlines: []

+ 10 - 10
Assets/Scenes/Player.unity

@@ -17604,9 +17604,9 @@ RectTransform:
   m_Father: {fileID: 995816063}
   m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 104, y: -330}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 104, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &765671128
@@ -23242,9 +23242,9 @@ RectTransform:
   m_Father: {fileID: 100471033}
   m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 105, y: 29}
+  m_AnchoredPosition: {x: 105, y: -288}
   m_SizeDelta: {x: 208, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &995816064
@@ -29284,9 +29284,9 @@ RectTransform:
   m_Father: {fileID: 100471033}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 105, y: 51}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 105, y: -556}
   m_SizeDelta: {x: 208, y: 102}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1259139725
@@ -34027,7 +34027,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0, y: -0.00000018572389}
+  m_AnchoredPosition: {x: 0, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
 --- !u!1 &1442051382
@@ -38197,7 +38197,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 104, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1605365115

+ 39 - 0
Assets/Scripts/Controllers/CameraController.cs

@@ -1,8 +1,10 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 using UnityEngine.EventSystems;
+using UnityEngine.UI;
 
 /// <summary>
 /// Отслеживание объекта
@@ -14,11 +16,13 @@ public class CameraController : MonoBehaviour
     public float movementSpeed = 0.1f;
     public int mouseSpeed = 100;
     public float smoothness = 0.85f;
+    public Button ButtonCameraCenter;
 
     Vector3 targetPosition;
     private Vector3 dragOrigin;
 
     public Transform target;
+    public GameObject location;
     
     void Start()
     {      
@@ -27,6 +31,8 @@ public class CameraController : MonoBehaviour
 
         yaw = transform.eulerAngles.y;
         pitch = transform.eulerAngles.x;
+
+        ButtonCameraCenter.onClick.AddListener(CameraCenter);
     }
 
     void Update()
@@ -202,4 +208,37 @@ public class CameraController : MonoBehaviour
             transform.Translate(0, dragKeySpeed, 0);
 
     }
+
+    public void CameraCenter()
+    {
+        if (location != null)
+        {
+            var pos = location.transform.position;
+            var scale = location.transform.localScale;
+
+            //float distance = Mathf.Max(pos.x, pos.y, pos.z);
+            //distance /= Mathf.Tan(0.5f * GetComponent<Camera>().fieldOfView * Mathf.Deg2Rad);
+            //// Move camera in -z-direction; change '2.0f' to your needs
+           
+            transform.position = new Vector3(pos.x - scale.x / 2, transform.position.y, pos.z - scale.z / 2);
+
+            //if(Screen.width > Screen.height)
+            //transform.position = new Vector3(Mathf.Clamp(transform.position.x, Screen.width / 2, Screen.width / 2), transform.position.y, transform.position.z);
+            //transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, location.transform.position.z, Screen.height / 2));
+            //Vector3 centerPos = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, -Vector3.Distance(location.transform.position, Camera.main.nearClipPlane)));
+            //transform.position = centerPos;
+            //transform.localScale = initialScale * dist * objectScale;
+
+            //transform.position = new Vector3(pos.x - scale.x/2, 12, pos.z - scale.z / 2);
+        }
+        else
+            transform.position = new Vector3(5, 12, 5);
+        transform.rotation = Quaternion.Euler(90, 0, 0);
+
+        targetPosition = transform.position;
+        yaw = transform.eulerAngles.y;
+        pitch = transform.eulerAngles.x;
+    }
+
+    
 }

+ 1 - 0
Assets/Scripts/Models/Location.cs

@@ -156,6 +156,7 @@ public class Location
                     var lz = lzs.ZoneInfos[z.id];
                     lz.gameObject.SetActive(active);
                 }
+        if (active) Camera.main.GetComponent<CameraController>().location = plane;
     }
 }
 

+ 3 - 2
Assets/Scripts/Models/User.cs

@@ -17,7 +17,8 @@ public class User
     public GameObject marker { get; set; }
     public LineRenderer marker_line { get; set; }
     //public uint acc_id { get; set; }
-    public bool starting { get; set; }
+    //public bool starting { get; set; }
+    public bool broadcast { get; set; }
 
 
     public static void UsersReceive(byte[] bytedata)
@@ -132,5 +133,5 @@ public class User
         toggle_user.transform.SetParent(WorkersList.transform);
         var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
         camera_button.onClick.AddListener(() => BroadcastStart(id));
-    }
+    }    
 }