Jelajahi Sumber

Bugfix: AudioSource and AudioListener components now work properly in script code

BearishSun 8 tahun lalu
induk
melakukan
13752d1f37

+ 4 - 0
Source/BansheeCore/BsCorePrerequisites.h

@@ -329,6 +329,8 @@ namespace bs
 	class CLight;
 	class CAnimation;
 	class CBone;
+	class CAudioSource;
+	class CAudioListener;
 	class GpuPipelineParamInfo;
 	class MaterialParams;
 	template <class T> class TAnimationCurve;
@@ -664,6 +666,8 @@ namespace bs
 	typedef GameObjectHandle<CReflectionProbe> HReflectionProbe;
 	typedef GameObjectHandle<CSkybox> HSkybox;
 	typedef GameObjectHandle<CLightProbeVolume> HLightProbeVolume;
+	typedef GameObjectHandle<CAudioSource> HAudioSource;
+	typedef GameObjectHandle<CAudioListener> HAudioListener;
 
 	/** @} */
 }

+ 7 - 0
Source/BansheeCore/Components/BsCAudioListener.cpp

@@ -9,6 +9,13 @@ using namespace std::placeholders;
 
 namespace bs
 {
+	CAudioListener::CAudioListener()
+	{
+		setName("AudioListener");
+
+		mNotifyFlags = TCF_Transform;
+	}
+
 	CAudioListener::CAudioListener(const HSceneObject& parent)
 		: Component(parent)
 	{

+ 1 - 1
Source/BansheeCore/Components/BsCAudioListener.h

@@ -83,7 +83,7 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 
 	protected:
-		CAudioListener() {} // Serialization only
+		CAudioListener(); // Serialization only
 	};
 
 	 /** @} */

+ 8 - 2
Source/BansheeCore/Components/BsCAudioSource.cpp

@@ -9,9 +9,15 @@ using namespace std::placeholders;
 
 namespace bs
 {
+	CAudioSource::CAudioSource()
+	{
+		setName("AudioSource");
+
+		mNotifyFlags = TCF_Transform;
+	}
+
 	CAudioSource::CAudioSource(const HSceneObject& parent)
-		: Component(parent), mVolume(1.0f), mPitch(1.0f), mLoop(false), mPriority(0), mMinDistance(1.0f), mAttenuation(1.0f)
-		, mPlayOnStart(true)
+		: Component(parent)
 	{
 		setName("AudioSource");
 

+ 8 - 8
Source/BansheeCore/Components/BsCAudioSource.h

@@ -163,13 +163,13 @@ namespace bs
 		Vector3 mVelocity = Vector3::ZERO;
 
 		HAudioClip mAudioClip;
-		float mVolume;
-		float mPitch;
-		bool mLoop;
-		UINT32 mPriority;
-		float mMinDistance;
-		float mAttenuation;
-		bool mPlayOnStart;
+		float mVolume = 1.0f;
+		float mPitch = 1.0f;
+		bool mLoop = false;
+		UINT32 mPriority = 0;
+		float mMinDistance = 1.0f;
+		float mAttenuation = 1.0f;
+		bool mPlayOnStart = true;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/
@@ -180,7 +180,7 @@ namespace bs
 		RTTITypeBase* getRTTI() const override;
 
 	protected:
-		CAudioSource() {} // Serialization only
+		CAudioSource(); // Serialization only
 	 };
 
 	 /** @} */