Skip to content

Instantly share code, notes, and snippets.

@mao-test-h
mao-test-h / NativeImageEncoder.mm
Created August 9, 2021 15:45
RenderTexture.GetNativeTexturePtr()からネイティブ側でpngに変換+保存
#import <Metal/Metal.h>
#import <UnityFramework/UnityFramework-Swift.h>
#ifdef __cplusplus
extern "C" {
#endif
// P/Invoke code.
// [DllImport("__Internal", EntryPoint = "encodeToPNG2")]
// static extern string EncodeToPNG(IntPtr nativeTexturePtr, string fileName);
@mao-test-h
mao-test-h / UIScreenBridge.cs
Last active May 7, 2021 20:48
Unity上からiOS端末の画面輝度を取得/設定
using System.Runtime.InteropServices;
using UnityEngine;
namespace iOSNative
{
/// <summary>
/// `UIScreen`のBridge
/// </summary>
/// <remarks>
/// - https://developer.apple.com/documentation/uikit/uiscreen
@mao-test-h
mao-test-h / AVAudioSessionBridge.cs
Last active May 7, 2021 20:26
Unity上からiOS端末のシステムボリュームを取得する
using System.Runtime.InteropServices;
namespace iOSNative
{
/// <summary>
/// `AVAudioSession`のBridge
/// </summary>
/// <remarks>
/// - https://developer.apple.com/documentation/avfaudio/avaudiosession
/// </remarks>
@mao-test-h
mao-test-h / SourceEditorCommand.swift
Created December 10, 2020 20:03
Xcode Source Editor Extensionsを用いてprintメソッドの内容を全てもなふわすい〜とる〜むのURLに変更する為のEditor拡張
import Foundation
import XcodeKit
// このGistでは実装のコア部分である`SourceEditorCommand.swift`のみアップ (実装は適当)
// Xcode Source Editor Extensionsの導入に関しては以下を参照
//
// - Creating a Source Editor Extension
// https://developer.apple.com/documentation/xcodekit/creating_a_source_editor_extension
//
// - Xcode Source Editor Extension を使った Xcode プラグインの作り方
@mao-test-h
mao-test-h / EnableBackgroundAudio.mm
Last active October 1, 2021 18:45
Unity iOSビルドにてオーディオのバックグラウンド再生を行なう
#import <AVFoundation/AVFoundation.h>
@interface EnableBackgroundAudioWrapper : NSObject
+ (void)enableBackgroundAudio;
@end
@implementation EnableBackgroundAudioWrapper
+ (void)enableBackgroundAudio {
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
@mao-test-h
mao-test-h / ProcessInfoBridge.cs
Last active May 7, 2021 20:09
Unity上からiOS端末の発熱状態を取得する
using System.Runtime.InteropServices;
namespace iOSNative
{
/// <summary>
/// `ProcessInfo`のBridge
/// </summary>
/// <remarks>
/// - https://developer.apple.com/documentation/foundation/processinfo
/// </remarks>
@mao-test-h
mao-test-h / FinalSword_LEVELUp_Effect.swift
Created July 19, 2020 22:22
ファイナルソードの「LEVEL Up」演出っぽい挙動をSwiftUIで再現
import SwiftUI
struct ContentView: View {
// Font
let fontSize: CGFloat = 90
// Animation
let startScale: CGFloat = 0.3
let endScale: CGFloat = 1.0
@mao-test-h
mao-test-h / CcacheSettings.cs
Created April 25, 2020 20:54
xcodeprojにccache向けの設定を適用するサンプル
#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
namespace Samples
{
static class CcacheSettings
{
@mao-test-h
mao-test-h / CHANGELOG.md
Created March 26, 2020 13:03
UPM Custom Template

UPM Custom Template

[0.0.1] - 20xx-0x-0x

  • feature
    • sample
  • change
    • sample
  • fix
  • sample
@mao-test-h
mao-test-h / ExportPackage.cs
Created March 4, 2020 12:52
ProjectSettingsを.unitypackage形式で出力
using System;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
namespace EditorUtility
{
static class ExportProjectSettings
{