Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / ConfigurableJointExtensions.cs
Created May 25, 2020 09:33 — forked from mstevenson/ConfigurableJointExtensions.cs
Extension methods for working with Configurable Joints for Unity
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
@unitycoder
unitycoder / InstancedGeometry.shader
Created June 2, 2020 05:05
Instanced Geometry Shader
// https://forum.unity.com/threads/is-it-possible-to-have-gpu-instancing-with-geometry-shader.898070/#post-5928629
Shader "Unlit/InstancedGeometryShader"
{
Properties
{
_TriangleOffset ("Triangle Offset", Float) = 0.1
_Color ("Color", Color) = (1,1,1,1)
}
SubShader
@unitycoder
unitycoder / unwanted-processes.txt
Last active June 3, 2020 07:53
Unwanted Background Processes and Services
\Adobe\Acrobat DC\Acrobat\AdobeCollabSync.exe
\Adobe\Acrobat DC\Acrobat\acrotray.exe
Adobe\Adobe Desktop Common\ElevationManager\AdobeUpdateService.exe
@unitycoder
unitycoder / AnimPlayer.cs
Last active May 8, 2024 11:21
Unity Animation Component Add Clip and Play specific Frame Ranges
// note, using Animation component (with autoplay disabled)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimPlayer : MonoBehaviour
{
Animation anim;
void Start()
@unitycoder
unitycoder / SnapVector3Angle.cs
Created June 10, 2020 16:34
snap-round-3d-direction-vector-based-on-angle
// https://forum.unity.com/threads/snap-round-3d-direction-vector-based-on-angle.905168/#post-5963291
private Vector3 findNearest(Vector3 dir)
{
// scale vector to unit cube
float scaleDivisor = Mathf.Abs(dir.x);
if (Mathf.Abs(dir.y) > scaleDivisor)
scaleDivisor = Mathf.Abs(dir.y);
if (Mathf.Abs(dir.z) > scaleDivisor)
scaleDivisor = Mathf.Abs(dir.z);
@unitycoder
unitycoder / normals.shader
Created June 16, 2020 06:37
Normal Debug Shader (Show Normals)
// https://docs.unity3d.com/Manual/ShaderTut2.html
Shader "Tutorial/Display Normals"
{
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
@unitycoder
unitycoder / SplineLine.cs
Created July 6, 2020 20:26
Simple Bezier Line From A to B (with adjustable between points)
// original source from https://github.com/mopsicus/unity-bezier-curves
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SplineLine : MonoBehaviour
{
public LineRenderer lineRenderer;
private int segmentsCount = 16;
@unitycoder
unitycoder / Vibration.cs
Created July 8, 2020 18:42 — forked from aVolpe/Vibration.cs
Vibration for Unity3d with Android native Call, with fallback to Handlheld.Vibrate()
using UnityEngine;
using System.Collections;
public static class Vibration
{
#if UNITY_ANDROID && !UNITY_EDITOR
public static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
public static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
public static AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");