x

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"

How do I create a *temporary* UCurveFloat?

So I've got a variety of curves that are stored as FRichCurves in my own UDataAsset that I want to show in an editor plugin. This requires creating temporary UCurveFloat* objects with no physical counterparts in the content browser (there's about 500 curves, which would stink up the content browser and require a lot more lookups) because SCurveEditor only takes those.

 UCurveFloat* Curve = NewObject<UCurveFloat>(); // there seems to be no other way to build a curve that's not part of an actual actor or package. Remember, we're part of a widget, so we can't hook it onto that
 

My question is, what can I do to make UE stop apparently auto-garbage collecting parts of them at inopportune times? When the editor tries to autosave, I get... this result, which isn't very useful. I can't make it a safer reference-counted pointer, because apparently you cannot do that with an UObject. alt text If nobody has any suggestions, I guess I could write my own FRichFloat editor, but I was really hoping I could stick to the built-in stuff. I mean, that's what it's for, right?

(also, you know, you might want to sanity check the data at that point in SCurveEditor.cpp anyway, since apparently it can sometimes be null)

Product Version: UE 4.14
Tags:
curveproblem.png (173.1 kB)
more ▼

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

avatar image

turfster
92 8 19 24

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

1 answer: sort voted first

You can use AddToRoot() to temporarily mark an object as part of the root set (and thus safe from garbage collection) while you are editing it. Call RemoveFromRoot() when you are finished with your temporary object and want to allow it to die.

If the outer calling code is itself in a UObject then you just need to store a reference to your temporary object in a UPROPERTY() so it can be found during GC.

Finally you can also use a FGCObject class to keep something alive, but one of the first two approaches are probably better.

Cheers, Michael Noland

more ▼

answered Jan 13 '17 at 11:11 PM

avatar image

Michael Noland STAFF
609 17 11 33

avatar image turfster Jan 14 '17 at 12:25 AM

Thanks, that did it!

(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