Entries from 2015-05-01 to 1 month

Touchの扱い

void TouchFingerInput(){ if (Input.touchCount > 0){ Touch touch = Input.touches[0]; // フェイズで管理できる。 switch(touch.phase){ // タッチ開始場所 case TouchPhase.Began: OnStartDrag(touch.position); break; // タッチ終了場所 case TouchPha…

Time.timeScale(ポーズ画面)

// ポーズ画面静止状態にする public void PopPaused(){ GameManager.instance.Play = false; PausedParent.SetActive(true); Time.timeScale = 0; } public void HidePaused(){ GameManager.instance.Play = true; PausedParent.SetActive(false); // 元の…

Touch touch = Input.GetTouch(0);

【Unity 2D】GameObjectにタッチ処理を実装するalbatrus.com Unity - 入力 / Inputpsm.playstation.net

オブジェクトの親子関係(孫要素)

//オブジェクトの孫要素を取得する。 EndScreen.transform.FindChild("ScoreParent").transform.FindChild("Score").GetComponent<Text>().text =""+ (SituationCreater.instance.Count); // わざわざFindChildを使う非有ようがないのであれば、以下でよい。 GameO</text>…

GetComponent<TextMesh>().text

UIでなくて、文字を表示する方法 //public string text ScenePrefabs[Type].transform.FindChild("OddNumberWC").GetComponent<TextMesh>().text = "" + (Count + ScenePrefabs.Length); GameObject上にカウントダウンテキスト表示するにはja.stackoverflow.com Unity</textmesh>…

【Unity】Screen.width : 画面サイズの取得方法

unity_get_screen_size - FreeStyleWiki

CanvasのRender Cameraをスクリプトで変更したい(覚える)

o.transform.FindChild("Canvas").GetComponent<Canvas>().worldCamera = targetCamera; //例2 //メインカメラの最初の名前は、「Main Camera」になっている。 //「MainCamera」に変更しないといけない。 CanvasSituation.GetComponent<Canvas> ().worldCamera = GameObject</canvas></canvas>…

2Dでスワイプ(フリック)を取得する方法

Rayを使って、最初と最後の入力の位置を獲得して、自分でRayを定義してあげる。 (スワイプの取得方法で、他にいい方法があれば教えて欲しいです。) using UnityEngine; using System.Collections; using UnityEngine.UI; public class FlickManager : Mono…

ベクトルの角度

//y軸との角度を取得する。 float angle =Vector2.Angle(new Vector2(0,1),UnitVector); Vector3クラスのメモ - unity学習帳unitylab.wiki.fc2.com

色を使って変化

iTweenを使って、色を変化させる。 iTween.ColorTo(Background_White,iTween.Hash("r",1f, "g",1f, "b",1f, "time",0.5f));

リスト名.Add

リストの要素の追加は、Addを使う。 public List<GameObject> Obj; void Start () { for (int i = 1; i <=NumObj; i++){ Obj.Add(GameObject.Find("Obj"+i)); } } UnityでListを使いたい - Qiitaqiita.com</gameobject>

【フリー素材】背景パターン、音源

音源 BGM素材 – ポケットサウンド – フリー効果音素材・BGMダウンロード G-Sound 全曲無料・フリー音楽素材/魔王魂 Download 100,000 Royalty-Free Music, Sound Effects, and Loops 背景 商用可、オシャレ質感系Photoshopパターン素材を無料公開している「S…

【フリー素材】ゲーム難易度表記

難易度表記の素材満載。 ネット世代の雑評論 ゲームの難易度表記の序列 横文字編。

【Unity ライブラリ】アニメーション関連

1. Draw Shapes for 2D Physics Game https://www.assetstore.unity3d.com/jp/#!/content/17955 デモ Unity Web Player | Draw Shapes for 2D Physic Game 2. Uni2D 一つのスプライトから、アニメーションを作成できる。 https://www.assetstore.unity3d.com…

オブジェクトの生成、UpdateよりCoroutine

Updateでオブジェクト生成のメソッドを書くより、StartCoroutineを使って生成する方が早くなる。(理由は・・・)Coroutineとwhileを使ってオブジェクトを生成する。 using UnityEngine; using System.Collections; public class Interpolator3 : MonoBehavi…

【Unity エラー】CS0126 : コルーチン関連のエラー

error CS0126: An object of a type convertible to `bool' is required for the return statement 文中のreturn;をyield break;に修正すると、エラーがなくなる。hwks.hatenadiary.jp Unityのコルーチンの使い方をまとめてみた - WonderPlanet DEVELOPER BL…

二点間の単位ベクトル

UnitVector = ( Obj2.transform.position - Obj1.transform.position ).normalized; 3D+ Unity 二点間のベクトル3dplus.blog.fc2.com

2点間の距離を取る。

public static float Distance(Vector2 a, Vector2 b); ActionScript入門Wiki - Unity - (Vector3)二点間距離を求める Unity - スクリプティング API: Vector2.Distancedocs.unity3d.com

ScreenToWorldPoint(2D上でお絵描きしたいとき)

2Dでの「Camera.main.ScreenToWorldPoint」の扱いに困った。 これは、「スクリーン座標をワールド座標に変換する関数」であるが、これを2Dで使うたいとき、カメラのプロパティ「Projection」を「Orthographic」(2D用)に設定してあげなければならない。082…

RigidbodyとColliderの干渉

Rigidbodyコンポーネントを持つオブジェクトを、Colliderコンポーネントを持つコンポーネントの上に生成すると、反発する。もし共存させたい場合は、レイヤーを設定して、「PlayerSetting」「Physics」のところで、レイヤーの影響範囲を設定してあげる。

【iOS】レビューをお願いするプラグイン

12px.com github.com

Application.OpenURL()

UntiyでWebページを開きたい時に使う。 public void ShareButton(){ Application.OpenURL("https://www.google.co.jp"); } Unity3D:アプリのレビューページを直接開く - devlog [naru design] Unityアプリからソーシャルメディアと連携する - Qiitaqiita.com…

【Unity エラー】CS0029 : 変数型違いによるエラー

ケース1 エラー内容 error CS0029: Cannot implicitly convert type `UnityEngine.Transform' to `UnityEngine.GameObject' 修正前 public GameObject ClearScreen; GameObject ClearHideButton; public void ClearStage(){ ClearHideButton = ClearScreen.…

シーンを読み込んだ時の初期状態に戻す

再度シーンを読み込むことによって、リロードすることができる。 オブジェクトの初期状態を変数に入れておいて、元に戻すという手間なことをする必要がない。 Application.LoadLevel("Stage1"); Unity C# リロード(初期状態にもどる)的な処理 - Qiitaqiita…

UIはEventSystemがないと動かない

複数のステージを作る際に、Canvasをプレハブで再利用するとき、EventSystemを子にしておく。

transform.SetParent

親を設定する。 cameoChild.transform.SetParent(ListParent.transform);

#if UNITY_IPHONE #endif

Unityでプラットフォームごとに分岐を作る - ことばアルバムis4cafe.hatenablog.com

【Unity ネタ】デザインの美しいゲーム

Dots:「繋ぎ」を追求するゲーム - Google Play の Android アプリ gigazine.net

Splashスクリーンのフェイドアウトの例

using UnityEngine; using System.Collections; using UnityEngine.UI; public class SplashScreenScript : MonoBehaviour { public Image myPanel; float fadeTime = 2f; Color colorToFadeTo; void Start() { colorToFadeTo = new Color (1f, 1f, 1f, 1f);…

PlayerPrefsのデータをすべて消して動作確認

if (Input.GetKeyDown(KeyCode.A)){ PlayerPrefs.DeleteAll(); } Unityで、保存データ全消しのデバッグ用ボタンを配置するblog.k-kansei.com