スニペット
ああ〜このリソース、Sceneの寿命に紐付けたいな〜って時ありますよね。 var disposable = Disposable.Create(() => {}); disposable.AddTo(Lifespan.Scene); これを実現するのが以下のコード。 using System; using UnityEngine; using UniRx; using Object…
async/awaitで、特定条件までawaitしつつも毎フレームこれを実行したい!みたいなめっちゃゲームでしか出てこなさそうなことをどう書くと綺麗に書けるか考えている。 とりあえず素直に書くならこう。 var cancellationTokenSource = new CancellationTokenSo…
Testとかのために同期的にAddressableからAssetを読みたい時用。 public static class EditorAddressables { public static AddressableAssetGroup[] GetGroups() { var settings = UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Se…
using UnityEngine; using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; #if UNITY_IOS using System.IO; using Extension; using UnityEditor.iOS.Xcode; #endif public class IosPostprocessBuild : IPostprocessBuildWithR…
ググるとshift_jisに変換してバイト数数えるやつがよく出てくるんですが、 Unity + Android環境だとI18N.dll突っ込まないと動かないらしいので正確じゃないけどそれっぽい動きするやつ。 正確にやりたい人は頑張ってください。 public static class StringUt…
using System.IO; using AkyuiUnity.Editor.Extensions; using Unity.VectorGraphics.Editor; using UnityEditor; using UnityEngine; namespace Sandbox { public static class SvgToPng { public static byte[] Convert(string svg, Vector2Int size) { va…
var fontAsset = AssetDatabase.LoadAssetAtPath<Font>(fontPath); var settings = new TextGenerationSettings { generationExtents = Vector2.zero, textAnchor = TextAnchor.MiddleCenter, alignByGeometry = false, scaleFactor = 1.0f, color = Color.white, </font>…
using System; using Cysharp.Threading.Tasks; using Extensions; using UnityEngine; public class MessageTest : MonoBehaviour { public void Start() => Test().Forget(); private async UniTask Test() { var messageBroker = new TaskMessageBroker()…
UniRxに入っているAsyncMessageBrokerのTaskバージョン using System; using System.Collections.Generic; using Cysharp.Threading.Tasks; namespace Extensions { public interface ITaskMessagePublisher { UniTask PublishAsync<T>(T message); } public in</t>…
var ct: ComplexType = TPath({ pack: [], name: 'Array', params: [TPType(type.toComplexType())] }); fields.push({ pos: pos, name: "value", access: [APublic], kind: FVar(ct, macro []), meta: [{ name: ":s", pos: pos }] }); ついでに、metaつける…
git ls-remote | grep 'hoge' (ブランチ名の一部)でrefsを得る git ls-remote | grep '556dc1c3db16a13a07bd160fb00c5cdda6d89b83' > a.txt hexdump a.txt git push origin --delete $'\xE5\x88\x9D\xE5\x9B\x9E\xE3\x82\xAF\xE3\x83\xAA\xE3\x82\xA2\xE5'
var fixedTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Japan"); var jstNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, fixedTimeZone);