Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
// https://forum.unity.com/threads/let-us-override-functions-of-inputsystemuiinputmodule.867592/#post-8628135
/// Used to expose the internal function of the Unity.InputSystem to XXXX assembly
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("XXXXX")]
@unitycoder
unitycoder / GetExternalIP.js
Last active December 3, 2022 13:16
node.js get external IP address using ipify
// get external IP address using ipify https://stackoverflow.com/questions/20273128/node-js-how-to-get-my-external-ip-address-in-node-js-app/37850722#37850722
// this code was created by chatGPT
const http = require('http');
// Set the URL of the request to the ipify API
const options = {
host: 'api.ipify.org',
port: 80,
path: '/?format=json'
};
@unitycoder
unitycoder / getlocalinferfaces.js
Created December 3, 2022 13:13
node.js print all local ip addresses from networkinterfaces
const os = require('os');
// Get the network interfaces object
const interfaces = os.networkInterfaces();
// Create an array to store the IP addresses
const ipAddresses = [];
// Iterate over the properties in the object
for (const interfaceName in interfaces) {
@unitycoder
unitycoder / gamesfactory-export-midi.md
Created December 3, 2022 15:59
How to extract music files from Games Factory
@unitycoder
unitycoder / fetchrss.js
Created December 3, 2022 21:30
node.js fetch RSS feed every 1hr
// created by chatGPT
const fetch = require('node-fetch');
const parser = require('rss-parser');
// Replace this with the URL of the RSS feed you want to fetch
const RSS_FEED_URL = 'http://example.com/rss';
// Set the interval to 1 hour (in milliseconds)
const FETCH_INTERVAL = 1 * 60 * 60 * 1000;
@unitycoder
unitycoder / Explosion.shader
Created December 4, 2022 11:15
fake volumetric explosion shader (similar to unity butterfly effect demo)
// https://stevencraeynest.wordpress.com/2013/03/29/easy-volumetric-explosion-in-unity3d/
Shader "Custom/Explosion"
{
Properties
{
_RampTex ("Color Ramp", 2D) = "white" {}
_DispTex ("Displacement Texture", 2D) = "gray" {}
_Displacement ("Displacement", Range(0, 1.0)) = 0.1
_ChannelFactor ("ChannelFactor (r,g,b)", Vector) = (1,0,0)
_Range ("Range (min,max)", Vector) = (0,0.5,0)
@unitycoder
unitycoder / solve-range-compression-x-y.txt
Created December 4, 2022 18:12
solve X and Y in: -1*x+y = 0 and 1*x+y=1
// chatGPT
This system of equations has two unknowns, x and y. To solve for these unknowns, we can use a method called elimination.
First, we can rewrite the equations so that the x terms are on one side and the y terms are on the other side. This will make it easier to eliminate one of the variables. The equations become:
-1x + y = 0
1x + y = 1
Next, we can add the two equations together. This will eliminate the y terms and leave us with an equation in terms of x. The equations become:
@unitycoder
unitycoder / GLSL-Noise.md
Created December 4, 2022 20:39 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@unitycoder
unitycoder / RemoveDuplicateSurfaces.cs
Created December 5, 2022 09:14
unity remove duplicate triangles
// created by chatGPT
using UnityEngine;
using UnityEditor;
public class RemoveDuplicateSurfaces : EditorWindow
{
[MenuItem("Tools/Remove Duplicate Surfaces")]
static void Init()
{
RemoveDuplicateSurfaces window = (RemoveDuplicateSurfaces)EditorWindow.GetWindow(typeof(RemoveDuplicateSurfaces));
@unitycoder
unitycoder / Line.cs
Created December 5, 2022 10:17
Metawire Line.cs without LINQ
// converted with chatGPT
// https://github.com/keijiro/Metawire/blob/main/Packages/jp.keijiro.metawire/Editor/Line.cs
// linq
public void Generate(Mesh mesh)
{
var p = Enumerable.Range(0, Segments + 1)
.Select(i => (float)i / Segments);
var idx = Enumerable.Range(0, Segments)