UnityWebRequest MySQL 教學

Kelvin 老師分享如何架設自已的伺服器,支援 Unity 開發網路連線遊戲。

快速連結 [程式碼] [Dreamweaver資料庫設定] [Hinet架站]

 

玩家資料表 (tb_player)

名稱 類型 說明
player_ID   玩家編號(主索引)
player_name   玩家帳號
player_pass   玩家密碼
player_nickname   玩家暱稱

 

物品資料表 (tb_item)

名稱 類型 說明
item_ID   物品編號(主索引)
item_name   物品名稱
item_description   物品說明
     

 

 

背包資料表 (tb_inventory)

名稱 類型 說明
inventory_ID   (主索引)
player_id   玩家編號
inventory_content    
     

 

 

任務資料表 (tb_quest)

名稱 類型 說明
ID   (主索引)
player_id    
     
     

 

 

排行榜資料表 (tb_leaderboard)

名稱 類型 說明
ID   (主索引)
game_id    
player_id    
player_score    

 

 

連線除錯 - 若出現以下錯誤:

InvalidOperationException: Insecure connection not allowed

UnityEngine.Networking.UnityWebRequest.SendWebRequest ()

 

解決方式如下:開啟 [ Project Settings > Player > Allow downloads over HTTP ] 設定 Always allowed

 

管理 MySQL 資料庫連線,使用 <?php require_once('Connections/Connection.php'); ?>

資料庫連結設定檔案改為外部連結,便於管理。

 

Script-LoginSystem-20231230.png

/dev/