2015-01-01から1年間の記事一覧
ソースコード 使い方 AssertUtils.IsNullFormat( nullObj, "{0}", "メッセージ" ); AssertUtils.IsNotNullFormat( notNullObj, "{0}", "メッセージ" ); AssertUtils.IsTrueFormat( true, "{0}", "メッセージ" ); AssertUtils.IsFalseFormat( false, "{0}", "…
ソースコード 使い方 nullObj .MustBeNullFormat( "{0}", "メッセージ" ); notNullObj .MustNotBeNullFormat( "{0}", "メッセージ" ); canJump .MustBeTrueFormat( "{0}", "メッセージ" ); isDead .MustBeFalseFormat( "{0}", "メッセージ" ); health .MustB…
ソースコード public static class MathfUtils { public static int Wrap( int value, int min, int max ) { int n = ( value - min ) % ( max - min ); return n >= 0 ? n + min : n + max; } } 使い方 MathfUtils.Wrap( 0, 0, 3 ) // 0 MathfUtils.Wrap( 1…
ソースコード using System.Collections.Generic; public static class IListExtensions { public static bool IsEmpty<T>( this IList<T> self ) { return self.Count == 0; } } 使い方 var x = new int[ 0 ]; var y = new int[ 1 ]; x.IsEmpty(); // True y.IsEm</t></t>…
概要 var x = new List<int>(); var y = new Dictionary<int, string>(); print( x.GetType().ToString() ); // System.Collections.Generic.List`1[System.Int32] print( y.GetType().ToString() ); // System.Collections.Generic.Dictionary`2[System.Int32,System.String] </int,></int>…
概要 var x = new List<int>(); var y = new Dictionary<int, string>(); print( x.GetType().Name ); // List`1 print( y.GetType().Name ); // Dictionary`2 型情報をType.GetType()で取得して Type.Nameを参照することで 型の名前を表す文字列が取得可能ですが、ジェネリッ</int,></int>…
概要 // コンポーネントからBoxColliderを取得する // コンポーネントがnullの場合は何もしない BoxCollider result = null; if ( com != null ) { result = com.GetComponent<BoxCollider>(); } 下記の拡張メソッドを使用することで Component型のインスタンスの上記のよ</boxcollider>…
概要 // ゲームオブジェクトをアクティブにする // ゲームオブジェクトがnullの場合は何もしない if ( go != null ) { go.SetActive( true ); } // ゲームオブジェクトからBoxColliderを取得する // ゲームオブジェクトがnullの場合は何もしない BoxCollider…
Destroy may not be called from edit mode! Use DestroyImmediate instead. Also think twice if you really want to destroy something in edit mode. Since this will destroy objects permanently. エディタ拡張の処理でGameObject.Destroyを呼び出すと…
The same field name is serialized multiple times in the class or its parent class. This is not supported: -> AAAA(MonoBehaviour) BBBB(CCCC) DDDD 基底クラスと派生クラスで同名のフィールドをシリアライズ可能にした場合 上記のエラーが発生します …
Unity を 4.5.5 から 4.6.6 にアップデートして iOS ビルドを行ったところ 実機で 3D モデルの表示が紫色になる不具合に遭遇 Player Settings を開いて「Graphics API」を「Open GL ES 2.0」に変更したところ 実機で 3D モデルが正常に表示された 4.6.6 にア…
ソースコード 使い方 AssertUtils.IsNull( obj1, obj2 ); AssertUtils.IsNull( obj1, obj2, obj3 ); AssertUtils.IsNull( obj1, obj2, obj3, obj4 ); AssertUtils.IsNull( obj1, obj2, "null ではないオブジェクトが存在します" ); AssertUtils.IsNull( obj1…
ソースコード using System; using System.Collections.Generic; public static class IEnumerableExtensions { public static bool None<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate ) { foreach ( var n in source ) { if ( predicate( n ) ) { return fals</tsource,></tsource></tsource>…
ソースコード public static class StringUtils { private const string PASSWORD_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz"; public static string GeneratePassword( int length ) { var sb = new System.Text.StringBuilder( length ); var r = ne…
using UnityEngine; public class Player : MonoBehaviour { private int mValue = Random.Range( 0, 10 ); } このように変数初期化子でRandom.Range関数を使用すると 下記のようなエラーが発生します RandomRangeInt can only be called from the main thre…
概要 Tupleクラスは .NET Framework 4.0 から追加されたため .NET Framework 3.5 までの機能しか使えないUnityでは使用できません そのため、Unity でTupleを使用したい場合は 自前で実装する必要がありますが 個人的には Gist で公開されている下記のソース…
ソースコード 使い方 var character = gameObject.GetComponent<Character>(); // 従来の方法 GameObject.Destroy( character ); // 拡張メソッドの方法 character.Destroy(); 関連記事</character>
Asset Store 概要 クラッシュ・オブ・クランのような街作りゲームのスターターキット クラッシュ・オブ・クラン (Clash of Clans)Supercellゲーム無料 公式サイト http://www.citybuildingkit.com/ パッケージ種別 サンプルアプリ シティービルダー https://…
期待した処理が呼び出されない Action onLog = null; Action onClick = null; onClick += onLog; onLog += () => Debug.Log( "ピカチュウ" ); onClick(); Debug.Log( "ピカチュウ" )は呼び出されない onClickにonLogを登録したタイミングでonLogはnullのため…
using UnityEngine; public class Player : MonoBehaviour { public Enemy mEnemy; } using UnityEngine; public class Enemy : MonoBehaviour { } 例えば上記のようなスクリプトが存在して それぞれをゲームオブジェクトにアタッチして参照を設定していたと…
can't be loaded because it was not built with the right version or build target Android版のアプリでiOS版のアセットバンドルをダウンロードしようとしたり、 iOS版のアプリでAndroid版のアセットバンドルをダウンロードしようとするなど、 間違ったプ…
方法 ※Pythonのインストールが必要です 「https://github.com/gered/extractunitypackage」にアクセスする 「Download ZIP」を選択する ダウンロードした「extractunitypackage-master.zip」を展開する 「extractunitypackage.py」を使用して.unitypackageを…
using UnityEditor; using UnityEngine; public class ExampleClass { [MenuItem( "Tools/Example" )] static void Example() { var dirList = new [] { "Assets/Scenes", }; EditorUtils.ApplyToScenesByDirectoryList( dirList, c => { Debug.Log( c ); } …
概要 dirList配列に対象のシーンファイルが格納されている ディレクトリのパスを記述する TODOコメントの場所に一括で行いたい処理を記述する 関連記事
iOSにおいて、開発しているゲームの3D表示が真っ黒になる不具合に遭遇したので 解決方法を書き残しておきます Unityのバージョン:4.6.5p4 「File>Build Settings...」を選択 「Platform」で「iOS」を選択 「Player Settings...」を選択 「Dynamic Batching…
Receiving unhandled NULL exception Launching bug reporter UnityをJenkinsで自動ビルドできるようにしてゲーム開発していたところ Unityのバッチビルド中にクラッシュして上記のエラーが発生する問題に遭遇しました 原因としては、InitializeOnLoadMethod…
https://atnd.org/events/65467 「第32回代々木Unity勉強会」で エディタ拡張について発表させていただきました 発表資料をSlideShareに公開したので共有します 資料内容 エディタ拡張の基本 Hierarchy ビューの拡張 Project ビューの拡張 Scene ビューの拡…
概要 下記の条件下における GC Alloc を調査 0 から 1 の値を 1 秒間繰り返し変化させる処理を登録 毎フレーム呼び出されるコールバック関数を登録 iTween using UnityEngine; public class ExampleClass : MonoBehaviour { private float mValue; void Awak…
概要 関連記事
概要 関連記事