From ea9deb82fb5c5c8742035646980a3a7ba2585f00 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 16 Jan 2024 11:57:58 +0100 Subject: [PATCH] Added namespaces --- Editor/HumanoidControl/Pose/Pose_Editor.cs | 2 +- .../Scripts/Tools/FlashLight.cs | 55 +++++---- Runtime/HumanoidControl/Scripts/Tools/Hit.cs | 12 +- .../HumanoidControl/Scripts/Tools/Redrop.cs | 62 +++++----- .../Scripts/Tools/SceneLoader.cs | 55 +++++---- Runtime/Sites/Scripts/RigidbodyTools.cs | 4 +- Runtime/Tools/Input/ControllerDebugger.cs | 112 +++++++++--------- Runtime/Visitors/Scripts/ShowVisitorName.cs | 29 +++-- Runtime/Visitors/Scripts/ToggleActive.cs | 14 ++- 9 files changed, 186 insertions(+), 159 deletions(-) diff --git a/Editor/HumanoidControl/Pose/Pose_Editor.cs b/Editor/HumanoidControl/Pose/Pose_Editor.cs index 89c4838..45e209d 100644 --- a/Editor/HumanoidControl/Pose/Pose_Editor.cs +++ b/Editor/HumanoidControl/Pose/Pose_Editor.cs @@ -236,7 +236,7 @@ namespace Passer.Humanoid { if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null) continue; - Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID); + var fmh_239_74_638409995538839071 = bones[i].bone.transform.rotation; Handles.FreeMoveHandle(bones[i].bone.transform.position, 0.002F, Vector3.zero, DotHandleCapSaveID); controlIds[i] = lastControlID; boneIds[i] = bones[i].boneId; } diff --git a/Runtime/HumanoidControl/Scripts/Tools/FlashLight.cs b/Runtime/HumanoidControl/Scripts/Tools/FlashLight.cs index 4e00bbc..a64bb6b 100644 --- a/Runtime/HumanoidControl/Scripts/Tools/FlashLight.cs +++ b/Runtime/HumanoidControl/Scripts/Tools/FlashLight.cs @@ -1,33 +1,36 @@ using System.Collections; using UnityEngine; -public class FlashLight : MonoBehaviour { +namespace Passer { - protected Light thisLight; + public class FlashLight : MonoBehaviour { - public float duration = 0.1F; + protected Light thisLight; - protected virtual void Awake() { - thisLight = GetComponent(); + public float duration = 0.1F; + + protected virtual void Awake() { + thisLight = GetComponent(); + } + + public void Flash() { + Flash(duration); + } + + public void Flash(float duration) { + if (thisLight == null) + return; + + StartCoroutine(FlashRoutine(thisLight, duration)); + } + + protected IEnumerator FlashRoutine(Light light, float duration) { + if (light == null) + yield return null; + + light.enabled = true; + yield return new WaitForSeconds(duration); + light.enabled = false; + } } - - public void Flash() { - Flash(duration); - } - - public void Flash(float duration) { - if (thisLight == null) - return; - - StartCoroutine(FlashRoutine(thisLight, duration)); - } - - protected IEnumerator FlashRoutine(Light light, float duration) { - if (light == null) - yield return null; - - light.enabled = true; - yield return new WaitForSeconds(duration); - light.enabled = false; - } -} +} \ No newline at end of file diff --git a/Runtime/HumanoidControl/Scripts/Tools/Hit.cs b/Runtime/HumanoidControl/Scripts/Tools/Hit.cs index d61b3da..2d1a0f5 100644 --- a/Runtime/HumanoidControl/Scripts/Tools/Hit.cs +++ b/Runtime/HumanoidControl/Scripts/Tools/Hit.cs @@ -1,8 +1,12 @@ using UnityEngine; -public class Hit : MonoBehaviour { +namespace Passer { - public void HitMe() { - Debug.Log("AU!"); + public class Hit : MonoBehaviour { + + public void HitMe() { + Debug.Log("AU!"); + } } -} + +} \ No newline at end of file diff --git a/Runtime/HumanoidControl/Scripts/Tools/Redrop.cs b/Runtime/HumanoidControl/Scripts/Tools/Redrop.cs index 6798244..43eb647 100644 --- a/Runtime/HumanoidControl/Scripts/Tools/Redrop.cs +++ b/Runtime/HumanoidControl/Scripts/Tools/Redrop.cs @@ -1,39 +1,43 @@ using UnityEngine; -public class Redrop : MonoBehaviour { +namespace Passer { - // Script which is to be replaced by CollisionEventHandler + public class Redrop : MonoBehaviour { - public Collider groundCollider; + // Script which is to be replaced by CollisionEventHandler - private Rigidbody thisRigidbody; - private Vector3 startPosition; - private Quaternion startRotation; + public Collider groundCollider; - void Start() { - startPosition = transform.position; - startRotation = transform.rotation; - } + private Rigidbody thisRigidbody; + private Vector3 startPosition; + private Quaternion startRotation; - void Update() { - if (groundCollider == null && transform.position.y < 0) { - MoveToStart(); + void Start() { + startPosition = transform.position; + startRotation = transform.rotation; + } + + void Update() { + if (groundCollider == null && transform.position.y < 0) { + MoveToStart(); + } + } + + private void OnCollisionEnter(Collision collision) { + if (collision.collider == groundCollider) { + MoveToStart(); + } + } + + private void MoveToStart() { + thisRigidbody = transform.GetComponent(); + if (thisRigidbody != null) { + thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z)); + thisRigidbody.MoveRotation(startRotation); + thisRigidbody.velocity = Vector3.zero; + thisRigidbody.angularVelocity = Vector3.zero; + } } } - private void OnCollisionEnter(Collision collision) { - if (collision.collider == groundCollider) { - MoveToStart(); - } - } - - private void MoveToStart() { - thisRigidbody = transform.GetComponent(); - if (thisRigidbody != null) { - thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z)); - thisRigidbody.MoveRotation(startRotation); - thisRigidbody.velocity = Vector3.zero; - thisRigidbody.angularVelocity = Vector3.zero; - } - } -} +} \ No newline at end of file diff --git a/Runtime/HumanoidControl/Scripts/Tools/SceneLoader.cs b/Runtime/HumanoidControl/Scripts/Tools/SceneLoader.cs index 0ef19b5..584a0ee 100644 --- a/Runtime/HumanoidControl/Scripts/Tools/SceneLoader.cs +++ b/Runtime/HumanoidControl/Scripts/Tools/SceneLoader.cs @@ -4,31 +4,42 @@ using UnityEngine.SceneManagement; using UnityEditor; using UnityEditor.SceneManagement; +namespace Passer { -[InitializeOnLoad] -public class SceneLoader { - static SceneLoader() { - EditorSceneManager.sceneOpened += SceneOpened; - } - - private static void SceneOpened(Scene scene, OpenSceneMode mode) { - if ((scene.name == "ObjectTable Pawn" || - scene.name == "ObjectTable Pawn VR" || - scene.name == "ObjectTable Humanoid") && - EditorSceneManager.loadedSceneCount == 1) { - - //Debug.Log("Additive opening ObjectTable scene"); - EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive); - } - else if ((scene.name == "ShootingRange Pawn" || - scene.name == "ShootingRange Pawn VR" || - scene.name == "ShootingRange Humanoid") && - EditorSceneManager.loadedSceneCount == 1) { - - //Debug.Log("Additive opening ShootingRange scene"); - EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive); + [InitializeOnLoad] + public class SceneLoader { + static SceneLoader() { + EditorSceneManager.sceneOpened += SceneOpened; } + private static void SceneOpened(Scene scene, OpenSceneMode mode) { + if ((scene.name == "ObjectTable Pawn" || + scene.name == "ObjectTable Pawn VR" || + scene.name == "ObjectTable Humanoid") +#if UNITY_2022_2_OR_NEWER + && UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1 +#else + && EditorSceneManager.loadedSceneCount == 1 +#endif + ) { + //Debug.Log("Additive opening ObjectTable scene"); + EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive); + } + else if ((scene.name == "ShootingRange Pawn" || + scene.name == "ShootingRange Pawn VR" || + scene.name == "ShootingRange Humanoid") +#if UNITY_2022_2_OR_NEWER + && UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1 +#else + && EditorSceneManager.loadedSceneCount == 1 +#endif + ) { + //Debug.Log("Additive opening ShootingRange scene"); + EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive); + } + + } } + } #endif diff --git a/Runtime/Sites/Scripts/RigidbodyTools.cs b/Runtime/Sites/Scripts/RigidbodyTools.cs index 6942b70..e4f23cd 100644 --- a/Runtime/Sites/Scripts/RigidbodyTools.cs +++ b/Runtime/Sites/Scripts/RigidbodyTools.cs @@ -1,6 +1,6 @@ using UnityEngine; -//namespace Passer { +namespace Passer { public static class RigidbodyTools { public static void DestroyGameObject(this Rigidbody rigidbody) { @@ -8,4 +8,4 @@ } } -//} \ No newline at end of file +} \ No newline at end of file diff --git a/Runtime/Tools/Input/ControllerDebugger.cs b/Runtime/Tools/Input/ControllerDebugger.cs index 54d51dd..4f6327a 100644 --- a/Runtime/Tools/Input/ControllerDebugger.cs +++ b/Runtime/Tools/Input/ControllerDebugger.cs @@ -1,66 +1,68 @@ using UnityEngine; using System.Collections; -using Passer; +namespace Passer { -public class ControllerDebugger : MonoBehaviour { + public class ControllerDebugger : MonoBehaviour { - [System.Serializable] - public struct ControllerSideDebugger { - public float stickHorizontal; - public float stickVertical; - public bool stickButton; - public bool stickTouch; + [System.Serializable] + public struct ControllerSideDebugger { + public float stickHorizontal; + public float stickVertical; + public bool stickButton; + public bool stickTouch; - public float touchpadHorizontal; - public float touchpadVertical; - public bool touchpadButton; - public bool touchpadTouch; + public float touchpadHorizontal; + public float touchpadVertical; + public bool touchpadButton; + public bool touchpadTouch; - public bool[] buttons; + public bool[] buttons; - public float bumper; - public float trigger; + public float bumper; + public float trigger; - public bool option; + public bool option; + } + + public ControllerSideDebugger left; + public ControllerSideDebugger right; + + private Controller controller; + + private void Start() { + controller = Controllers.GetController(0); + + left.buttons = new bool[4]; + right.buttons = new bool[4]; + } + + private void Update() { + UpdateSide(ref left, controller.left); + UpdateSide(ref right, controller.right); + } + + void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) { + sideDebugger.stickHorizontal = controllerSide.stickHorizontal; + sideDebugger.stickVertical = controllerSide.stickVertical; + sideDebugger.stickButton = controllerSide.stickButton; + sideDebugger.stickTouch = controllerSide.stickTouch; + + sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal; + sideDebugger.touchpadVertical = controllerSide.touchpadVertical; + sideDebugger.touchpadButton = controllerSide.touchpadPress; + sideDebugger.touchpadTouch = controllerSide.touchpadTouch; + + sideDebugger.buttons[0] = controllerSide.buttons[0]; + sideDebugger.buttons[1] = controllerSide.buttons[1]; + sideDebugger.buttons[2] = controllerSide.buttons[2]; + sideDebugger.buttons[3] = controllerSide.buttons[3]; + + sideDebugger.bumper = controllerSide.trigger1; + sideDebugger.trigger = controllerSide.trigger2; + + sideDebugger.option = controllerSide.option; + } } - public ControllerSideDebugger left; - public ControllerSideDebugger right; - - private Controller controller; - - private void Start () { - controller = Controllers.GetController(0); - - left.buttons = new bool[4]; - right.buttons = new bool[4]; - } - - private void Update () { - UpdateSide(ref left, controller.left); - UpdateSide(ref right, controller.right); - } - - void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) { - sideDebugger.stickHorizontal = controllerSide.stickHorizontal; - sideDebugger.stickVertical = controllerSide.stickVertical; - sideDebugger.stickButton = controllerSide.stickButton; - sideDebugger.stickTouch = controllerSide.stickTouch; - - sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal; - sideDebugger.touchpadVertical = controllerSide.touchpadVertical; - sideDebugger.touchpadButton = controllerSide.touchpadPress; - sideDebugger.touchpadTouch = controllerSide.touchpadTouch; - - sideDebugger.buttons[0] = controllerSide.buttons[0]; - sideDebugger.buttons[1] = controllerSide.buttons[1]; - sideDebugger.buttons[2] = controllerSide.buttons[2]; - sideDebugger.buttons[3] = controllerSide.buttons[3]; - - sideDebugger.bumper = controllerSide.trigger1; - sideDebugger.trigger = controllerSide.trigger2; - - sideDebugger.option = controllerSide.option; - } -} +} \ No newline at end of file diff --git a/Runtime/Visitors/Scripts/ShowVisitorName.cs b/Runtime/Visitors/Scripts/ShowVisitorName.cs index a215a90..a7fdf7a 100644 --- a/Runtime/Visitors/Scripts/ShowVisitorName.cs +++ b/Runtime/Visitors/Scripts/ShowVisitorName.cs @@ -1,18 +1,17 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; -public class ShowVisitorName : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - +namespace Passer { + + public class ShowVisitorName : MonoBehaviour { + // Start is called before the first frame update + void Start() { + + } + + // Update is called once per frame + void Update() { + + } } - // Update is called once per frame - void Update() - { - - } -} +} \ No newline at end of file diff --git a/Runtime/Visitors/Scripts/ToggleActive.cs b/Runtime/Visitors/Scripts/ToggleActive.cs index 5c7b360..ebeea7c 100644 --- a/Runtime/Visitors/Scripts/ToggleActive.cs +++ b/Runtime/Visitors/Scripts/ToggleActive.cs @@ -1,8 +1,12 @@ using UnityEngine; -public class ToggleActive : MonoBehaviour { - // Temporary helper script to implement toggling the gameobject active state - public void Toggle() { - this.gameObject.SetActive(!this.gameObject.activeSelf); +namespace Passer { + + public class ToggleActive : MonoBehaviour { + // Temporary helper script to implement toggling the gameobject active state + public void Toggle() { + this.gameObject.SetActive(!this.gameObject.activeSelf); + } } -} + +} \ No newline at end of file