Entries from 2015-05-01 to 1 month

レベルの管理について(ハイスコアと同じ要領)

レベルの管理ってどうしたらいいのだろう。 以下のスクリプトで管理することはできるが、何かいい方法があれば教えて欲しいです。 using UnityEngine; using System.Collections; public class LevelManager : MonoBehaviour { public int CurrentLevel; pub…

GridLayoutGroup

全て同じ要領で、プロパティを参照することができる。 間違っていると思うときは添付して検索。 float GridSpace = Content.GetComponent<GridLayoutGroup>().spacing.y;</gridlayoutgroup>

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…

面白い、軌跡のオブジェクトを生成

is4cafe.hatenablog.com

Input.mousePosition

マウスで押した場所を取得する。ActionScript入門Wiki - Unity - クリックした位置にオブジェクトを移動させるwww40.atwiki.jp

【Unity プラグイン】pushwoosh : プッシュ通知 (Xcode設定)

PuchwooshのXcodeの設定 以下の設定が必要 1. General imageIO libz 2. Info Pushwoosh_APPID : ID入力 Pushwoosh_SHOW_ALERT : YES Number One Push Notifications Service for Any Possible Product. 1 Service, 21 Platforms プッシュ通知とは? | サービ…

【Unity】rectTransform.localPosition : 使用例

UIコンポーネントの位置は、rectTransformで扱うことができる。 public class CreditController : MonoBehaviour{ public Text CreditMainText; public void PopCredit(){ CreditMainText.rectTransform.localPosition = new Vector3(0f,-200f,0f); } } スク…

【Unity】オブジェクト ドラッグで移動

オフセットの部分は、ベクトルで考えるとわかりやすい。 using UnityEngine; using System.Collections; public class PieceManager : MonoBehaviour { private bool isDrag = false; enum STEP{ NONE = -1, IDLE = 0, DRAGGING, } // 初期状態 private STEP…

Raycast,C#でサンプル

using UnityEngine; using System.Collections; public class CubeManager : MonoBehaviour { public static CubeManager instance = null; void Awake(){ if(instance = null){ instance = this; } } void Update () { if( this.gameObject == GameManager.…

ブログで稼ぐってすごいね。

「ブログで稼ぐ」は現実的か?PV別ブログ収益をざっくり計算blogos.com

Vector3.Distance(A, B) もしくは、(pos1 - pos2).magnitude

A,B間の距離を計算してくれるプロパティ float型で値を返す。 // Bool型のメソッド。メソッドも返り血をBool型することもできる。 private bool is_in_snap_range() { bool ret = false; // ある程度離れていたとしても、trueとする。 if(Vector3.Distance(t…

ray.origin, ray.direction

originプロパティ:開始点 directionプロパティ:方向(単位ベクトル) public bool unproject_mouse_position(out Vector3 world_position, Vector3 mouse_position) { // returnでtrue、falseを返す。 // ret、ローカル変数にする。 bool ret; float depth…

オーディオをサンプルスクリプト

Unity – 効果音(SE)を再生する方法。複数の音を鳴らすサンプルコードも用意しました | increment Logincrement-log.com

【Unity エラー】CS1519 : タイプミスの可能性

error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration 「;」がないとか。 private float step_timer = 0.0f void Update () { }

コンポーネントを取得

コンポーネントを取得するとき、2通りの書き方がある。 public GameObject textlevel_ex; public text textlevel; textlevel = textlevel_ex.GetComponent<Text>(); public void TextLevel(string method){ if(method == "pop"){ ParentChance.SetActive(true); t</text>…

ゲーム理論・読み物

Table of Contents · Game Programming Patterns CASUAL CONNECT EDUCATION

Androidアプリ開発

Android アプリ開発に (UI) UI « Android GitHub - futurice/android-best-practices: Do's and Don'ts for Android development, by Futurice developers GitHub - futurice/ios-good-practices: Good ideas for iOS development, by Futurice developers. …

【Unity エラー】CS1525 : コードに全角スペースなど

コード中に全角のスペースが入っている場合が多い。 (「;」がないとかの可能性もあり) 例1 error CS1525: Unexpected symbol `<internal>' 例2 error CS1525: Unexpected symbol `iTween' IEnumerator ButtonBombUnlockWait(){ yield return new WaitForSeconds(0.</internal>…

シーンが変わってもスコアが初期化されないようにする。

public static int CurrentScore; スコア、ハイスコアの保持(unityC#): おじさんのプログラミングojisan-puroguramu.seesaa.net

ハイスコア

ハイスコアの作成は、Unity公式チュートリアルを参考にした。Unity: 統合ゲーム開発環境japan.unity3d.com using UnityEngine; using System.Collections; using UnityEngine.UI; // プレイ画面でのスコアの表示 public class Score : MonoBehaviour { publi…

WebPlayer、公開どうしたらいい?(解決済)

ChromeのGoogleDriveを使ってURL作成を作成することで解決した。また、ビルドによって生成されたhtmlファイルとunity3dファイルフォルダごとアップロードするのも忘れず。 https://googledrive.com/host/0B60ZL9C7QgodfmxGdFZmN1M5VzlGb1hEd2xwa3BEZ1VuZk1Pa…

【Unity チュートリアル】AR

makers.hatenablog.com

【Unity ネタ】アセット作家になる

アセット作家になろう! ~作ったキャラクターやスクリプトをアセットストアに出品しよう!~ from Takashi Jona www.slideshare.net

【Unity エラー】UnassignedReferenceException : 値が初期化されていない

値が設定されていないことによるエラー。丁寧に調べてみると、その通り値が設定されていない...。 UnassignedReferenceException: The variable CurrentScoreTextGameOver of ScoreGameover has not been assigned. You probably need to assign the Current…

JsonDataはカウントすることができる。

private void LoadAbilityTableFromJSON(string json) { JsonData jresult = JsonMapper.ToObject (json); List<Questions> data = new List<Questions> (); // JsonDataはカウントすることができる。 maxQuestion = jresult.Count; for(int i=0;i</questions></questions>

Resources.Load(“ / ”)

Resourcesにあるアセットは、 Resources.Load(“ファイルを選択”) で呼び出すことが可能である。だから、例えば、AudioClipを呼び出すとき、スクリプトに変数を作って呼び出さずに直接呼び出すこともできる! public void PlayQuestion(){ string assetLocati…