Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Changing UPROPERTY type based on other UPROPERTY

Is it possible to do with some C++ magic?

Fir example I have to variables, both declared in C++ base class.

alt text

First store the Object Class and is set up from subclassed blueprint. Second is instance Variable and it's type should change to the value set in firs variable, or be Object if null.

Is that kind of magic possible in C++? Have anybody did something like that? Maybe some tweaking of Class properties can be implemented at runtime? That is expected to be some kind of template mechanism.

Product Version: UE 4.14
more ▼

asked Jan 24 '17 at 07:24 AM in C++ Programming

avatar image

544 39 50 68

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Templates wont do anything for you, since they evaluate at compile time, and you are looking to do stuff at runtime.

Do you want the variable to be of arbritrary class? For example: Could it be anything from an int32 to a UStaticMeshComponent? If this is the case, then I'm pretty sure that it won't work. (I have also no idea why you would need something like that)

If they have some functionallity in common however, for example they all have one method that you want to call, you could derive all your variableClasses from a parent class. Your variable then stores a pointer to this parent class, and you can assign any object of the subclasses to it. You could then call your method using virtual functions. Also check out TSubclassOf if this direction works for you.

more ▼

answered Jan 24 '17 at 10:55 AM

avatar image

1.2k 46 29 59

avatar image Yata Jan 25 '17 at 06:43 AM

No, seems you don't get the idea. I want some mechanism to be able to switch variable type depending on other variables value. So if I switch value in VariableClass variable to ex. MyActorClass, than type of Variable should automatically change to MyActor. So I will not need do typecasts everywhere in my code.

avatar image pulp_user Jan 25 '17 at 07:15 AM

No, this is not possible. C++ is a statically typed language, the whole point is to know the type of variables at compile time, you can't simply change them at runtime. You will have to use casts.

avatar image Yata Jan 25 '17 at 07:58 AM

No, I am talking about changing type in Blueprint, it should be possible by tweaking UClass members, but I am not sure if this is safe.

avatar image pulp_user Jan 25 '17 at 08:11 AM

In your question you said, that Variable and VariableClass are both declared in a C++ class. If that is the case you can't change their type, for the reasons in my earlier comment. If you want to change their type in Blueprint, you should ask this question again in the Blueprint section, not in the C++ section.

avatar image Yata Jan 25 '17 at 08:15 AM

Yes, the type on C++ side is known and static, but on Blueprint side I want it changed. For example my VariableClass is TSubclassOf And Variable is of type ABaseActor*

But on Blueprint side I can set VariableClass to MyDerivedActorClass type and want Variable be visible as MyDerivedActor That would be pretty legal.

Don't think that question is suitable for Blueprint section, because solution should involve some C++ coding I think.

avatar image MCGWoody Jun 08 '17 at 06:00 PM

I am trying to do a similar thing. I have a UEnum as a UProperty in c++ called PropertyA. I want to expose a blueprint property called PropertyB to select a subclass of UEnum(possibly a blueprint type). Then I would like the PropertyA drop down options to be limited to values of type PropertyB. Does this make sense? Any Ideas?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question