[DataContract]
public class Hoge
{
[DataMember(Order = 0)]
public int MyProperty1 { get; set; }
}
[DataContract]
public class HogeHoge : Hoge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DictionaryDisposable<TKey, TValue> : IDisposable, IDictionary<TKey, TValue> | |
where TValue : IDisposable | |
{ | |
bool isDisposed = false; | |
readonly Dictionary<TKey, TValue> inner; | |
public DictionaryDisposable() | |
{ | |
inner = new Dictionary<TKey, TValue>(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UniRx; | |
public class MyBehaviour : MonoBehaviour | |
{ | |
void Start() | |
{ | |
// https://github.com/jbevain/cecil/issues/241 | |
// https://github.com/saynomoo/unetweaver_error | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DictionaryPerfomanceExtensions | |
{ | |
public static void ToDictionaryBatching<T, TKey1>(this T[] array, | |
Func<T, TKey1> keySelector1, out Dictionary<TKey1, T> dictionary1 | |
) | |
{ | |
dictionary1 = new Dictionary<TKey1, T>(array.Length); | |
for (int i = 0; i < array.Length; i++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Hoge | |
{ | |
public Action<int, string> onSomethingWithArgs2; | |
public void Hoge2() | |
{ | |
var source = Observable.FromEvent<Action<int, string>, Tuple<int, string>>( | |
h => (x, y) => h(Tuple.Create(x, y)), | |
h => onSomethingWithArgs2 += h, | |
h => onSomethingWithArgs2 -= h); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task ThraedingError() | |
{ | |
Debug.Log($"Start ThreadId:{Thread.CurrentThread.ManagedThreadId}"); | |
await Task.Delay(TimeSpan.FromMilliseconds(300)); | |
Debug.Log($"From another thread, can't touch transform position. ThreadId:{Thread.CurrentThread.ManagedThreadId}"); | |
Debug.Log(this.transform.position); // exception | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task UseUniRxInBackground() | |
{ | |
Debug.Log($"Start ThreadId:{ Thread.CurrentThread.ManagedThreadId}"); | |
await Task.Delay(TimeSpan.FromMilliseconds(300)); | |
Debug.Log($"From same thread, because UniRx installs UniRxSynchronizationContext.ThreadId:{ Thread.CurrentThread.ManagedThreadId}"); | |
Debug.Log(this.transform.position); // show transform | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task CoroutineBridge() | |
{ | |
Debug.Log("start www await"); | |
var www = await new WWW("https://unity3d.com"); | |
Debug.Log(www.text); | |
await CustomCoroutine(); | |
Debug.Log("await after 3 seconds"); | |
} | |
IEnumerator CustomCoroutine() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task AwaitObservable() | |
{ | |
Debug.Log("start await observable"); | |
await Observable.NextFrame(); // like yield return null | |
await Observable.TimerFrame(5); // await 5 frame | |
try | |
{ | |
// ObservableWWW promote exception when await(difference in await WWW) | |
var result = await ObservableWWW.Get("https://404.com"); | |
Debug.Log(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MsgPack.Serialization; | |
using ProtoBuf; | |
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using ZeroFormatter; | |
// スーパー雑雑クラス。 | |
[ZeroFormattable] |