發表文章

目前顯示的是 12月, 2018的文章

Create UE4 project and packaged to HTML5

圖片
Create your UE4 project Compress settings for HTML5 -------------------------------------------------- Project Settings -> Platforms - HTML5 ->  tick 'Packaging.Compress files during shipping packaging' Project Settings -> Project - Packaging ->  tick 'Packaging.Create compressed cooked packages'  add your maps to 'Packaging.List of maps to include in a packaged build' // 000webhost limit a file size to 128 MB max -------------------------------------------------- Upload files to '000webhost' -------------------------------------------------- 000webhost https://www.000webhost.com/ follow packaged folder HTML/Readme.txt upload required files  In this case :  index.html (rename)  SideScroller.data.jsgz  SideScroller.datagz  UE4Game-HTML5-Shipping.js.symbolsgz  UE4Game-HTML5-Shipping.jsgz  UE4Game-HTML5-Shipping.wasmgz  Utility.jsgz // UE4.21 update add upload files :  .htaccess  <project>.UE4.jsgz --------

TCP Socket send&recv 範例摘錄 (Server:C++ App, Client:UE4)

[UE4] TCP Socket 傳輸實現

程式碼 需要注意的地方 記得在Build.cs添加Sockets, Networking TcpClient.h virtual bool SocketReceive(); //這裡添加virtual關鍵字是為了未來覆載此方法來實現從封包中拆解出自訂的資料格式 TcpClient.cpp 可在ATcpClient::ATcpClient() {...}建構函式中給予資料成員一個初始值,避免資料異常 若你想同步變數 ATcpClient::ATcpClient() {  bReplicates = true; // 啟用同步  } // Replicate void ATcpClient::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const {   Super::GetLifetimeReplicatedProps(OutLifetimeProps);   DOREPLIFETIME(ATcpClient, Tcp_UpdateRate); // 你想同步的變數 } 在UE4停止運作時,確保有刪除Thread與關閉Socket void ATcpClient::EndPlay(const EEndPlayReason::Type EndPlayReason) {   if (m_RecvThread != nullptr)   {    m_RecvThread->Kill(true);    delete m_RecvThread;   }   if (Socket)   {    Socket->Close();    ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(Socket);   }   Super::EndPlay(EndPlayReason); } Byte to String & Byte to float // Byte to String FString(ANSI_TO_TCHAR(r