Skip to content

Instantly share code, notes, and snippets.

View MattRix's full-sized avatar

Matt Rix MattRix

View GitHub Profile
@LotteMakesStuff
LotteMakesStuff / Colors.cs
Created April 6, 2017 23:45
Trying to set Colours from code but need something better than the few that unity provide and dont wanna mess around with colour values for ages? Colors is your friend!!!
using UnityEngine;
public class Colors
{
// NOTE: The follwing color names come from the CSS3 specification, Section 4.3 Extended Color Keywords
// http://www.w3.org/TR/css3-color/#svg-color
public static readonly Color AliceBlue = new Color32(240,248,255,255);
public static readonly Color AntiqueWhite = new Color32(250,235,215,255);
public static readonly Color Aqua= new Color32(0,255,255,255);
@LotteMakesStuff
LotteMakesStuff / InspectorButtonsTest.cs
Last active November 2, 2023 21:03
Code running pack! two property drawing scripts that make it super easy to trigger code via buttons in the inspector, and get feedback! [TestButton] draws you little buttons that call a method on your MonoBehaviour, and [ProgressBar] give you a great way to show feedback from long running methods. These are *super* helpful for things like proced…
using UnityEngine;
using System.Collections;
public class InspectorButtonsTest : MonoBehaviour
{
[TestButton("Generate world", "DoProcGen", isActiveInEditor = false)]
[TestButton("Clear world", "ClearWorld", 2, isActiveInEditor = false)]
[ProgressBar(hideWhenZero = true, label = "procGenFeedback")]
public float procgenProgress = -1;
@prucha
prucha / UnityMeshCreator.cs
Last active March 31, 2024 15:45
Unity: Creating a Mesh in code
using UnityEngine;
using System.Collections;
// This Unity script demonstrates how to create a Mesh (in this case a Cube) purely through code.
// Simply, create a new Scene, add this script to the Main Camera, and run.
public class UnityMeshCreator : MonoBehaviour {
GameObject _cube;
@phosphoer
phosphoer / SimpleGeo.cs
Last active March 28, 2024 22:24
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
@MattRix
MattRix / UnityEditorIcons.txt
Last active April 26, 2024 18:52
A list of all the built-in EdtiorGUI icons in Unity. Use EditorGUIUtility.IconContent([icon name]) to access them.
ScriptableObject Icon
_Popup
_Help
Clipboard
SocialNetworks.UDNOpen
SocialNetworks.Tweet
SocialNetworks.FacebookShare
SocialNetworks.LinkedInShare
SocialNetworks.UDNLogo
animationvisibilitytoggleoff
@MattRix
MattRix / PhysicsFollower.cs
Last active May 7, 2024 09:06
A thing you can use to make a rigidbody move towards a position reliably
using UnityEngine;
using System.Collections;
using System;
[RequireComponent (typeof(Rigidbody))]
public class PhysicsFollower : MonoBehaviour
{
public Transform target;
Rigidbody rb;
@DGoodayle
DGoodayle / ExtendedComponentReodering.cs
Last active April 17, 2016 08:00
Move to Top, Move to Bottom on components - Just put this in your Editor folder!
using UnityEngine;
using UnityEditor;
/*
Extended Component Reodering by Just a Pixel (Danny Goodayle) - http://www.justapixel.co.uk
Copyright (c) 2015
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@aras-p
aras-p / custom_brdf.md
Last active April 27, 2020 11:13
Custom BRDFs in deferred shading/lighting in Unity

So, https://twitter.com/sunjammer/status/569925239989256192 and https://twitter.com/sunjammer/status/569983534368206848

Now, depends on whether you want custom BRDF in deferred on 1) all your objects (easy) or 2) only some of your objects (harder).

1. change BRDF for everything

That's fairly easy. The actual object shaders more or less just fill the g-buffer (and in Unity 4.x deferred lighting, combine textures with the lighting buffer in the final pass). The actual BRDF is in the "light shader". Start by copying the built-in light shader (4.x deferred lighting: Internal-PrePassLighting.shader; 5.0 deferred shading: Internal-DeferredShading.shader) into your project. In 4.x, put it into Resources folder so it's included into the build; in 5.0 point Unity to use that shader under Project Settings -> Graphics.

Change the shader to do different BRDF.

@omgwtfgames
omgwtfgames / NoiseTexture.cs
Last active March 17, 2021 00:18 — forked from KdotJPG/OpenSimplex2S.java
Visually axis-decorrelated coherent noise function based on the Simplectic honeycomb - C# port
/*
* OpenSimplex (Simplectic) Noise Test for Unity (C#)
* This file is in the Public Domain.
*
* This file is intended to test the functionality of OpenSimplexNoise.cs
* Attach this script to a GameObject with mesh (eg a Quad prefab).
* Texture is updated every frame to assist profiling for performance.
* Using a RenderTexture should perform better, however using a Texture2D
* as an example makes this compatible with the free version of Unity.
*
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using ClipperLib;
using TriangleNet.Geometry;
using Polygon = System.Collections.Generic.List<ClipperLib.IntPoint>;
using Polygons = System.Collections.Generic.List<System.Collections.Generic.List<ClipperLib.IntPoint>>;