Skip to content

Instantly share code, notes, and snippets.

View DenchiSoft's full-sized avatar
🐰
https://denchisoft.com

Denchi DenchiSoft

🐰
https://denchisoft.com
View GitHub Profile
@DenchiSoft
DenchiSoft / ClickHandler.cs
Created February 22, 2018 19:55
Setting the window to consume or pass through clicks.
[DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]
private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, int dwFlags);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
// Sets window to pass through clicks.
private void SetInactive() {
    #if !UNITY_EDITOR
    SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
@DenchiSoft
DenchiSoft / Cats.cs
Last active September 18, 2018 21:53
Extension method for CubismModel that makes it easy to access CubismParameters by name. CubismParameters for each model are stored in a dictionary the first time they're needed for fast access next time.
// CubismModel model = ...;
// Call it like this:
void Start() {
// ...
CubismParameter myParam = model.GetParam("ParamIDName");
// ...
}
using System.Linq;
using Live2D.Cubism.Core;
using Live2D.Cubism.Rendering;
using UnityEditor;
using UnityEngine;
/// <summary>
/// Replace active Live2D model texture temporarily
/// at runtime or permanently in editor.
/// </summary>
@DenchiSoft
DenchiSoft / L2DTest.cs
Created October 27, 2019 10:53
Minimal Live2D parameter manipulation example
using Live2D.Cubism.Core;
using Live2D.Cubism.Framework;
using System.Collections.Generic;
using UnityEngine;
public class L2DTest : MonoBehaviour
{
[Range(-30, 30)]
public float paramValue;
private CubismModel model;
@DenchiSoft
DenchiSoft / ExternalCubismModelLoader.cs
Last active December 16, 2019 22:33
Runtime-Loading external Live2D Cubism Models on Android
using Live2D.Cubism.Core;
using Live2D.Cubism.Framework.Json;
using System;
using System.IO;
using System.Text;
using UnityEngine;
public static class ExternalCubismModelLoader
{
/// <summary>
{
"title": "Welcome to the VTube Studio Headquarter!",
"description": "\n**Hi %user%! ** Good to have you with us!\n\nIf you just want to hang out and talk a bit, why don't you introduce yourself in <#652602255748497458>?\n\nBefore you ask questions though, please check the channels <#717998026547003393> and <#718909794420785162> first. Maybe your question was already answered.\n\nAlso, if you want a **role**, check the pinned message in <#727489986647031838>.\n\nEnjoy your stay! :sparkles:",
"color": 53380,
"image": "https://i.imgur.com/kSuASrY.png"
}
@DenchiSoft
DenchiSoft / ip.txt
Created March 29, 2021 00:21
ip.txt syntax for experimental VTube Studio network tracking with OpenSeeFace
# To listen for remote connections, change this to 0.0.0.0 or your actual IP on the desired interface.
ip=0.0.0.0
# This is the port the server will listen for tracking packets on.
port=11573
import socket
from socket import timeout
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
s.bind(("0.0.0.0", 47779));
s.settimeout(0.5)
while True:
try:
data, address = s.recvfrom(4096)
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Queue for calculating sliding averages. Not thread safe.
/// </summary>
public class SlidingWindowQueue
{
/// <summary>
/// The queue wrapped by this class.
Shader "Custom/ColorRepairShader"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Key("Key Color", color) = (0,0,0,0)
}
Subshader
{
Pass