Skip to content

Instantly share code, notes, and snippets.

@su10
su10 / .editorconfig_A
Created August 17, 2022 12:51
.editorconfig file reflecting Rider's default settings (A: without default values, B: with default values)
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = false
insert_final_newline = false
indent_style = space
indent_size = 4
# Microsoft .NET properties
@su10
su10 / ReorderableListEditor.cs
Created October 20, 2020 12:04
Editor that draws all lists/arrays in Unity Inspector as re-orderable by default.
/*
MIT License
Copyright (c) 2018 ANURAG DEVANAPALLY
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@su10
su10 / ParseBigJsonWithUtf8Json.cs
Last active June 6, 2018 15:01
Utf8Jsonでキーを網羅していないクラスで長いJSONをデシリアライズしようとするとNullReferenceExceptionになる例
using UniRx;
using UnityEditor;
using UnityEngine;
using Utf8Json;
public class ParseBigJsonWithUtf8Json : MonoBehaviour
{
public void ParseSmallJson()
{
ObservableWWW.Get("https://public.bitbank.cc/btc_jpy/transactions")
@su10
su10 / CaptureScreenshotFromEditor.cs
Last active November 13, 2017 10:04
【Unity】指定した解像度のスクリーンショットを実機なし・エディタだけで撮る方法【2017.1対応】 ref: https://qiita.com/su10/items/a8f3f825155835de3d2a
using System.Collections;
using UniRx;
using UnityEditor;
using UnityEngine;
/// <summary>
/// Unityエディタ上からGameビューのスクリーンショットを撮るEditor拡張
/// </summary>
public class CaptureScreenshotFromEditor : Editor
{
@su10
su10 / ObservableSocialWorker.cs
Last active July 6, 2017 14:27
【Unity】SocialWorkerをObservableに使うラッパークラスを書いた【UniRx】 ref: http://qiita.com/su10/items/d550d6c31306e8720d03
using SWorker;
using UniRx;
namespace Jagapippi.Social
{
public static class ObservableSocialWorker
{
public static IObservable<Unit> PostTwitterAsync(string message, string url, string imagePath)
{
return Observable.Create<Unit>(observer =>
@su10
su10 / NetworkSpawner.cs
Last active January 26, 2022 07:26
Photonでオブジェクトをスポーンする方法の調査およびIPunPrefabPoolとUniRx.Toolkit.ObjectPoolを使ったオブジェクトプールのサンプル ref: http://qiita.com/su10/items/4bae56bc814c4e6a2bc0
using Photon;
using PhotonRx;
using System.Linq;
using UniRx;
using UniRx.Toolkit;
using UniRx.Triggers;
using UnityEngine;
namespace Jagapippi.Network
{
@su10
su10 / PhotonExtensions.cs
Created May 13, 2017 03:32
【Unity】PhotonNetwork.OnEventCallをAsObservableにする【PhotonRx】 ref: http://qiita.com/su10/items/1b7a792ce9bd90debdb0
namespace UniRx
{
public static class PhotonExtensions
{
public static IObservable<Tuple<byte, object, int>> AsObservable(this PhotonNetwork.EventCallback eventCallback)
{
return Observable.FromEvent<PhotonNetwork.EventCallback, Tuple<byte, object, int>>(
h => (x, y, z) => h(Tuple.Create(x, y, z)),
h => PhotonNetwork.OnEventCall += h,
h => PhotonNetwork.OnEventCall -= h
@su10
su10 / DataBinding1.cs
Last active June 15, 2017 11:03
UniRx入門 ~ データバインディングとUnityイベント関数の購読 ~ ref: http://qiita.com/su10/items/6d7fd792d4b553454a4f
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class DataBindingSample1 : MonoBehaviour
{
// NOTE: newするときに初期値を与えることが可能
public ReactiveProperty<int> _intProperty = new ReactiveProperty<int>(1);
@su10
su10 / WaitForObservable.cs
Last active July 6, 2017 14:40
【Unity】Subscribeしなくても動作してかつSubscribeすることで結果も必ず受け取れるストリームを作る方法【UniRx】 ref: http://qiita.com/su10/items/caffe7877adfab54263c
using System;
using UnityEngine;
using UniRx;
public class WaitForObservable : MonoBehaviour
{
[SerializeField]
private Window _window;
void Start()
@su10
su10 / Drag.cs
Created April 10, 2017 07:54
【Unity】UniRxを使ったドラッグ移動のサンプル【UniRx】 ref: http://qiita.com/su10/items/ae3fd460a5762438a9d1
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UniRx;
using UniRx.Triggers;
public class Drag : MonoBehaviour
{
public RectTransform target;
public bool horizontal = true;