Skip to content

Instantly share code, notes, and snippets.

@nisovin
nisovin / GodotWebFilesExample.gd
Last active May 30, 2022 14:02
Godot Web File Open/Save Dialogs
extends Control
func _ready():
WebFiles.connect("file_opened", self, "_on_file_opened")
func _on_Button_pressed():
WebFiles.open_file(".jpg,.jpeg")
func _on_file_opened(file, content):
$Label.text = file
@raysan5
raysan5 / open_source_and_videogames.md
Last active October 11, 2025 17:01
Open Source and Videogames - Resources

open_source_and_videogames

Open Source and Videogames - Resources

This git include a list of programs, tools, engines and libraries free and open source intended to make videogames.

NOTE: This gist is a support material for the talk "Open Source and Videogames" given by me, Ramon Santamaria, on October 26th 2021 in Canòdrom, Barcelona. All the materials listed here were explained in detail in a +2 hours talk.

Contents

Shader "Test/SmoothZoomTexture"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[KeywordEnum(Basic,Manual,Blend,Compare)]Mode("Mode", Int) = 0
_Blend("Blend", Range(0,1)) = 1
[Header(Mip Map)]
_MipMapMin("MipMap Min", Int) = 4
@unitycoder
unitycoder / MouseInputManager.cs
Created August 13, 2021 07:59
Raw Input Multiple Mouse Unity
// https://pastebin.com/4h3CqpYy
// Unity PINVOKE interface for pastebin.com/0Szi8ga6
// Handles multiple cursors
// License: CC0
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System;
@unitycoder
unitycoder / IMG2Sprite.cs
Created June 30, 2021 07:08
Generating sprites dynamically from PNG or JPEG files in C# (unity)
// https://forum.unity.com/threads/generating-sprites-dynamically-from-png-or-jpeg-files-in-c.343735/
using UnityEngine;
using System.Collections;
using System.IO;
 
 
public class IMG2Sprite : MonoBehaviour
{
 
 
@unitycoder
unitycoder / CompileTime.cs
Created June 10, 2021 07:23
measure compile time unity editor
// https://forum.unity.com/threads/compile-times-twice-as-long-then-previous-versions.1123711/
using UnityEngine;
using UnityEditor;
using System.Collections;
class CompileTime : EditorWindow {
 
    bool isTrackingTime;
    double startTime, finishTime, compileTime;
    [MenuItem("Window/Compile Times")]
    public static void Init() {
@unitycoder
unitycoder / PanZoom.cs
Created February 15, 2021 10:31
mobile zoom and pan
// https://forum.unity.com/threads/zoom-and-pan-an-image.1048598/#post-6839018
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PanZoom : MonoBehaviour {
Vector3 touchStart;
public float zoomOutMin = 1;
public float zoomOutMax = 8;
@deakcor
deakcor / shadow2d.shader
Last active July 23, 2025 18:43
Shadow 2D for Godot Engine
/**
* Shadow 2D.
* License: CC0
* https://creativecommons.org/publicdomain/zero/1.0/
*/
shader_type canvas_item;
render_mode blend_mix;
uniform vec2 deform = vec2(2.0, 2.0);
uniform vec2 offset = vec2(0.0, 0.0);
@giacomelli
giacomelli / UnityEventExtensions.cs
Last active November 6, 2021 18:25
UnityEvent Dump Log
using System.Runtime.CompilerServices;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
namespace Giacomelli.Framework
{
public static class UnityEventExtensions
{
[System.Diagnostics.Conditional("DEBUG")]
@unitycoder
unitycoder / ResizeWithAspectRatio.cs
Created October 14, 2020 08:53
Calculate resize with aspect ratio (scale)
//// get aspect ratio https://stackoverflow.com/a/32593158/5452781
int sourceWidth = 3000;
int sourceHeight = 2000;
int targetWidth = 1920;
int targetHeight = 1080;
float percent = (new List<float> { (float)targetWidth / (float)sourceWidth, (float)targetHeight / (float)sourceHeight }).Min();
Size resultSize = new Size((int)Math.Floor(sourceWidth * percent), (int)Math.Floor(sourceHeight * percent));
Console.WriteLine("size= " + sourceWidth + "x" + sourceHeight + " percent= " + percent + " result=" + (sourceWidth * percent) + "x" + (sourceHeight * percent));