- 投稿日:2019-04-03T20:47:44+09:00
Unity カードゲームのフェーズ管理
解説動画
https://youtu.be/R8nrvf8ZiYAGameMaster.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class GameMaster : MonoBehaviour { enum Phase{ INIT, DRAW, STANDBY, BATTLE, END, }; Phase phase; void Start () { phase = Phase.INIT; } void Update () { switch(phase){ case Phase.INIT: InitPhase(); break; case Phase.DRAW: DrawPhase(); break; case Phase.STANDBY: StandbyPhase(); break; case Phase.BATTLE: BattlePhase(); break; case Phase.END: EndPhase(); break; } } void InitPhase(){ Debug.Log("InitPhase"); phase = Phase.DRAW; } void DrawPhase(){ Debug.Log("DrawPhase"); phase = Phase.STANDBY; } void StandbyPhase(){ Debug.Log("StandbyPhase"); phase = Phase.BATTLE; } void BattlePhase(){ Debug.Log("BattlePhase"); phase = Phase.END; } void EndPhase(){ Debug.Log("EndPhase"); phase = Phase.DRAW; } }
- 投稿日:2019-04-03T19:45:41+09:00
Unity カードの移動方法
解説動画
https://youtu.be/cXZN1lNZDKMPlayer.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public Hand hand; public Field field; public void PushSettingCardOnFieldFromHand(){ Card card = hand.Pull(0); field.Add(card); } }Field.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class Field : MonoBehaviour { public List<Card> cardList = new List<Card>(); public void Add(Card _card){ _card.transform.SetParent(this.transform); cardList.Add(_card); } public Card Pull(int _position){ Card card = cardList[_position]; cardList.Remove(card); return card; } }Hand.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class Hand : MonoBehaviour { public GameObject cardPrefab; public List<Card> cardList = new List<Card>(); void Awake () { for(int i=0; i<5 ; i++){ GameObject cardObj = Instantiate(cardPrefab); Card card = cardObj.GetComponent<Card>(); this.Add(card); } } void Add(Card _card){ _card.transform.SetParent(this.transform); cardList.Add(_card); } public Card Pull(int _position){ Card card = cardList[_position]; cardList.Remove(card); return card; } }Card.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class Card : MonoBehaviour { }
- 投稿日:2019-04-03T18:44:35+09:00
Unity カードの生成と反映方法
解説動画
https://youtu.be/1zjcvax7NugCard.csusing System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Card : MonoBehaviour { public Text hpText; int hp; string name; public void Load(CardData _cardData){ hp = _cardData.hp; hpText.text = hp.ToString(); name = _cardData.name; } }CardGenerater.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class CardGenerater : MonoBehaviour { public GameObject cardPrefab; public GameObject hand; // Use this for initialization List<CardData> cardDataList = new List<CardData>(){ new CardData(1, "スタジオしまづ", 1), new CardData(2, "マリオネットAI", 10), new CardData(3, "コマンドクラフト", 5), }; void Start () { for(int i=0; i<cardDataList.Count; i++){ GameObject cardObj = Instantiate(cardPrefab); cardObj.name = cardDataList[i].name; cardObj.transform.SetParent(hand.transform); Card card = cardObj.GetComponent<Card>(); card.Load(cardDataList[i]); } } }CardData.csusing System.Collections; using System.Collections.Generic; using UnityEngine; public class CardData { public int id; public string name; public int hp; public CardData(int _id, string _name, int _hp){ id = _id; name = _name; hp = _hp; } }
- 投稿日:2019-04-03T11:40:26+09:00
Unity(Windows)+Xcode(MacBook)での環境設定メモ
UnityでiPhoneアプリを作ろうとしたときに環境設定でいくつかはまったので、
個人的備忘録としてメモしておきます。インストール等
目的
開発環境はWindows。
コンパイルだけサブPCのMacBookで行う。開発環境
- Windows PC + Unity 2018.3.11f1
- MacBook(OS10.14.4) + Xcode Ver10.2
- iPhone XS Max
遭遇したトラブルと対処
1) UnityのBuild SettingでiOSやAndroidを選択できない
正常なら上記のような画面になるはずが、特にチェックボックス等がなく「あなたのlicenseではこの機能は使えません」的なメッセージだけが出ている(エラー文メモし損ねました…)対処法:Help > Manage License からアカウントを登録する
通常は初回起動時にユーザー登録画面が出るはずなんですが、これをスキップしたのかそれともだいぶ以前に一度インストールしたデータが残っていたためか上記事象になりました
個人用の無料プランでもiOSやAndroidのBuildは出来るはずなのに何故と無駄にはまることに。2) "Unity-iPhone" requires a provisioning profile
1.Unity側でプロジェクトをBuild
2.Build結果保存先にある「Unity-iPhone.xcodeproj」をXcodeで開く
3.コンパイル
が基本的な流れ。コンパイル時に出たエラーが上記対処法:プロジェクト設定のGeneral > Signing > Automaticall manage signingにチェックを入れ、Teamの欄にアカウントを設定する
※Team欄から何も選択できない場合は、適当にXcode初期設定の仕方をぐぐる3) "Command PhaseScriptExecution failed with a nonzero exit code"
2)と同じくXcodeコンパイル時に出るエラー。
詳細を見ると"/User/~~/MapFileParser.sh:Permission denied」と出ている。
対処法:WindowsからMacにビルド結果をコピーする際、./MapFileParser.shに実行権限を付与する