Skip to content

Instantly share code, notes, and snippets.

@baobao
baobao / UnityPlayerActivity.java
Created May 5, 2024 06:16
This UnityPlayerActivity implements Picture in Picture in Unity.
package com.unity3d.player;
import android.app.Activity;
import android.app.PictureInPictureParams;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.util.Rational;
import android.view.KeyEvent;
@baobao
baobao / AndroidManifest.xml
Created May 5, 2024 05:07
This is an AndroidManifest that implements Picture in Picture in Unity.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:glEsVersion="0x00030000" />
<uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
<application android:extractNativeLibs="true">
<meta-data android:name="unity.splash-mode" android:value="0" />
<meta-data android:name="unity.splash-enable" android:value="True" />
@baobao
baobao / PooledDOTween.cs
Last active April 24, 2024 03:20
大量のオブジェクトを何度もTweenさせる場合はSetRecyclable(true)にした方がよいかもと検証したサンプルコード
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
public class PooledDOTween : MonoBehaviour
{
private List<GameObject> objs = new List<GameObject>();
/// <summary>
/// TweenerのPoolフラグ
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Noise2 : MonoBehaviour
{
Shader m_shader;
Material m_mat;
[Range(0,1)]
public float horizonValue;
//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>
//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);
Shader "UI/Mask"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@baobao
baobao / AnimationClipRecoveryEditor.cs
Last active March 18, 2023 16:16
アニメーションクリップを少しリカバリーするEditorスクリプト
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
public class AnimationClipRecoveryEditor : EditorWindow
{
[MenuItem("Tools/AnimationClip Recover")]
static void Init ()
{
; global シンボル名で公開したいシンボルを定義(外部から参照可能になる)
global _main
; DATAセクションの始まりを定義
section .data
; str_helloというラベルを定義(あとから参照できるようにする)
; db 文字列で、指定文字列をASCIIコードに変換して数値として連続して書き込むということを意味する
; db "H","e","l","l","o", " World", 0x0a と記述しても同じ
; 0x0aは改行の意味
@baobao
baobao / Main.cs
Last active February 18, 2022 11:30
イントロ実装SoundManager
using UnityEngine;
using System.Collections;
public class Main : MonoBehaviour
{
public AudioClip clip;
private SoundManager _mng;
void Start ()
{
@baobao
baobao / UIToolkit_MouseDownUpTest.cs
Last active January 29, 2022 08:58
UI Toolkitサンプル:MouseDown・MouseUpショートコード
using UnityEngine;
using UnityEngine.UIElements;
// 解説Qiita記事 : https://qiita.com/ohbashunsuke/items/ae1da96e582aef734eee
[RequireComponent(typeof(UIDocument))]
public class UIToolkit_MouseDownUpTest : MonoBehaviour
{
void OnEnable()
{
var document = GetComponent<UIDocument>();