Ivan3z
(Ivan3z)
May 17, 2023, 1:42am
1
I am looking for a function equivalent to node (IsValidClass) in C++.
I tried something like this but the function doesn’t exist, or I don’t have the necessary include.
IsValidClass();
I can’t find the solution on Google either.
Do you know how to do it?
Thank you so much!!
Ivan3z
(Ivan3z)
May 17, 2023, 2:04am
2
ok… i found this in the Lyra code
TSubclassOf PartClass = ULyraDevelopmentStatics::FindClassByShortName(AssetName);
if (PartClass != nullptr)
I hope it works
Perhaps this is what you’re looking for?
UKismetSystemLibrary::IsValidClass(const UClass *Class);
The above method forwards to:
::IsValid(const UObject*);
1 Like
Also you can do it like that :
if (IsValid(YourClass))
{
}
or
if (YourClass)
{
}
1 Like
Ivan3z
(Ivan3z)
May 17, 2023, 2:13am
5
Thank you very much for your reply
However it appears to be a private member of the class
Ivan3z
(Ivan3z)
May 17, 2023, 2:32am
7
Thanks for your reply
I’m going to try it.
Not sure if it will work though… seems to only work with classes derived from UObject.
This class is not derived class derived from UObject
But this is a derived class derived from UObject
So maybe I should use it this way
I’m going to try it and then come back here to say what happened.
Thank you very much for your help!!
UClass does derive from UObject. TSubclassOf is just a wrapper that holds a pointer to a UClass.
So IsValid() is correct.
And you shouldn’t need to call .Get() on a TSubclassOf. It should just work. I have tried it and it compiles.
edit: The reason it works with TSubclassOf despite not deriving from UObject is because it has an operator that will return the contained pointer and since that pointer does derive from a UObject, it should just work. These are implicit conversions that the compiler will do.
1 Like
Ivan3z
(Ivan3z)
May 17, 2023, 2:41am
9
Ok, I will do as you say, thank you very much for your explanation!
system
(system)
Closed
May 18, 2023, 2:50am
11
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.