BlockMesh->OnClicked.AddDynamic(this, &APuzzleBlock::BlockClicked); //鼠标点击事件 BlockMesh->OnInputTouchBegin.AddDynamic(this, &APuzzleBlock::OnFingerPressedBlock); //触摸屏点击事件 void APuzzleBlock::BlockClicked(UPrimitiveComponent* ClickedComp) { bIsActive = !bIsActive; // flip the value of bIsActive // (if it was true, it becomes false, or vice versa) if (bIsActive) { BlockMesh->SetMaterial(0, OrangeMaterial); } else { BlockMesh->SetMaterial(0, BlueMaterial); } // Tell the Grid if (OwningGrid != NULL) { OwningGrid->AddScore(); } // --TO HERE-- } void APuzzleBlock::OnFingerPressedBlock(ETouchIndex::Type FingerIndex, UPrimitiveComponent* TouchedComponent) { BlockClicked(TouchedComponent); }