Create a editable curve in Detail Panel

Hi,

I want to know how to draw the red curve like the screenshot.

I hope that the points on the curve can be adjusted by other UPROPERTY variables.

After my own implementation, FRuntimeFloatCurve does not contain a editable curves and the points on the curve must be added manually.

Can I draw a preset curve and the points via C++?

Can I change the curve properties(“Time”,“value”…as shown in the screenshot) via C++?

Thanks.

283908-curve-1.png

Hello ashleypan0808,

If I understand your question correctly you want to create a FRuntimeFloatCurve that has a curve defined in C++ by default and that they are editable by altering separate values in the details panel. You can create the default FRuntimeFloatCurve in C++. You can also write a function to update the keys whenever you want at edit time.

.h

UPROPERTY(EditAnywhere, Category = "Curve Category")
FRuntimeFloatCurve Curve;

FKeyHandle h1;
FKeyHandle h2;
FKeyHandle h3;

.cpp

...
//Inside Constructor
//create keyhandles to manipulate keys
	h1 = FKeyHandle();
	h2 = FKeyHandle();
	h3 = FKeyHandle();

//Add keys to the graph
Curve.EditorCurveData.AddKey(0.2f, 0.6f, true, h1);
Curve.EditorCurveData.AddKey(0.9f, 1.2f, true, h2);
Curve.EditorCurveData.AddKey(1.5f, 0.8f, true, h3);

//Add the first key
Curve.EditorCurveData.SetKeyTangentMode(h1, ERichCurveTangentMode::RCTM_Auto);
//Set the Interpretation Mode
Curve.EditorCurveData.SetKeyInterpMode(h1, ERichCurveInterpMode::RCIM_Cubic);
Curve.EditorCurveData.SetKeyTime(h1, 0.25f);
Curve.EditorCurveData.SetKeyValue(h1, 0.32f);

//Add the second key
Curve.EditorCurveData.SetKeyTangentMode(h2, ERichCurveTangentMode::RCTM_Auto);
//Set the Interpretation Mode
Curve.EditorCurveData.SetKeyInterpMode(h2, ERichCurveInterpMode::RCIM_Cubic);

//Add the third key
Curve.EditorCurveData.SetKeyTangentMode(h3, ERichCurveTangentMode::RCTM_Auto);
//Set the Interpretation Mode
Curve.EditorCurveData.SetKeyInterpMode(h3, ERichCurveInterpMode::RCIM_Cubic);
...


void ACurveActor::SetInterpMode(FKeyHandle key, ERichCurveInterpMode eMode)
{
	Curve.EditorCurveData.SetKeyInterpMode(key, eMode);
}

You cannot expose FKeyHandles to blueprints, which is why SetInterpMode() doesn’t use UCLASS().

As for updating the graph by updating separate values you can read about detail panel customization here.

From,

Hi ,

Thanks for your help!!!

But after I add four keys in curve, the fourth key will not display in curve graph.
Do you know what caused this problem?

.h

UPROPERTY(EditAnywhere, Category = "Curve")
		FRuntimeFloatCurve Curve;

FKeyHandle h1;
FKeyHandle h2;
FKeyHandle h3;
FKeyHandle h4;

.cpp

//Inside Constructor
    //create keyhandles to manipulate keys
	h1 = FKeyHandle();
	h2 = FKeyHandle();
	h3 = FKeyHandle();
	h4 = FKeyHandle();

	//Add keys to the graph
	Curve.EditorCurveData.AddKey(0.2f, 0.6f, true, h1);
	Curve.EditorCurveData.AddKey(0.9f, 1.2f, true, h2);
	Curve.EditorCurveData.AddKey(1.5f, 0.8f, true, h3);
	Curve.EditorCurveData.AddKey(0.2f, 1.0f, true, h4);

	//Add the first key
	Curve.EditorCurveData.SetKeyTangentMode(h1, ERichCurveTangentMode::RCTM_Auto);
	//Set the Interpretation Mode
	Curve.EditorCurveData.SetKeyInterpMode(h1, ERichCurveInterpMode::RCIM_Cubic);
	/*Curve.EditorCurveData.SetKeyTime(h1, 0.25f);
	Curve.EditorCurveData.SetKeyValue(h1, 0.32f);*/
	
	//Add the second key
	Curve.EditorCurveData.SetKeyTangentMode(h2, ERichCurveTangentMode::RCTM_Auto);
	//Set the Interpretation Mode
	Curve.EditorCurveData.SetKeyInterpMode(h2, ERichCurveInterpMode::RCIM_Cubic);

	//Add the third key
	Curve.EditorCurveData.SetKeyTangentMode(h3, ERichCurveTangentMode::RCTM_Auto);
	//Set the Interpretation Mode
	Curve.EditorCurveData.SetKeyInterpMode(h3, ERichCurveInterpMode::RCIM_Cubic);

	//Add the four key
	Curve.EditorCurveData.SetKeyTangentMode(h4, ERichCurveTangentMode::RCTM_Auto);
	//Set the Interpretation Mode
	Curve.EditorCurveData.SetKeyInterpMode(h4, ERichCurveInterpMode::RCIM_Cubic);

Hi ,

Sorry for my mistake.
I have no questions about this topic.
Thanks.