Entries from 2015-05-13 to 1 day

Canvas Scaler

UIを使うとき、「Canvas Scaler」を「scale with screen size」に設定するようにする。

オブジェクト.active

オブジェクトがアクティブか非アクティブをbool型のtrue・falseで返す。 public void HomeButton(){ // ホーム画面に戻る操作。 Application.LoadLevel("Home"); play = false; if(ClearScreen.active = true){ ClearScreen.SetActive(false); } } Unityゲー…

Sceneでオブジェクトが消えないようにする。

シーンを切り替えても、オブジェクトが消えないようにする。 using UnityEngine; using System.Collections; public class GameManager : MonoBehaviour { void Awake(){ DontDestroyOnLoad(this.gameObject); } } Unity - Scene切替時でもGameObject等を破…

hit.transform.gameObject.layer

RaycastHit2Dのlayerを参照したい。 hit. transform. gameObject. layer http://docs.unity3d.com/ja/current/ScriptReference/RaycastHit2D.html 公式のページから、RaycastHit2Dは、 transformのプロパティを持っていることわかる。 transformからgameObje…

Physics2D.Raycast

3D用の当たり判定は2D用では使えない。 コードを2Dように書く必要がある。2D用、例1 using UnityEngine; using System.Collections; public class ObjectManager3 : MonoBehaviour { public GameObject Prefab; void Start () { } void Update () { if(Inp…