-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinearColorCurveActor.cpp
More file actions
41 lines (28 loc) · 1.18 KB
/
LinearColorCurveActor.cpp
File metadata and controls
41 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Fill out your copyright notice in the Description page of Project Settings.
#include "TimelinePluginDemo.h"
#include "LinearColorCurveActor.h"
void ALinearColorCurveActor::ChangeColor(FLinearColor NewColor)
{
//Dummy code
UMaterialInstanceDynamic* Material = SM->CreateAndSetMaterialInstanceDynamic(0);
Material->SetVectorParameterValue(FName("BaseColor"), NewColor);
}
// Sets default values
ALinearColorCurveActor::ALinearColorCurveActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SM = CreateDefaultSubobject<UStaticMeshComponent>(FName("SM"));
TimelineHandleComp = CreateDefaultSubobject<UTimelineHandleComponent>(FName("TimelineHandleComp"));
}
// Called when the game starts or when spawned
void ALinearColorCurveActor::BeginPlay()
{
Super::BeginPlay();
//Add a curve to play
TimelineHandleComp->AddCurve(LinearColorCurve);
//Bind a function to call in each timeline tick
TimelineHandleComp->OnLinearColorCurveTickFunction.AddDynamic(this, &ALinearColorCurveActor::ChangeColor);
//Play from start and loop
TimelineHandleComp->PlayTimelineFromStart(true);
}