2015-01-01から1年間の記事一覧
以下の様なEnumあるとする。 public enum HogeType { None, Bar, } Enumの中身展開 foreach(var val in System.Enum.GetValues(typeof(HogeType))) { Debug.Log("Value: " + val); } Objectになってしまうので、varは目的のEnum型に foreach(HogeType val in…
小数(浮動小数点数型)の計算が思った結果にならない理由と解決法: .NET Tips: C#, VB.NET if(0.1f + 0.2f == 0.3f) { Debug.Log("ok"); } 一応ok ・17桁表示 Debug.Log((0.1f).ToString("G17")); 0.100000001 Debug.Log((0.2f).ToString("G17")); 0.200000…
stackoverflow.com オブジェクトで比較するからDistinct()だと同じやつもそのまま別物扱い。 Distinctを拡張してやるのもいいかもしれないが・・。 GroupByがよさ気。 c# - Linq Distinct on a particular Property - Stack Overflow なんかGroupByのいち位…
101 LINQ Samples in C# LINQのサンプル
https://kenjin.unity3d.jp/events/show/307 開演、Unity Technologies Japan 大前広樹登壇 サバイバルシューター https://unity3d.com/jp/learn/tutorials/projects/survival-shooter-project ライトとかも入っている。 ・ビルド(Development Build) アセ…
Hogeクラスは何の変哲もないMonoBehaviorの継承でもないふつーのクラス。 シリアライズのため[System.Serializable] [System.Serializable] class Hoge { string bar; } そしてInsppectorを表示していたクラス public class MyMono : MonoBehaviour { [Seria…
どうしてもEditorのOnEnabledが遅くて、普通のMonoBahaviorのAwake()より遅くて困った。 [InitializeOnLoad] //これをつけるとstaticなコストラクタを定義すると呼ばれる. public class Test : Editor // 別にEditorの小クラスでなくても`InitializeOnLoad`…
Compiler Error CS1673 コード抜粋 // Try assigning to a local variable // S s = this; ←こうしろ MyDelegate d = delegate() { i = this.member; // CS1673 エラー // And use the local variable instead of "this" // i = s.member; return i; ここでC…
React.js Advent Calendar 2015 - Qiita カノジョできないエンジニア Advent Calendar 2015 - Qiita すきなことをしよう(仮) Advent Calendar 2015 - Qiita
yield キーワード yield return n; とした。 foreach(object n in GetIterator()) { Debug.Log(n); } ちゃんと数字返るっぽい
IL2CPPに関する軽い話 from Wooram Yang www.slideshare.net 中間言語(Intermediate Language)をC++(CPP)に変換
万年素人なので分からなかった。 Storyboad(ストーリーボード)のメニューが消えた。 UnityのInspector(インスペクタ)的なやつ。 どこにあるのか? Inspectorで検索してみた。 「Show Identity Inspector」だった。 こいつは「Identity Inspector(アイデ…
Activity Monitor で確認してみる。 CPU使用率が100%とかではない。 「Slow Animations」がONになっていた! ショートカットは command + [T]
for me in 3...4 { print(me) } 3 4 最後の数字は含む
2の4乗したい。 2 ^ 4 でもなく pow(2, 4) infix operator ^^ { } func ^^ (radix: Int, power: Int) -> Int { return Int(pow(Double(radix), Double(power))) } こうすれば 2 ^^ 4
let str1 = "9876" let index = 3 Int(str1[str1.startIndex.advancedBy(index)..
たまたまListの変数に対して.打つとかってにコードのサジェスチョンが出たので調べた。 日本語のブログ出たけどわかりにくいから今度まとめる。 【参考】 qiita.com Linq入門記-40 (LINQ To Object, Aggregate) - いろいろ備忘録日記 ameblo.jp 【単語の意味…
c# - Cast object to T - Stack Overflow private static T ReadData<T>(XmlReader reader, string value) { reader.MoveToAttribute(value); object readData = reader.ReadContentAsObject(); return (T)readData; } このときにreadDataをTにキャスト不可能。</t>…
Enum.GetNames(typeof(ここにenumの型)).Length
intValueやstringValueがあるのに int配列 public static int[] ToIntArrayValue(this UnityEditor.SerializedProperty aProperty) { int size = aProperty.arraySize; var arr = new int[size]; for(int i=0;i
www.dailycoding.com
いつもと違うキーの名前にしたせい? 僕が作ったSSHの秘密鍵はpersonalidの名前だった。 以下 > git push origin master master [9189f99] Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the co…
invoke a method from a Unity Inspector カスタムアトリビュートを作る? using System; // Place this file in any folder that is or is a descendant of a folder named "Scripts" namespace CatchCo { // Restrict to methods only [AttributeUsage(Att…
https://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/property-drawers-custom-inspectors UnityScriptもなんかある http://answers.unity3d.com/questions/39360/how-to-get-to-the-editor-to-display-a-childs-world.html
プレースホルダでカッコを使いたい時。 c# - How to escape braces (curly brackets) in a format string in .NET - Stack Overflow {を2つにする。
> pod install master untracked Updating local specs repositories Analyzing dependencies Downloading dependencies Using Realm (0.95.0) Using RealmSwift (0.95.0) Generating Pods project Integrating client project Sending stats Pod installati…
RGBの(255, 255, 255)みたいなのを6桁の16進数数字のカラーコードFFFFFFにしたい。 ※'#‘はいらない。 RGB値からHTMLカラーコードに変換する:humming bird を参考。 拡張メソッド // Slice. public static string Slice(this string aString, int num) { retu…
何故か出ない。 One of my scripts has no check-box next to it in Inspector - Unity Answers Your MonoBehaviour won't have a checkbox next to it in the inspector if it doesn't have any of the per-frame methods, like Update, FixedUpdate, OnGUI…
デフォルト引数(別名:省略可能な引数、オプション引数(optional parameter))を使って、 デリゲートすると変な現象。 まず、このようなデフォルト引数のあるメソッド void Hoge(int fooInt, bool barBool=false, int fugaInt=0) { Debug.LogError(fooInt…
#if UNITY_EDITOR みたいなやつをプリプロセッサーディレクティブと言うと思う。 publicな定義を作りたい。 Global Conditional Compilation with Unity3D Assets/smcs.rsp の中に -define:LITE と書いてやれば グローバルのカスタム define シンボルになる…