Skip to content

Instantly share code, notes, and snippets.

mao-test-h

Block or report user

Report or block mao-test-h

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mao-test-h
mao-test-h / CompileTime.cs
Last active Jan 4, 2020
コンパイル時間計測 (Unity2018/2019対応版)
View CompileTime.cs
// referred to:
// http://baba-s.hatenablog.com/entry/2019/05/22/084000
// https://forum.unity.com/threads/editorapplication-iscompiling-is-always-false.770126/
using UnityEngine;
using UnityEditor;
#if UNITY_2019_1_OR_NEWER
using UnityEditor.Compilation;
#endif
@mao-test-h
mao-test-h / MonafuwaUtility.cs
Created Dec 9, 2019
Unityのタイトルバーを「もなふわすい~とる~む」に設定出来るEditor拡張(Windows限定)
View MonafuwaUtility.cs
#if UNITY_EDITOR_WIN
using System;
using System.Runtime.InteropServices;
using System.Text;
using UnityEditor;
namespace MonafuwaUtility
{
static class MonafuwaSweetRoomEditor
{
@mao-test-h
mao-test-h / EndianConverter.cs
Created Dec 7, 2019
エンディアン変換
View EndianConverter.cs
// refered to:
// - https://takachan.hatenablog.com/entry/2018/03/10/020555
using System;
namespace Utility
{
internal static class EndianConverter
{
public static char Reverse(char value) => (char)Reverse((ushort)value);
@mao-test-h
mao-test-h / CheckDarkMode.cs
Created Nov 3, 2019
Unity上でDarkMode判定
View CheckDarkMode.cs
using System.Runtime.InteropServices;
namespace iOSNative
{
public static class CheckDarkMode
{
[DllImport("__Internal")]
static extern bool check_dark_mode();
public static bool IsDarkMode()
@mao-test-h
mao-test-h / NativeUtility.cs
Created Sep 15, 2019
ポインタをNativeArrayに変換
View NativeUtility.cs
namespace Unity.Collections.LowLevel.Unsafe
{
public static unsafe class NativeUtility
{
public static NativeArray<T> PtrToNativeArray<T>(T* ptr, int length)
where T : unmanaged
{
var arr = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>(ptr, length, Allocator.Invalid);
// これをやらないとNativeArrayのインデクサアクセス時に死ぬ
@mao-test-h
mao-test-h / Native2DArray.cs
Last active Aug 12, 2019
Unityでのネイティブメモリ確保用のラッパー
View Native2DArray.cs
using System;
using System.Runtime.InteropServices;
using Unity.Collections.LowLevel.Unsafe;
namespace Unity.Collections
{
/// <summary>
/// ネイティブメモリでの2次元配列のメモリ確保用ラッパー
/// </summary>
[NativeContainer]
@mao-test-h
mao-test-h / InsertDefault.cs
Last active Mar 29, 2019
[SerializeField] private 変数にdefault代入してくれる君
View InsertDefault.cs
// Unity2018.3からprivateな[SerializeField]が初期化しないと警告吐くようになってきたので、
// 各CSソースを解析して一括で"= default;"を付ける奴。
// ※ sedコマンドとかでも出来なくは無いが..改行や既存の代入などを踏まえるとこっちの方が早かった。
namespace Tools // HACK: 適当なので都合に合わせて命名
{
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
@mao-test-h
mao-test-h / NativeObject.cs
Created Feb 23, 2019
少し保守的にしてみたネイティブメモリ側に作るオブジェクト。(ぶっちゃけ長さが1のNativeArrayと変わらない)
View NativeObject.cs
namespace LowLevel.Unsafe
{
using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
public unsafe struct NativeObject<T> : IDisposable
where T : unmanaged
{
[NativeDisableUnsafePtrRestriction] readonly T* _buffer;
@mao-test-h
mao-test-h / ProgressBarDrawer.cs
Created Feb 21, 2019
Inspectorにプログレスバーを表示する奴のサンプル
View ProgressBarDrawer.cs
// usage:
// [SerializeField] [ProgressBar] float _sample;
// [SerializeField] [ProgressBar("hoge")] float _sample;
// [SerializeField] [ProgressBar(0f, 1f)] float _sample;
// [SerializeField] [ProgressBar(0f, 1f, "hoge")] float _sample;
namespace Sample
{
using System;
using UnityEngine;
@mao-test-h
mao-test-h / Dokaben-Sprite-Default.shader
Created Oct 29, 2018
ドカベンロゴアニメーションシェーダー(書き直し版)
View Dokaben-Sprite-Default.shader
Shader "Custom/Sprites/Dokaben"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
[HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
You can’t perform that action at this time.