This commit is contained in:
Даниил Заикин
2026-06-17 20:44:53 +03:00
parent 9d153773c2
commit b133e7c656
1880 changed files with 244545 additions and 0 deletions
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1894414b42fe5e343b181b818b714b55
folderAsset: yes
timeCreated: 1552910252
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 878e70decc5254841b8310d665bf6844
timeCreated: 1556081593
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 140739
packageName: Free Fly Camera
packageVersion: 1.2
assetPath: Assets/FreeFlyCamera/Documentation/FreeFlyCamera_ru.pdf
uploadId: 396755
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: eeaac17fd74c9fb4592e12afe1203aab
folderAsset: yes
timeCreated: 1549511058
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,218 @@
//===========================================================================//
// FreeFlyCamera (Version 1.2) //
// (c) 2019 Sergey Stafeyev //
//===========================================================================//
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class FreeFlyCamera : MonoBehaviour
{
#region UI
[Space]
[SerializeField]
[Tooltip("The script is currently active")]
private bool _active = true;
[Space]
[SerializeField]
[Tooltip("Camera rotation by mouse movement is active")]
private bool _enableRotation = true;
[SerializeField]
[Tooltip("Sensitivity of mouse rotation")]
private float _mouseSense = 1.8f;
[Space]
[SerializeField]
[Tooltip("Camera zooming in/out by 'Mouse Scroll Wheel' is active")]
private bool _enableTranslation = true;
[SerializeField]
[Tooltip("Velocity of camera zooming in/out")]
private float _translationSpeed = 55f;
[Space]
[SerializeField]
[Tooltip("Camera movement by 'W','A','S','D','Q','E' keys is active")]
private bool _enableMovement = true;
[SerializeField]
[Tooltip("Camera movement speed")]
private float _movementSpeed = 10f;
[SerializeField]
[Tooltip("Speed of the quick camera movement when holding the 'Left Shift' key")]
private float _boostedSpeed = 50f;
[SerializeField]
[Tooltip("Boost speed")]
private KeyCode _boostSpeed = KeyCode.LeftShift;
[SerializeField]
[Tooltip("Move up")]
private KeyCode _moveUp = KeyCode.E;
[SerializeField]
[Tooltip("Move down")]
private KeyCode _moveDown = KeyCode.Q;
[Space]
[SerializeField]
[Tooltip("Acceleration at camera movement is active")]
private bool _enableSpeedAcceleration = true;
[SerializeField]
[Tooltip("Rate which is applied during camera movement")]
private float _speedAccelerationFactor = 1.5f;
[Space]
[SerializeField]
[Tooltip("This keypress will move the camera to initialization position")]
private KeyCode _initPositonButton = KeyCode.R;
#endregion UI
private CursorLockMode _wantedMode;
private float _currentIncrease = 1;
private float _currentIncreaseMem = 0;
private Vector3 _initPosition;
private Vector3 _initRotation;
#if UNITY_EDITOR
private void OnValidate()
{
if (_boostedSpeed < _movementSpeed)
_boostedSpeed = _movementSpeed;
}
#endif
private void Start()
{
_initPosition = transform.position;
_initRotation = transform.eulerAngles;
}
private void OnEnable()
{
if (_active)
_wantedMode = CursorLockMode.Locked;
}
// Apply requested cursor state
private void SetCursorState()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.lockState = _wantedMode = CursorLockMode.None;
}
if (Input.GetMouseButtonDown(0))
{
_wantedMode = CursorLockMode.Locked;
}
// Apply cursor state
Cursor.lockState = _wantedMode;
// Hide cursor when locking
Cursor.visible = (CursorLockMode.Locked != _wantedMode);
}
private void CalculateCurrentIncrease(bool moving)
{
_currentIncrease = Time.deltaTime;
if (!_enableSpeedAcceleration || _enableSpeedAcceleration && !moving)
{
_currentIncreaseMem = 0;
return;
}
_currentIncreaseMem += Time.deltaTime * (_speedAccelerationFactor - 1);
_currentIncrease = Time.deltaTime + Mathf.Pow(_currentIncreaseMem, 3) * Time.deltaTime;
}
private void Update()
{
if (!_active)
return;
SetCursorState();
if (Cursor.visible)
return;
// Translation
if (_enableTranslation)
{
transform.Translate(Vector3.forward * Input.mouseScrollDelta.y * Time.deltaTime * _translationSpeed);
}
// Movement
if (_enableMovement)
{
Vector3 deltaPosition = Vector3.zero;
float currentSpeed = _movementSpeed;
if (Input.GetKey(_boostSpeed))
currentSpeed = _boostedSpeed;
if (Input.GetKey(KeyCode.W))
deltaPosition += transform.forward;
if (Input.GetKey(KeyCode.S))
deltaPosition -= transform.forward;
if (Input.GetKey(KeyCode.A))
deltaPosition -= transform.right;
if (Input.GetKey(KeyCode.D))
deltaPosition += transform.right;
if (Input.GetKey(_moveUp))
deltaPosition += transform.up;
if (Input.GetKey(_moveDown))
deltaPosition -= transform.up;
// Calc acceleration
CalculateCurrentIncrease(deltaPosition != Vector3.zero);
transform.position += deltaPosition * currentSpeed * _currentIncrease;
}
// Rotation
if (_enableRotation)
{
// Pitch
transform.rotation *= Quaternion.AngleAxis(
-Input.GetAxis("Mouse Y") * _mouseSense,
Vector3.right
);
// Paw
transform.rotation = Quaternion.Euler(
transform.eulerAngles.x,
transform.eulerAngles.y + Input.GetAxis("Mouse X") * _mouseSense,
transform.eulerAngles.z
);
}
// Return to init position
if (Input.GetKeyDown(_initPositonButton))
{
transform.position = _initPosition;
transform.eulerAngles = _initRotation;
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 436275a13d4459746955fc6db5953473
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 140739
packageName: Free Fly Camera
packageVersion: 1.2
assetPath: Assets/FreeFlyCamera/Scripts/FreeFlyCamera.cs
uploadId: 396755
@@ -0,0 +1,24 @@
You are using asset FreeFlyCamera (Version 1.1)
It emulates control of the Scene editor camera in Play mode (in-game screen).
It is very convenient for quick scene adding and to use it for transition in it while staying in play mode. Load the asset and just drag the script to the main camera “FreeFlyCamera.cs” ready to use.
You can change parameters of rotation rate, movement, increase of transition speed, acceleration. You can activate/deactivate the rotation, transition, acceleration of movement speed.
If you have any questions or suggestions, you can send them to my email: sergeystafeyev@gmail.com.
--------------------------------------------------------
Вы используете ассет FreeFlyCamera (Версия 1.1)
Эмулирует управление камерой редактора сцены в режиме игры (на игровом экране).
Очень удобно быстро добавить на сцену, и использовать для перемещения по ней в игровом режиме. Загрузите ассет, и просто перетащите на основную камеру скрипт "FreeFlyCamera.cs" - готово к использованию.
Можно изменить параметры скорости вращения, перемещения, увеличения скорости перемещения, ускорения. Можно активировать/деактивировать вращение, перемещение, ускорение скорости движения.
Если у Вас есть какие-либо вопросы или предложения, можете отправить их на мой электронный адрес: sergeystafeyev@gmail.com.
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 4884ccef30647b541924654c47c779bb
timeCreated: 1556081593
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 140739
packageName: Free Fly Camera
packageVersion: 1.2
assetPath: Assets/FreeFlyCamera/readme.txt
uploadId: 396755