浏览代码
- Added simple FreeCamera component to ScriptableRenderPipeline/common
- Added simple FreeCamera component to ScriptableRenderPipeline/common
- Added Beginning of small debugging framework to push messages and handle debug inputs. - Added CameraSwitcher helper to help to switch between different locations in the game./Branch_Batching2
Julien Ignace
8 年前
当前提交
686cfb59
共有 9 个文件被更改,包括 779 次插入 和 295 次删除
-
718ProjectSettings/InputManager.asset
-
9Assets/ScriptableRenderPipeline/common/Camera.meta
-
136Assets/ScriptableRenderPipeline/common/Debugging.cs
-
12Assets/ScriptableRenderPipeline/common/Debugging.cs.meta
-
108Assets/ScriptableRenderPipeline/common/Camera/CameraSwitcher.cs
-
12Assets/ScriptableRenderPipeline/common/Camera/CameraSwitcher.cs.meta
-
67Assets/ScriptableRenderPipeline/common/Camera/FreeCamera.cs
-
12Assets/ScriptableRenderPipeline/common/Camera/FreeCamera.cs.meta
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!13 &1 |
|||
InputManager: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 2 |
|||
m_Axes: |
|||
- serializedVersion: 3 |
|||
m_Name: Horizontal |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: left |
|||
positiveButton: right |
|||
altNegativeButton: a |
|||
altPositiveButton: d |
|||
gravity: 3 |
|||
dead: .00100000005 |
|||
sensitivity: 3 |
|||
snap: 1 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Vertical |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: down |
|||
positiveButton: up |
|||
altNegativeButton: s |
|||
altPositiveButton: w |
|||
gravity: 3 |
|||
dead: .00100000005 |
|||
sensitivity: 3 |
|||
snap: 1 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire1 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left ctrl |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 0 |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire2 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left alt |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 1 |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire3 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left shift |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 2 |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Jump |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: space |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse X |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: .100000001 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse Y |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: .100000001 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 1 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse ScrollWheel |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: .100000001 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 2 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Horizontal |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: .189999998 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 2 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Vertical |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: .189999998 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 1 |
|||
type: 2 |
|||
axis: 1 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire1 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 0 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire2 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 1 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire3 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 2 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Jump |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 3 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Submit |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: return |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 0 |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Submit |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: enter |
|||
altNegativeButton: |
|||
altPositiveButton: space |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Cancel |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: escape |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 1 |
|||
gravity: 1000 |
|||
dead: .00100000005 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!13 &1 |
|||
InputManager: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 2 |
|||
m_Axes: |
|||
- serializedVersion: 3 |
|||
m_Name: Horizontal |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: left |
|||
positiveButton: right |
|||
altNegativeButton: q |
|||
altPositiveButton: d |
|||
gravity: 3 |
|||
dead: 0.001 |
|||
sensitivity: 3 |
|||
snap: 1 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Vertical |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: down |
|||
positiveButton: up |
|||
altNegativeButton: s |
|||
altPositiveButton: z |
|||
gravity: 3 |
|||
dead: 0.001 |
|||
sensitivity: 3 |
|||
snap: 1 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire1 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left ctrl |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 0 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire2 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left alt |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 1 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire3 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: left shift |
|||
altNegativeButton: |
|||
altPositiveButton: mouse 2 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Jump |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: space |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse X |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: 0.1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Controller Right Stick X |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1 |
|||
dead: 0.2 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 2 |
|||
axis: 3 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse Y |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: 0.1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 1 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Controller Right Stick Y |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1 |
|||
dead: 0.2 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 1 |
|||
type: 2 |
|||
axis: 4 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Mouse ScrollWheel |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0 |
|||
sensitivity: 0.1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 1 |
|||
axis: 2 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Horizontal |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0.19 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 2 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Vertical |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 0 |
|||
dead: 0.19 |
|||
sensitivity: 1 |
|||
snap: 0 |
|||
invert: 1 |
|||
type: 2 |
|||
axis: 1 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire1 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 0 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire2 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 1 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Fire3 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 2 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Jump |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: joystick button 3 |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Submit |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: return |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 0 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Submit |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: enter |
|||
altNegativeButton: |
|||
altPositiveButton: space |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Cancel |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: escape |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 1 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Enable Debug Button 1 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: escape |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 8 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Enable Debug Button 2 |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: escape |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 9 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Debug Next |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: |
|||
altPositiveButton: joystick button 5 |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Debug Next |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: page down |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Debug Previous |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: |
|||
altNegativeButton: joystick button 4 |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|||
- serializedVersion: 3 |
|||
m_Name: Debug Previous |
|||
descriptiveName: |
|||
descriptiveNegativeName: |
|||
negativeButton: |
|||
positiveButton: page up |
|||
altNegativeButton: |
|||
altPositiveButton: |
|||
gravity: 1000 |
|||
dead: 0.001 |
|||
sensitivity: 1000 |
|||
snap: 0 |
|||
invert: 0 |
|||
type: 0 |
|||
axis: 0 |
|||
joyNum: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: e99921594db38ce4cbb616f0ca87148d |
|||
folderAsset: yes |
|||
timeCreated: 1488370960 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class Debugging : MonoBehaviour |
|||
{ |
|||
|
|||
private static bool m_DebugControlEnabled = false; |
|||
public static bool debugControlEnabled { get { return m_DebugControlEnabled; } } |
|||
|
|||
private float m_DebugControlEnabledMsgTime = 3.0f; |
|||
private float m_DebugControlEnabledMsgTimer = 0.0f; |
|||
|
|||
private bool m_DebugKeyUp1 = false; |
|||
private bool m_DebugKeyUp2 = false; |
|||
private bool m_CanReceiveInput = true; |
|||
|
|||
private static List<string> m_DebugMessages = new List<string>(); |
|||
|
|||
private static string kEnableDebugBtn1 = "Enable Debug Button 1"; |
|||
private static string kEnableDebugBtn2 = "Enable Debug Button 2"; |
|||
private string[] m_RequiredInputButtons = { kEnableDebugBtn1, kEnableDebugBtn2 }; |
|||
private bool m_Valid = true; |
|||
|
|||
public static void PushDebugMessage(string message) |
|||
{ |
|||
m_DebugMessages.Add(message); |
|||
} |
|||
|
|||
static public bool CheckRequiredInputButtonMapping(string[] values) |
|||
{ |
|||
bool inputsOk = true; |
|||
foreach(string value in values) |
|||
{ |
|||
try |
|||
{ |
|||
Input.GetButton(value); |
|||
} |
|||
catch |
|||
{ |
|||
Debug.LogWarning(string.Format("Required input button mapping missing: {0}.", value)); |
|||
inputsOk = false; |
|||
} |
|||
} |
|||
|
|||
return inputsOk; |
|||
} |
|||
|
|||
static public bool CheckRequiredInputAxisMapping(string[] values) |
|||
{ |
|||
bool inputsOk = true; |
|||
foreach (string value in values) |
|||
{ |
|||
try |
|||
{ |
|||
Input.GetAxis(value); |
|||
} |
|||
catch |
|||
{ |
|||
Debug.LogWarning(string.Format("Required input axis mapping missing: {0}.", value)); |
|||
inputsOk = false; |
|||
} |
|||
} |
|||
|
|||
return inputsOk; |
|||
} |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_Valid = CheckRequiredInputButtonMapping(m_RequiredInputButtons); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if(m_Valid) |
|||
{ |
|||
m_DebugControlEnabledMsgTimer += Time.deltaTime; |
|||
|
|||
bool enableDebug = Input.GetButton(kEnableDebugBtn1) && Input.GetButton(kEnableDebugBtn2) || Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Backspace); |
|||
|
|||
if (m_CanReceiveInput && enableDebug) |
|||
{ |
|||
m_DebugControlEnabled = !m_DebugControlEnabled; |
|||
m_DebugControlEnabledMsgTimer = 0.0f; |
|||
m_CanReceiveInput = false; |
|||
m_DebugKeyUp1 = false; |
|||
m_DebugKeyUp2 = false; |
|||
} |
|||
|
|||
if (Input.GetButtonUp(kEnableDebugBtn1)) |
|||
{ |
|||
m_DebugKeyUp1 = true; |
|||
} |
|||
if (Input.GetButtonUp(kEnableDebugBtn2)) |
|||
{ |
|||
m_DebugKeyUp2 = true; |
|||
} |
|||
|
|||
// For keyboard you want to be able to keep ctrl pressed.
|
|||
if (Input.GetKeyUp(KeyCode.Backspace)) |
|||
{ |
|||
m_DebugKeyUp1 = m_DebugKeyUp2 = true; |
|||
} |
|||
|
|||
m_CanReceiveInput = m_DebugKeyUp1 && m_DebugKeyUp2; |
|||
|
|||
if (m_DebugControlEnabledMsgTimer < m_DebugControlEnabledMsgTime) |
|||
{ |
|||
if (m_DebugControlEnabled) |
|||
PushDebugMessage("Debug Controls Enabled"); |
|||
else |
|||
PushDebugMessage("Debug Controls Disabled"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
using(new GUILayout.HorizontalScope()) |
|||
{ |
|||
GUILayout.Space(10.0f); |
|||
using(new GUILayout.VerticalScope()) |
|||
{ |
|||
GUILayout.Space(10.0f); |
|||
for (int i = 0; i < m_DebugMessages.Count; ++i) |
|||
{ |
|||
GUILayout.Label(m_DebugMessages[i]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Make sure to clear only after all relevant events have occured.
|
|||
if (Event.current.type == EventType.Repaint) |
|||
m_DebugMessages.Clear(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fcb6090d644beb040a7853639fcffddb |
|||
timeCreated: 1488381065 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class CameraSwitcher : MonoBehaviour |
|||
{ |
|||
public Camera[] m_Cameras; |
|||
|
|||
private int m_CurrentCameraIndex = -1; |
|||
private Camera m_OriginalCamera = null; |
|||
private Vector3 m_OriginalCameraPosition; |
|||
private Quaternion m_OriginalCameraRotation; |
|||
private Camera m_CurrentCamera = null; |
|||
|
|||
private float m_MessageDuration = 1.0f; |
|||
private float m_MessageTimer = 1000.0f; |
|||
|
|||
private static string kDebugNext = "Debug Next"; |
|||
private static string kDebugPrevious = "Debug Previous"; |
|||
private string[] m_RequiredInputButtons = { kDebugNext, kDebugPrevious }; |
|||
private bool m_Valid = true; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_OriginalCamera = GetComponent<Camera>(); |
|||
m_CurrentCamera = m_OriginalCamera; |
|||
|
|||
m_Valid = Debugging.CheckRequiredInputButtonMapping(m_RequiredInputButtons); |
|||
} |
|||
|
|||
int GetCameraCount() |
|||
{ |
|||
return m_Cameras.Length + 1; // We need +1 for handling the original camera.
|
|||
} |
|||
|
|||
void NextCamera() |
|||
{ |
|||
m_CurrentCameraIndex = (m_CurrentCameraIndex + 1) % GetCameraCount(); |
|||
} |
|||
|
|||
void PreviousCamera() |
|||
{ |
|||
m_CurrentCameraIndex = m_CurrentCameraIndex - 1; |
|||
if (m_CurrentCameraIndex == -1) |
|||
m_CurrentCameraIndex = m_Cameras.Length; |
|||
} |
|||
|
|||
Camera GetNextCamera() |
|||
{ |
|||
if (m_CurrentCameraIndex == m_Cameras.Length) |
|||
return m_OriginalCamera; |
|||
else |
|||
return m_Cameras[m_CurrentCameraIndex]; |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (m_Valid && Debugging.debugControlEnabled && m_OriginalCamera != null) |
|||
{ |
|||
m_MessageTimer += Time.deltaTime; |
|||
bool needUpdateCamera = false; |
|||
if (Input.GetButtonDown(kDebugNext)) |
|||
{ |
|||
NextCamera(); |
|||
needUpdateCamera = true; |
|||
} |
|||
|
|||
if (Input.GetButtonDown(kDebugPrevious)) |
|||
{ |
|||
PreviousCamera(); |
|||
needUpdateCamera = true; |
|||
} |
|||
|
|||
if (needUpdateCamera) |
|||
{ |
|||
m_MessageTimer = 0.0f; |
|||
|
|||
if(m_CurrentCamera == m_OriginalCamera) |
|||
{ |
|||
m_OriginalCameraPosition = m_OriginalCamera.transform.position; |
|||
m_OriginalCameraRotation = m_OriginalCamera.transform.rotation; |
|||
} |
|||
|
|||
m_CurrentCamera = GetNextCamera(); |
|||
|
|||
if(m_CurrentCamera != null) |
|||
{ |
|||
// If we witch back to the original camera, put back the transform in it.
|
|||
if (m_CurrentCamera == m_OriginalCamera) |
|||
{ |
|||
m_OriginalCamera.transform.position = m_OriginalCameraPosition; |
|||
m_OriginalCamera.transform.rotation = m_OriginalCameraRotation; |
|||
} |
|||
|
|||
transform.position = m_CurrentCamera.transform.position; |
|||
transform.rotation = m_CurrentCamera.transform.rotation; |
|||
} |
|||
} |
|||
|
|||
if (m_MessageTimer < m_MessageDuration) |
|||
{ |
|||
string cameraName = m_CurrentCamera != null ? m_CurrentCamera.name : "NULL"; |
|||
string message = string.Format("Switching to camera : {0}", cameraName); |
|||
Debugging.PushDebugMessage(message); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f52d1e5345c395641b482217c8804ff9 |
|||
timeCreated: 1488380874 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
public class FreeCamera : MonoBehaviour |
|||
{ |
|||
public float m_LookSpeedController = 120f; |
|||
public float m_LookSpeedMouse = 10.0f; |
|||
public float m_MoveSpeed = 50.0f; |
|||
public float m_Turbo = 10.0f; |
|||
|
|||
|
|||
private static string kMouseX = "Mouse X"; |
|||
private static string kMouseY = "Mouse Y"; |
|||
private static string kRightStickX = "Controller Right Stick X"; |
|||
private static string kRightStickY = "Controller Right Stick Y"; |
|||
private static string kVertical = "Vertical"; |
|||
private static string kHorizontal = "Horizontal"; |
|||
private string[] m_RequiredInputAxes = { kMouseX, kMouseY, kRightStickX, kRightStickY, kVertical, kHorizontal }; |
|||
|
|||
private bool m_Valid = true; |
|||
void OnEnable() |
|||
{ |
|||
m_Valid = Debugging.CheckRequiredInputAxisMapping(m_RequiredInputAxes); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if(m_Valid) |
|||
{ |
|||
float inputRotateAxisX = 0.0f; |
|||
float inputRotateAxisY = 0.0f; |
|||
if (Input.GetMouseButton(1)) |
|||
{ |
|||
inputRotateAxisX = Input.GetAxis(kMouseX) * m_LookSpeedMouse; |
|||
inputRotateAxisY = Input.GetAxis(kMouseY) * m_LookSpeedMouse; |
|||
} |
|||
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * Time.deltaTime); |
|||
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * Time.deltaTime); |
|||
|
|||
float inputVertical = Input.GetAxis(kVertical); |
|||
float inputHorizontal = Input.GetAxis(kHorizontal); |
|||
|
|||
bool moved = inputRotateAxisX != 0.0f || inputRotateAxisY != 0.0f || inputVertical != 0.0f || inputHorizontal != 0.0f; |
|||
if (moved) |
|||
{ |
|||
float rotationX = transform.localEulerAngles.x; |
|||
float newRotationY = transform.localEulerAngles.y + inputRotateAxisX; |
|||
|
|||
// Weird clamping code due to weird Euler angle mapping...
|
|||
float newRotationX = (rotationX - inputRotateAxisY); |
|||
if (rotationX <= 90.0f && newRotationX >= 0.0f) |
|||
newRotationX = Mathf.Clamp(newRotationX, 0.0f, 90.0f); |
|||
if (rotationX >= 270.0f) |
|||
newRotationX = Mathf.Clamp(newRotationX, 270.0f, 360.0f); |
|||
|
|||
transform.localRotation = Quaternion.Euler(newRotationX, newRotationY, transform.localEulerAngles.z); |
|||
|
|||
float moveSpeed = Time.deltaTime * m_MoveSpeed; |
|||
if (Input.GetMouseButton(1)) |
|||
moveSpeed *= Input.GetKey(KeyCode.LeftShift) ? m_Turbo : 1.0f; |
|||
else |
|||
moveSpeed *= Input.GetAxis("Fire1") > 0.0f ? m_Turbo : 1.0f; |
|||
transform.position += transform.forward * moveSpeed * inputVertical; |
|||
transform.position += transform.right * moveSpeed * inputHorizontal; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 618b0e3f6c65dd247a4a016150006c57 |
|||
timeCreated: 1488370968 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue