1
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1185038087929456
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4672307179458510}
|
||||
- component: {fileID: 20604241696856574}
|
||||
- component: {fileID: 124262863553394556}
|
||||
- component: {fileID: 81181633540223728}
|
||||
- component: {fileID: 114916208249967746}
|
||||
- component: {fileID: 1349245266}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4672307179458510
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 4.095389, y: 18.9, z: -206.8}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &20604241696856574
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: 3
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!124 &124262863553394556
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_Enabled: 1
|
||||
--- !u!81 &81181633540223728
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_Enabled: 1
|
||||
--- !u!114 &114916208249967746
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6a6143841ffb47f4ea83574c618ca3e2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
data: {fileID: 11400000, guid: 5ec9fac7c7c3ee643a288d1340aafa17, type: 2}
|
||||
--- !u!114 &1349245266
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1185038087929456}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e83c49ade708374995107d7992d0c66, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
interval: 0.25
|
||||
displayType: 0
|
||||
gradientRange: {x: 15, y: 60}
|
||||
fontRun: {fileID: 0}
|
||||
fontResult: {fileID: 0}
|
||||
logo: {fileID: 0}
|
||||
showLogoOnResultsScreen: 1
|
||||
showHideButton: 8
|
||||
acceptInput: 1
|
||||
reset: 0
|
||||
currentFPS: 0
|
||||
averageFPS: 0
|
||||
minimumFPS: 999.9
|
||||
maximumFPS: 0
|
@@ -0,0 +1,125 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
public class NavigationCamera : MonoBehaviour
|
||||
{
|
||||
public static float fov;
|
||||
public SO_NavigationCamera data;
|
||||
|
||||
Quaternion rot;
|
||||
Vector3 currentSpeed;
|
||||
float tStamp;
|
||||
float deltaTime;
|
||||
|
||||
Vector3 startPosition, position;
|
||||
Quaternion startRotation;
|
||||
float scrollWheel;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
tStamp = Time.realtimeSinceStartup;
|
||||
|
||||
startPosition = position = transform.position;
|
||||
startRotation = rot = transform.rotation;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
RestoreCam();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
scrollWheel = Input.mouseScrollDelta.y * data.mouseScrollWheelMulti;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
deltaTime = Time.realtimeSinceStartup - tStamp;
|
||||
tStamp = Time.realtimeSinceStartup;
|
||||
|
||||
Vector2 deltaMouse = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
|
||||
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
rot = transform.rotation;
|
||||
deltaMouse = Vector2.zero;
|
||||
}
|
||||
|
||||
Vector3 speed = Vector3.zero;
|
||||
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
// rot *= Quaternion.Euler(new Vector3(-deltaMouse.y * data.mouseSensitity * deltaTime * 100, deltaMouse.x * data.mouseSensitity * deltaTime * 100, 0));
|
||||
|
||||
Quaternion oldRot = transform.rotation;
|
||||
transform.Rotate(0, deltaMouse.x * data.mouseSensitity * 1.66f, 0, Space.World);
|
||||
transform.Rotate(-deltaMouse.y * data.mouseSensitity * 1.66f, 0, 0, Space.Self);
|
||||
rot = transform.rotation;
|
||||
transform.rotation = oldRot;
|
||||
|
||||
if (Input.GetKey(KeyCode.W)) speed.z = 1;
|
||||
else if (Input.GetKey(KeyCode.S)) speed.z = -1;
|
||||
|
||||
if (Input.GetKey(KeyCode.D)) speed.x = 1;
|
||||
else if (Input.GetKey(KeyCode.A)) speed.x = -1;
|
||||
|
||||
if (Input.GetKey(KeyCode.E)) speed.y = 1;
|
||||
else if (Input.GetKey(KeyCode.Q)) speed.y = -1;
|
||||
|
||||
speed *= GetSpeedMulti();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(2))
|
||||
{
|
||||
speed.x = -deltaMouse.x;
|
||||
speed.y = -deltaMouse.y;
|
||||
|
||||
speed *= GetSpeedMulti();
|
||||
currentSpeed = speed;
|
||||
}
|
||||
else Lerp2Way(ref currentSpeed, speed, data.speedUpLerpMulti, data.speedDownLerpMulti);
|
||||
|
||||
position += transform.TransformDirection(currentSpeed * deltaTime) + (transform.forward * scrollWheel * deltaTime);
|
||||
|
||||
transform.rotation = rot;
|
||||
transform.position = position;
|
||||
}
|
||||
|
||||
public void SetCam()
|
||||
{
|
||||
transform.rotation = rot;
|
||||
transform.position = position;
|
||||
}
|
||||
|
||||
public void RestoreCam()
|
||||
{
|
||||
transform.position = startPosition;
|
||||
transform.rotation = startRotation;
|
||||
}
|
||||
|
||||
float GetSpeedMulti()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift)) return data.speedFast;
|
||||
if (Input.GetKey(KeyCode.LeftControl)) return data.speedSlow;
|
||||
else return data.speedNormal;
|
||||
}
|
||||
|
||||
void Lerp2Way(ref Vector3 v, Vector3 targetV, float upMulti, float downMulti)
|
||||
{
|
||||
Lerp2Way(ref v.x, targetV.x, upMulti, downMulti);
|
||||
Lerp2Way(ref v.y, targetV.y, upMulti, downMulti);
|
||||
Lerp2Way(ref v.z, targetV.z, upMulti, downMulti);
|
||||
}
|
||||
|
||||
void Lerp2Way(ref float v, float targetV, float upMulti, float downMulti)
|
||||
{
|
||||
float multi;
|
||||
if (Mathf.Abs(v) < Mathf.Abs(targetV)) multi = upMulti; else multi = downMulti;
|
||||
v = Mathf.Lerp(v, targetV, multi * deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7ce3a8e19ca99214f81249b8a740c439, type: 3}
|
||||
m_Name: NavigationCamera_Data
|
||||
m_EditorClassIdentifier:
|
||||
mouseSensitity: 1
|
||||
speedUpLerpMulti: 1
|
||||
speedDownLerpMulti: 15
|
||||
speedSlow: 1
|
||||
speedNormal: 10
|
||||
speedFast: 100
|
||||
mouseScrollWheelMulti: 100
|
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshCombineStudio
|
||||
{
|
||||
// [CreateAssetMenu(fileName = "NavigationCamera_Data", menuName = "ScriptableObjects/MeshCombineStudio/NavigationCamera_Data", order = 1)]
|
||||
public class SO_NavigationCamera : ScriptableObject
|
||||
{
|
||||
public float mouseSensitity = 1;
|
||||
|
||||
public float speedUpLerpMulti = 1;
|
||||
public float speedDownLerpMulti = 15;
|
||||
public float speedSlow = 1;
|
||||
public float speedNormal = 10;
|
||||
public float speedFast = 25;
|
||||
public float mouseScrollWheelMulti = 25;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user