Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using System.Collections.Generic;
public class EventReceiverSample : MonoBehaviour
{
public enum AnimType {
TYPE_1, TYPE_2, TYPE_3
}
/// <summary>【実行可能】引数の無い関数</summary>
@baobao
baobao / ReflectionSample.cs
Last active March 6, 2025 12:23
【Unity】開発の幅が広がるC#のリフレクション入門のサンプルコード
using UnityEngine;
namespace info.shibuya24
{
internal class ReflectionSample : ParentReflectionSample
{
public static int StaticPublicField = 1;
private static int StaticPrivateField = 2;
internal static int StaticInternalField = 3;
protected static int StaticProtectedField = 4;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Profiling;
public enum TransformAccessType
{
transformAccess,
GetComponentAccess,
CachedTransform,
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class SampleQRReader : MonoBehaviour
{
private string _result = "";
private WebCamTexture _webCam;
void Awake()
using UnityEngine;
using ZXing;
using ZXing.QrCode;
/// <summary>
/// QRコードの作成と読み込みヘルパークラス
/// </summary>
public static class QRCodeHelper
{
/// <summary>
using UnityEngine;
using UnityEditor;
using System.IO;
/// <summary>
/// QRコード作成EditorWindow
/// </summary>
public class CreateQRCodeWindow : EditorWindow
{
private enum QRImageSize
// OSC送信インスタンス
OSCSender m_sender;
public Slider slider;
void Start ()
{
m_sender = new OSCSender ();
// 送信クライアント名のセット、IPアドレス、ポート番号は適宜調整
// このIPアドレスとポート番号は受信側のIPアドレスとポート番号です
m_sender.Init ("TestClient", 8890, IPAddress.Parse ("192.168.3.11"));
@baobao
baobao / PropertyToIdPerformance.cs
Last active March 2, 2025 01:50
シェーダーを2.5倍早くする方法「http://shibuya24/info/entry/unity-shader-property-to-id」で使用したサンプルコード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PropertyToIdPerformance : MonoBehaviour
{
public Material mat;
public bool toggle;
public int cnt = 5000;
int propId = 0;
@baobao
baobao / SendStructCppToCs.cs
Last active February 23, 2025 15:52
C#/C++間構造体データ送信サンプル http://shibuya24.info/entry/unity-cs-cpp-struct
// C#からC++に構造体を送るサンプル(C#側処理)
using System;
using System.Runtime.InteropServices;
public static class SendStructCsToCpp
{
[DllImport("TestDll.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void SendStruct(ref StructData output, IntPtr input);
public struct StructData
@baobao
baobao / InvokeCpp.cs
Last active February 23, 2025 15:47
C#からC++に文字列を送信する記事 https://shibuya24.info/entry/unity-cs-cpp-string 内のサンプルソースコード
// C#からC++に文字列を送信するC#側のコード
using System.Runtime.InteropServices;
using UnityEngine;
public class InvokeCpp : MonoBehaviour
{
[DllImport("TestDll.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void ReceiveString(string hoge);
void Awake()