Skip to content

Instantly share code, notes, and snippets.

View barleymalt's full-sized avatar
🐢

Filippo Fratta Pasini barleymalt

🐢
View GitHub Profile
@barleymalt
barleymalt / CameraShake.cs
Created April 5, 2023 13:01
A simple CameraShake for Unity
using System;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Utils
{
public class CameraShake : MonoBehaviour
{
[Serializable]
@barleymalt
barleymalt / Unity Shaders Collection
Created March 13, 2023 13:30
A collection of useful unity shaders
//////////////////////////////////////////////
//// TRANSPARENT SHADOW COLLECTOR - START ////
//////////////////////////////////////////////
// See: https://forum.unity.com/threads/transparent-shader-receive-shadows.325877/#post-2114800
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/TransparentShadowCollector"
{
Properties
@barleymalt
barleymalt / rider_live_templates.txt
Last active February 3, 2023 11:41
Rider Live Templates
=================================================================
A LIST OF LIVE TEMPLATES FOR UNITY
TO MAKE THINGS EASIER, OR JUST BECAUSE, WHY NOT?
==================================================================
==================================================================
UNITY
==================================================================
------------------------------------------------------------------
@barleymalt
barleymalt / usefulPackages
Created October 20, 2022 14:24
custom packages to add to projects
"com.dbrizov.naughtyattributes": "https://github.com/dbrizov/NaughtyAttributes.git#upm"
@barleymalt
barleymalt / VerticesGrid.cs
Created October 20, 2022 14:11
a simple gist to create a grid of vertices
// catlike coding
private Vector3[] Generate(int xSize, ySize)
{
Vector3[] vertices = new Vector3[(xSize + 1) * (ySize + 1)];
for (int i = 0, y = 0; y < ySize; y++)
{
for (int x = 0; x < xSize; x++, i++)
{
public static class Vector3Extensions
{
public static Vector3 GetPointOnSphereAngle(this Vector3 center, Vector3 targetDirection, float angle, float radius)
{
float angleInRad = Random.Range(0.0f, angle) * Mathf.Deg2Rad;
Quaternion dir = Quaternion.LookRotation(targetDirection - center);
Vector2 pointOnCircle = (Random.onUnitSphere) * Mathf.Sin(angleInRad);
Vector3 pointOnSphere = dir * (new Vector3(pointOnCircle.x, pointOnCircle.y, Mathf.Cos(angleInRad))) + center;
Vector3 distFromCenter = (pointOnSphere - center) * radius;
@barleymalt
barleymalt / FreeCam.cs
Created April 30, 2022 07:07
Unity Utilities
// Source: https://gist.github.com/ashleydavis/f025c03a9221bc840a2b
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
/// <summary>
/// A simple free camera to be added to a Unity game object.