Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / MouseFinger.cs
Created November 3, 2021 06:13 — forked from alexmelyon/MouseFinger.cs
Send mouse/finger unity events
using UnityEngine;
using UnityEngine.Events;
public class MouseFingerEvent
{
public Vector2 position;
public int index;
}
public class MouseFinger : MonoBehaviour
@unitycoder
unitycoder / CameraEditorMovement.cs
Created November 3, 2021 06:14 — forked from alexmelyon/CameraEditorMovement.cs
Unity camera movement like Editor
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraEditorMovement : MonoBehaviour
{
[Header("Mouse")]
public float lookSpeedH = 2f;
public float lookSpeedV = 2f;
public float zoomSpeed = 2f;
@unitycoder
unitycoder / LineDrawer.cs
Created November 5, 2021 20:09
Drawing a line with Unity UI Toolkit
// Drawing a line with UITK https://forum.unity.com/threads/drawing-a-line-with-uitk.1193470/
public class LineDrawer : VisualElement
{
private Vector3 startPos, endPos;
private float thickness;
public LineDrawer(Vector3 pos1, Vector3 pos2, float width)
{
startPos = pos1;
endPos = pos2;
@unitycoder
unitycoder / PixelPerfectLine.shader
Created November 17, 2021 06:59
Pixel Perfect Line Shader
// https://forum.unity.com/threads/linerenderer2d-gpu-pixel-perfect-2d-line-renderer-for-unity-urp-2d-renderer.1021708/#post-7663765
Shader "Unlit/PixelPerfectLineShader"
{
Properties
{
_Endpoint ("Endpoint", Vector) = (0, 0, 10, 10)
_Thickness ("Thickness", float) = 1
_BlockSize ("BlockSize", int) = 1
}
SubShader
@unitycoder
unitycoder / Unity Physics Joints.md
Created November 24, 2021 18:25
Unity Physics Joints

SkinnedMeshRenderer jumps/breaks with joint

Check if root has negative scale, then connected anchor needs to be manual and set to negative!

@unitycoder
unitycoder / EditorCameraController.cs
Created December 9, 2021 17:38
Cardboard Unity Editor Camera Controller
// https://stackoverflow.com/a/46301111/5452781
// NOTE should disable if not in editor mode
public class EditorCameraController : MonoBehaviour
{
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
@unitycoder
unitycoder / ScreenSpaceUVTest.shader
Created December 14, 2021 10:59
screenspace UV shader
// https://forum.unity.com/threads/screenspace-uv.1207651/#post-7735020
Shader "Unlit/ScreenSpaceUVTest"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" "DisableBatching"="True" }
// https://forum.unity.com/threads/drawing-an-animated-arc-on-the-screen.1210524/
using UnityEngine;
using System.Collections;
 
public class Arc : MonoBehaviour
{
    public Shader ArcShader;
    private Material _Material;
 
    void Start()
@unitycoder
unitycoder / HueContrastSaturation.shader
Created December 18, 2021 08:12
hue saturation contrast standard shader
// https://forum.unity.com/threads/adding-hue-saturation-and-contrast-to-standardshader.843697/#post-5572063
Shader "HueContrastSaturation"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo Map", 2D) = "black" {}
        _BumpMap ("Normal Map", 2D) = "bump" {}
        _MetallicGlossMap ("Metallic (R) Smoothness (A) Map", 2D) = "black" {}
        _Hue ("Hue", Float) = 1.0
@unitycoder
unitycoder / Sort.cs
Created December 30, 2021 14:19
Sort with JOB system
// https://forum.unity.com/threads/lets-discuss-sorting-with-jobs.553288/
using System.Collections.Generic;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
 
namespace Cradle
{
    /// <summary>