View Issue Details

IDProjectCategoryView StatusLast Update
0002648NoesisGUIUnrealpublic2023-09-06 13:45
Reporterhcpizzi Assigned Tohcpizzi  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.2.1 
Target Version3.2.2Fixed in Version3.2.2 
Summary0002648: Support MediaTextures in Bindings
DescriptionWe currently don't support MediaTextures in Bindings.
TagsNo tags attached.
PlatformAny

Activities

hcpizzi

hcpizzi

2023-07-14 13:09

developer   ~0008606

Here's a patch that adds support for MediaTextures in Bindings
2648.patch (4,112 bytes)   
Index: Source/NoesisRuntime/Private/NoesisTypeClass.cpp
===================================================================
--- Source/NoesisRuntime/Private/NoesisTypeClass.cpp	(revision 12613)
+++ Source/NoesisRuntime/Private/NoesisTypeClass.cpp	(revision 12614)
@@ -31,6 +31,9 @@
 #include "MaterialDomain.h"
 #endif
 
+// MediaAsset includes
+#include "MediaTexture.h"
+
 // Slate includes
 #include "Framework/Text/TextLayout.h"
 
@@ -430,6 +433,25 @@
 	}
 };
 
+template<>
+struct NoesisTypeTraits<UMediaTexture*>
+{
+	typedef Noesis::TextureSource* NoesisType;
+	static Noesis::Ptr<Noesis::BaseComponent> ToNoesis(UObject* Value)
+	{
+		check(Value == nullptr || Value->IsA<UMediaTexture>());
+		return NoesisCreateComponentForUTexture((UMediaTexture*)Value);
+	}
+	static UObject* ToUnreal(Noesis::BaseComponent* Value)
+	{
+		return nullptr;
+	}
+	static bool Equals(UObject* Left, UObject* Right)
+	{
+		return Left == Right;
+	}
+};
+
 template<class T>
 Noesis::Ptr<Noesis::BaseComponent> GenericGetter(void* BasePointer, FProperty* Property)
 {
@@ -625,8 +647,7 @@
 	void* Value = Property->template ContainerPtrToValuePtr<void>(BasePointer);
 	UObject*& Object = *(UObject**)Value;
 	check(Property->IsA<FObjectProperty>());
-	FObjectProperty* ObjectProperty = (FObjectProperty*)Property;
-	NoesisClassConversion* ClassConversion = ClassConversions.Find(ObjectProperty->PropertyClass);
+	NoesisClassConversion* ClassConversion = ClassConversions.Find(Object->GetClass());
 	if (ClassConversion != nullptr)
 	{
 		return (*ClassConversion->Wrapper)(Object);
@@ -642,8 +663,9 @@
 	void* Value = Property->template ContainerPtrToValuePtr<void>(BasePointer);
 	UObject*& Object = *(UObject**)Value;
 	check(Property->IsA<FObjectProperty>());
-	FObjectProperty* ObjectProperty = (FObjectProperty*)Property;
-	NoesisClassConversion* ClassConversion = ClassConversions.Find(ObjectProperty->PropertyClass); 
+	UObject* InputObject = NoesisFindUObjectForComponent(Input);
+	UClass* Class = InputObject != nullptr ? InputObject->GetClass() : nullptr;
+	NoesisClassConversion* ClassConversion = Class != nullptr ? ClassConversions.Find(Class) : nullptr;
 	if (ClassConversion != nullptr)
 	{
 		UObject* NewObject = (*ClassConversion->Unwrapper)(Input);
@@ -766,7 +788,9 @@
 {
 	ClassConversions =
 	{
-		{UTexture2D::StaticClass(), NoesisClassConversion::FromType<UTexture2D*>() }
+		{UTexture2D::StaticClass(), NoesisClassConversion::FromType<UTexture2D*>() },
+		{UTextureRenderTarget2D::StaticClass(), NoesisClassConversion::FromType<UTextureRenderTarget2D*>() },
+		{UMediaTexture::StaticClass(), NoesisClassConversion::FromType<UMediaTexture*>() }
 	};
 
 	UScriptStruct* TimespanStruct = nullptr;
@@ -2238,7 +2262,17 @@
 
 Noesis::Ptr<Noesis::BaseComponent> NoesisCreateComponentForUTexture(UTexture* Texture)
 {
-	return *new NoesisTextureWrapper(Texture);
+	NoesisTextureWrapper** TextureSourcePtr = TextureMap.Find(Texture);
+	if (TextureSourcePtr != nullptr)
+	{
+		return Noesis::Ptr<Noesis::BaseComponent>(*TextureSourcePtr);
+	}
+	else
+	{
+		NoesisTextureWrapper* TextureSource = new NoesisTextureWrapper(Texture);
+		TextureMap.Add(Texture, TextureSource);
+		return Noesis::Ptr<Noesis::BaseComponent>(*TextureSource);
+	}
 }
 
 Noesis::Ptr<Noesis::BaseComponent> NoesisCreateComponentForTArray(void* ArrayPtr, FArrayProperty* ArrayProperty)
@@ -3559,20 +3593,6 @@
 			Wrapper = *new NoesisPostProcessMaterialWrapper(Material);
 		}
 	}
-	else if (Class->IsChildOf(UTexture2D::StaticClass()) || Class->IsChildOf(UTextureRenderTarget2D::StaticClass()))
-	{
-		NoesisTextureWrapper** TextureSourcePtr = TextureMap.Find(Object);
-		if (TextureSourcePtr != nullptr)
-		{
-			Wrapper = Noesis::Ptr<Noesis::BaseComponent>(*TextureSourcePtr);
-		}
-		else
-		{
-			NoesisTextureWrapper* TextureSource = new NoesisTextureWrapper((UTexture*)Object);
-			TextureMap.Add(Object, TextureSource);
-			Wrapper = *TextureSource;
-		}
-	}
 	else
 	{
 		Wrapper = *new NoesisObjectWrapper(Object);
2648.patch (4,112 bytes)   

Issue History

Date Modified Username Field Change
2023-07-10 16:26 hcpizzi New Issue
2023-07-14 13:08 hcpizzi Assigned To => hcpizzi
2023-07-14 13:08 hcpizzi Status new => assigned
2023-07-14 13:09 hcpizzi Note Added: 0008606
2023-07-14 13:09 hcpizzi File Added: 2648.patch
2023-07-18 12:45 sfernandez Product Version => 3.2.1
2023-07-18 12:45 sfernandez Target Version => 3.2.2
2023-07-21 11:35 hcpizzi Status assigned => feedback
2023-09-06 13:45 hcpizzi Status feedback => resolved
2023-09-06 13:45 hcpizzi Resolution open => fixed
2023-09-06 13:45 hcpizzi Fixed in Version => 3.2.2