概要
ネットワークゲームの簡単な動作確認方法書きます
こんな人がよむ
動作確認の度にビルドして実行ファイルを書き出すのが面倒な人
前提
基本的なgitの使い方がわかっている
やり方
流れ
- ローカルマシーンに同様のプロジェクトを2つクローンする
- UnityEditorを2つ開く
- 片方のプロジェクトでコーディングを行う
- 2つのローカルリポジトリを同期させる (準備)
- 2つのローカルリポジトリを同期させる
ローカルマシーンに同様のプロジェクトを2つクローンする
とりあえず該当するプロジェクトをクローンしてきましょう。
今回はテスト用のプロジェクトをクローン。
$ git clone https://github.com/sim-mokomo/LocalGitRepoSyncTest.git
$ git clone https://github.com/sim-mokomo/LocalGitRepoSyncTest.git LocalGitRepoSyncTest2
UnityEditorを2つ開く
無事開けました。
片方の変更がもう一方に反映できていれば満足の結果です。
片方のプロジェクトでコーディングを行う
(LocalGitRepoSyncTest内)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestScript : MonoBehaviour { // Start is called before the first frame update void Start() { Debug.Log("同期できてる!!!"); } // Update is called once per frame void Update() { } }
2つのローカルリポジトリを同期させる (準備)
LocalGitRepoSyncTest
に移動して以下のコマンドをたたきましょう。
remote add
はいつも Github の リポジトリ Url をたたき込んでるかもしれません。
代わりに2つめにクローンしてきたプロジェクトの相対パスを打ち込みます。
これで変更をもう一方のローカルgitリポジトリに適用することができるようになりました。
$ git remote add LocalGitRepoSyncTest2Proj ../LocalGitRepoSyncTest2
$ git remote -v LocalGitRepoSyncTest2Proj ../LocalGitRepoSyncTest2 (fetch) LocalGitRepoSyncTest2Proj ../LocalGitRepoSyncTest2 (push) origin https://github.com/sim-mokomo/LocalGitRepoSyncTest.git (fetch) origin https://github.com/sim-mokomo/LocalGitRepoSyncTest.git (push)
2つのローカルリポジトリを同期させる
準備ができたので早速プッシュしてみます。
$ git add .
$ git commit -m "同期テスト"
$ git push LocalGitRepoSyncTest2Proj master Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 12 threads Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 852 bytes | 426.00 KiB/s, done. Total 5 (delta 1), reused 0 (delta 0) remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: is denied, because it will make the index and work tree inconsistent remote: with what you pushed, and will require 'git reset --hard' to match remote: the work tree to HEAD. remote: remote: You can set the 'receive.denyCurrentBranch' configuration variable remote: to 'ignore' or 'warn' in the remote repository to allow pushing into remote: its current branch; however, this is not recommended unless you remote: arranged to update its work tree to match what you pushed in some remote: other way. remote: remote: To squelch this message and still keep the default behaviour, set remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To ../LocalGitRepoSyncTest2 ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '../LocalGitRepoSyncTest2'
怒られました。
プッシュ先で以下のコマンドをたたくと許されます。
詳細はこちらを見てください。
~/Documents/UnityProjects/LocalGitRepoSyncTest2 (master) $ git config receive.denyCurrentBranch updateInstead
動作確認
宣伝

オンラインゲームのしくみ Unityで覚えるネットワークプログラミング
- 作者: 河田匡稔
- 出版社/メーカー: SBクリエイティブ
- 発売日: 2014/09/06
- メディア: 単行本
- この商品を含むブログを見る

Unityネットワークゲーム開発 実践入門 UNET/ニフティクラウド mobile backend版
- 作者: 西森丈俊,一條貴彰,掌田津耶乃
- 出版社/メーカー: ソシム
- 発売日: 2017/06/19
- メディア: 単行本
- この商品を含むブログを見る