From 089eb9de261eaca1d8aba027fcbccfaf8bf20798 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Fri, 10 Mar 2023 14:11:59 +0800 Subject: [PATCH] Fixed bug where C# Asset implicit bool conversion operators were internal --- Assets/Scripts/AnimTest.cs | 12 ++++++---- .../src/Assets/AnimationClipAsset.hxx | 21 +++++++++-------- .../src/Assets/AnimationControllerAsset.hxx | 23 ++++++++++--------- .../src/Assets/AnimationRigAsset.hxx | 21 +++++++++-------- SHADE_Managed/src/Assets/FontAsset.hxx | 21 +++++++++-------- SHADE_Managed/src/Assets/MaterialAsset.hxx | 21 +++++++++-------- SHADE_Managed/src/Assets/MeshAsset.hxx | 23 ++++++++++--------- 7 files changed, 76 insertions(+), 66 deletions(-) diff --git a/Assets/Scripts/AnimTest.cs b/Assets/Scripts/AnimTest.cs index 4ceccbe6..584d046f 100644 --- a/Assets/Scripts/AnimTest.cs +++ b/Assets/Scripts/AnimTest.cs @@ -34,19 +34,23 @@ namespace SHADE.Test // Play animations if (Input.GetKeyUp(Input.KeyCode.Equals)) { - playFunc(fullClip); + if (fullClip) + playFunc(fullClip); } else if (Input.GetKeyUp(Input.KeyCode.Alpha1)) { - playFunc(idleClip); + if (idleClip) + playFunc(idleClip); } else if (Input.GetKeyUp(Input.KeyCode.Alpha2)) { - playFunc(runClip); + if (runClip) + playFunc(runClip); } else if (Input.GetKeyUp(Input.KeyCode.Alpha3)) { - playFunc(pickUpClip); + if (pickUpClip) + playFunc(pickUpClip); } } #endregion diff --git a/SHADE_Managed/src/Assets/AnimationClipAsset.hxx b/SHADE_Managed/src/Assets/AnimationClipAsset.hxx index 5a8c7845..2a4e52b3 100644 --- a/SHADE_Managed/src/Assets/AnimationClipAsset.hxx +++ b/SHADE_Managed/src/Assets/AnimationClipAsset.hxx @@ -29,6 +29,17 @@ namespace SHADE /// public value struct AnimationClipAsset { + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a AnimationClip is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(AnimationClipAsset asset); + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ @@ -57,16 +68,6 @@ namespace SHADE /// AssetID to the AnimationClip asset. AnimationClipAsset(AssetID AnimationClipId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a AnimationClip is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(AnimationClipAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Assets/AnimationControllerAsset.hxx b/SHADE_Managed/src/Assets/AnimationControllerAsset.hxx index 1be74fb9..7dc3d3d7 100644 --- a/SHADE_Managed/src/Assets/AnimationControllerAsset.hxx +++ b/SHADE_Managed/src/Assets/AnimationControllerAsset.hxx @@ -28,7 +28,18 @@ namespace SHADE /// public value struct AnimationControllerAsset { - internal: + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a AnimationController is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(AnimationControllerAsset asset); + + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ /*-----------------------------------------------------------------------------*/ @@ -56,16 +67,6 @@ namespace SHADE /// AssetID to the AnimationController asset. AnimationControllerAsset(AssetID AnimationControllerId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a AnimationController is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(AnimationControllerAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Assets/AnimationRigAsset.hxx b/SHADE_Managed/src/Assets/AnimationRigAsset.hxx index be43b7f0..09964d31 100644 --- a/SHADE_Managed/src/Assets/AnimationRigAsset.hxx +++ b/SHADE_Managed/src/Assets/AnimationRigAsset.hxx @@ -28,6 +28,17 @@ namespace SHADE /// public value struct AnimationRigAsset { + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a AnimationRig is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(AnimationRigAsset asset); + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ @@ -56,16 +67,6 @@ namespace SHADE /// AssetID to the AnimationRig asset. AnimationRigAsset(AssetID AnimationRigId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a AnimationRig is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(AnimationRigAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Assets/FontAsset.hxx b/SHADE_Managed/src/Assets/FontAsset.hxx index 89239224..5c3b4e11 100644 --- a/SHADE_Managed/src/Assets/FontAsset.hxx +++ b/SHADE_Managed/src/Assets/FontAsset.hxx @@ -28,6 +28,17 @@ namespace SHADE /// public value struct FontAsset { + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a Font is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(FontAsset asset); + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ @@ -56,16 +67,6 @@ namespace SHADE /// AssetID to the font asset. FontAsset(AssetID fontId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a Font is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(FontAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Assets/MaterialAsset.hxx b/SHADE_Managed/src/Assets/MaterialAsset.hxx index 5380b286..a5a0909b 100644 --- a/SHADE_Managed/src/Assets/MaterialAsset.hxx +++ b/SHADE_Managed/src/Assets/MaterialAsset.hxx @@ -28,6 +28,17 @@ namespace SHADE /// public value struct MaterialAsset { + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a Material is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(MaterialAsset asset); + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ @@ -56,16 +67,6 @@ namespace SHADE /// AssetID to the Material asset. MaterialAsset(AssetID MaterialId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a Material is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(MaterialAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Assets/MeshAsset.hxx b/SHADE_Managed/src/Assets/MeshAsset.hxx index 26625c1a..63922d65 100644 --- a/SHADE_Managed/src/Assets/MeshAsset.hxx +++ b/SHADE_Managed/src/Assets/MeshAsset.hxx @@ -28,7 +28,18 @@ namespace SHADE /// public value struct MeshAsset { - internal: + public: + /*-----------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*-----------------------------------------------------------------------------*/ + /// + /// Implicit conversion operator to enable checking if a Mesh is valid. + /// + /// Asset to check. + /// True if the Asset is valid. + static operator bool(MeshAsset asset); + + internal: /*-----------------------------------------------------------------------------*/ /* Properties */ /*-----------------------------------------------------------------------------*/ @@ -56,16 +67,6 @@ namespace SHADE /// AssetID to the Mesh asset. MeshAsset(AssetID meshId); - /*-----------------------------------------------------------------------------*/ - /* Operator Overloads */ - /*-----------------------------------------------------------------------------*/ - /// - /// Implicit conversion operator to enable checking if a Mesh is valid. - /// - /// Asset to check. - /// True if the Asset is valid. - static operator bool(MeshAsset asset); - /*-----------------------------------------------------------------------------*/ /* Conversion Operators */ /*-----------------------------------------------------------------------------*/