Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / GenerateGeometryWithLibTess.cs
Created March 10, 2022 06:28
using LibTressDotNet with Unity
// https://forum.unity.com/threads/libtressdotnet-example.1250383/#post-7952740
/// <summary>
/// Generate Mesh using LibTess.
/// </summary>
/// <param name="pointLists"></param>
/// <param name="textureScale"></param>
public void GenerateGeometryWithLibTess(List<List<Vector3>> pointLists, float textureScale)
{
    // Libtess stuff
    var triangulatedShape = new TriangulatedShape2D(pointLists);
@unitycoder
unitycoder / RayMarch.cs
Created March 8, 2022 08:01
render 3D render texture in custom shader (raymarch)
// https://forum.unity.com/threads/how-render-3d-render-texture-in-custom-shader.1247764/#post-7948198
using System.IO;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
 
using Common.Unity.Utility;
 
public class RayMarch : MonoBehaviour
{
@unitycoder
unitycoder / UnityHubLightTheme.css
Created March 6, 2022 19:45
Light Theme Style for Unity Hub 3.0.x
// SOURCE: https://gitlab.com/GuitarBro/hub-patcher/-/blob/master/hub_patcher.py
<style>
/******************************************/
/* */
/* HubPatcher and theme(s) by Andrew. */
/* */
/******************************************/
/* */
/* Last updated on 2022-3-3. */
@unitycoder
unitycoder / CurvedSurfaceShader.shader
Created February 25, 2022 11:49
Curved Surface Shader
// https://forum.unity.com/threads/adding-vertex-effect-to-surface-shader.1245025/
Shader "Custom/CurvedSurfaceShader"
{
    Properties
    {
        _Color ("Colour", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
public static class FileComparer
{
public static bool CompareEquals(string filePath1, string filePath2, int bufferSize = 65536)
{
if (filePath1 == filePath2) return true;
var buffer1 = ArrayPool<byte>.Shared.Rent(bufferSize);
var buffer2 = ArrayPool<byte>.Shared.Rent(bufferSize);
try
{
@unitycoder
unitycoder / TiledSpritesInfinite.cs
Created February 24, 2022 13:05 — forked from kurtdekker/TiledSpritesInfinite.cs
Infinite scrolling sprite background in Unity3D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
// To use:
// import a repeating sprite, FullRect
// drop it on a SpriteRenderer GameObject
// drop this on that same SpriteRenderer you want to be infinitely tiled
//
@unitycoder
unitycoder / ConsoleServer.cs
Created February 24, 2022 08:02
unity tcp client and dotnet console tcp server
// https://forum.unity.com/threads/connect-unity-and-wpf.337945/#post-2202467
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
 
public class serv
{
    public static void Main()
    {
@unitycoder
unitycoder / FloatingOrigin.cs
Created February 23, 2022 08:56 — forked from brihernandez/FloatingOrigin.cs
Floating origin to handle large worlds in Unity.
// Based on the Unity Wiki FloatingOrigin script by Peter Stirling
// URL: http://wiki.unity3d.com/index.php/Floating_Origin
using UnityEngine;
using UnityEngine.SceneManagement;
public class FloatingOrigin : MonoBehaviour
{
[Tooltip("Point of reference from which to check the distance to origin.")]
public Transform ReferenceObject = null;
@unitycoder
unitycoder / PreviewSphereCast.cs
Created February 22, 2022 19:52
Draw Spherecasts with Gizmos
// https://forum.unity.com/threads/draw-spherecasts-code-review.1243714/
[Range(0.1f, 1f)] public float sphereCastRadius;
[Range(1f, 100f)] public float range;
public LayerMask layerMask;
private RaycastHit hit;
private void OnDrawGizmosSelected()
{
if (Physics.SphereCast(transform.position, sphereCastRadius, transform.forward * range, out hit, range, layerMask))
Gizmos.DrawWireSphere(SphereCase(), sphereCastRadius);