Skip to content

Instantly share code, notes, and snippets.

@hecres
hecres / config.yml
Last active October 24, 2021 03:49
【CircleCI】対象リポジトリのSubmoduleをPullする方法
version: 2.1
executors:
unity:
docker:
- image: gableroux/unity3d:2019.1.14f1
jobs:
build-test:
executor: unity
steps:
- checkout
@hecres
hecres / 20190706_1_2.cs
Last active July 6, 2019 06:17
20190706_1_2.cs
using System;
using System.Linq;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
using Zenject;
public class FsmInjector : MonoBehaviour
@hecres
hecres / 20190706_1_1.cs
Last active July 6, 2019 06:22
20190706_1_1.cs
public class Hoge : FsmStateAction
{
[Inject] private IFuga fuga;
public override void OnEnter()
{
base.OnEnter();
fuga.Piyo();
}
}
@hecres
hecres / Blog20180708_0.cs
Last active July 8, 2018 13:46
Blog20180708_0
public static partial class UnityUIComponentExtensions
{
public static IObservable<string> OnDoneAsObservable(this InputField self)
{
return self.OnEndEditAsObservable()
.Where(_ => TouchScreenKeyboard.isSupported)
.Where(_ => self.touchScreenKeyboard.status == TouchScreenKeyboard.Status.Done)
.Share();
}
@hecres
hecres / link.xml
Last active March 17, 2018 06:18
link.xml
@hecres
hecres / ClassNameGetter.cs
Created March 17, 2018 05:56
Unityで割り当てられているクラスIDからクラス名を取得する処理
using System.Reflection;
using UnityEditor;
public static string GetClassName(int classId)
{
var assembly = Assembly.GetAssembly(typeof(MonoScript));
var unityType = assembly.GetType("UnityEditor.UnityType");
var classObject = unityType.InvokeMember("FindTypeByPresistentTypeID", BindingFlags.InvokeMethod, null, null, new object[] { classId });
if (classObject == null)
{
@hecres
hecres / EditorShortcuts.cs
Created March 14, 2018 12:44
プロジェクト設定、Lighting設定へのショートカットをつくるエディタ拡張
using System;
using System.Collections.Generic;
using System.Linq;
using Hecres.EditorShortcuts.Editor.ProjectSettings;
using Hecres.EditorShortcuts.Editor.RenderSettings;
using UnityEditor;
using UnityEngine;
namespace Hecres.EditorShortcuts.Editor
{
@hecres
hecres / ScreenFitter.cs
Created March 4, 2018 12:22
オブジェクトサイズ=画面サイズとするフィッター処理
private void FillScreen()
{
// orthographicSizeはカメラの垂直サイズの半分です。
var worldHeight = targetCamera.orthographicSize * 2f;
var worldWidth = worldHeight / Screen.height * Screen.width;
transform.localScale = new Vector3(worldWidth, worldHeight);
var tempPosition = Camera.main.transform.position;
tempPosition.z = 0f;
transform.position = tempPosition;
@hecres
hecres / Rethrow.cs
Created March 3, 2018 10:32
ExceptionDispatchInfoによる例外の再スロー処理
using System;
using System.Runtime.ExceptionServices;
public void Rethrow(Exception exception)
{
ExceptionDispatchInfo.Capture(exception).Throw();
}
@hecres
hecres / UniRxRethrow.cs
Last active March 3, 2018 11:01
UniRxへのExceptionDispatchInfo導入
// メソッドの場合
public void OnError(Exception error)
{
ExceptionDispatchInfo.Capture(error).Throw();
}
// Actionデリゲートの場合
public static readonly Action<Exception> Throw = ex => { ExceptionDispatchInfo.Capture(ex).Throw(); };
public static readonly Action<Exception, T> Throw = (ex, _) => { ExceptionDispatchInfo.Capture(ex).Throw(); };
public static readonly Action<Exception, T1, T2> Throw = (ex, _, __) => { ExceptionDispatchInfo.Capture(ex).Throw(); };