Thomas ICHÉ
5 年前
当前提交
baade23a
共有 19 个文件被更改,包括 1827 次插入 和 1163 次删除
-
40Assets/SampleLoader/SampleLoader.cs
-
167Assets/Samples/ARRadar/ARRadar.unity
-
368Assets/Samples/BonFire/BonFire.unity
-
138Assets/Samples/Butterflies/Butterflies.unity
-
14Assets/Samples/EllenHologram/EllenHologram.unity
-
156Assets/Samples/GenieMagicLamp/Genie.unity
-
408Assets/Samples/GrassWind/GrassWind.unity
-
229Assets/Samples/MorphingFace/MorphingFace.unity
-
158Assets/Samples/Portal/Portal.unity
-
223Assets/Samples/RibbonPack/RibbonPack.unity
-
26Assets/Samples/SpaceshipHoloTable/Script/SpaceshipHoloTableZoomControl.cs
-
158Assets/Samples/UnityLogo/UnityLogo.unity
-
362Assets/Samples/Volumetric/Volumetric.unity
-
369Assets/Samples/VoxelizedTerrain/VoxelizedTerrain.unity
-
26Assets/Samples/VoxelizedTerrain/VoxelizedTerrainController.cs
-
60Assets/Samples/Common/Scripts/CursorControl.cs
-
11Assets/Samples/Common/Scripts/CursorControl.cs.meta
-
66Assets/Samples/GrassWind/GrassWindMenuCameraControl.cs
-
11Assets/Samples/GrassWind/GrassWindMenuCameraControl.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class CursorControl : MonoBehaviour |
|||
{ |
|||
public bool DefaultCursorVisible = false; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
if (SampleLoader.instance != null) |
|||
{ |
|||
SampleLoader.instance.onMenuToggle += OnSamplesMenuToggle; |
|||
} |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
if (SampleLoader.instance != null) |
|||
{ |
|||
SampleLoader.instance.onMenuToggle -= OnSamplesMenuToggle; |
|||
} |
|||
} |
|||
|
|||
bool menuVisible = false; |
|||
void OnSamplesMenuToggle(bool visible) |
|||
{ |
|||
menuVisible = visible; |
|||
ShowCursor(menuVisible ? true : DefaultCursorVisible); |
|||
} |
|||
|
|||
private void Start() |
|||
{ |
|||
ShowCursor(DefaultCursorVisible); |
|||
} |
|||
|
|||
void ShowCursor(bool visible) |
|||
{ |
|||
if (visible) |
|||
{ |
|||
Cursor.visible = true; |
|||
Cursor.lockState = CursorLockMode.None; |
|||
} |
|||
else |
|||
{ |
|||
Cursor.visible = false; |
|||
Cursor.lockState = CursorLockMode.Locked; |
|||
} |
|||
} |
|||
|
|||
float GetInputAxis(string axisName) |
|||
{ |
|||
if (!menuVisible) |
|||
{ |
|||
return Input.GetAxis(axisName); |
|||
} |
|||
else |
|||
return 0; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 329a80dfda2a3b947923e71a6a7ed377 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Cinemachine; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class GrassWindMenuCameraControl : MonoBehaviour |
|||
{ |
|||
CinemachineCore.AxisInputDelegate m_AxisDelegateBackup; |
|||
|
|||
private void OnEnable() |
|||
{ |
|||
m_AxisDelegateBackup = CinemachineCore.GetInputAxis; |
|||
|
|||
CinemachineCore.GetInputAxis = GetInputAxis; |
|||
if(SampleLoader.instance != null) |
|||
{ |
|||
SampleLoader.instance.onMenuToggle += OnSamplesMenuToggle; |
|||
} |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
CinemachineCore.GetInputAxis = m_AxisDelegateBackup; |
|||
|
|||
if (SampleLoader.instance != null) |
|||
{ |
|||
SampleLoader.instance.onMenuToggle -= OnSamplesMenuToggle; |
|||
} |
|||
} |
|||
|
|||
bool menuVisible = false; |
|||
void OnSamplesMenuToggle(bool visible) |
|||
{ |
|||
menuVisible = visible; |
|||
ShowCursor(menuVisible); |
|||
} |
|||
|
|||
private void Start() |
|||
{ |
|||
ShowCursor(false); |
|||
} |
|||
|
|||
void ShowCursor(bool visible) |
|||
{ |
|||
if (visible) |
|||
{ |
|||
Cursor.visible = true; |
|||
Cursor.lockState = CursorLockMode.None; |
|||
} |
|||
else |
|||
{ |
|||
Cursor.visible = false; |
|||
Cursor.lockState = CursorLockMode.Locked; |
|||
} |
|||
} |
|||
|
|||
float GetInputAxis(string axisName) |
|||
{ |
|||
if (!menuVisible) |
|||
{ |
|||
return Input.GetAxis(axisName); |
|||
} |
|||
else |
|||
return 0; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c4d3988cc678b2244bb6314fc6f6bcbe |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue