Skip to content

Instantly share code, notes, and snippets.

@Mesidin
Mesidin / simple.html
Last active September 29, 2024 20:29
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<meta name="description" content="Description">
@Mesidin
Mesidin / GLSL-Noise.md
Created February 14, 2018 16:17 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@Mesidin
Mesidin / ScriptingDefineSymbolToggler.cs
Created March 14, 2017 15:00 — forked from derwodaso/ScriptingDefineSymbolToggler.cs
Disable / Enable ScriptingDefineSymbolds from menu
/* To avoid performance issues caused by string constructions when logging stuff
* to the console, simply surround the code with the the following:
*
* #if DEBUG_LOGGING
* Debug.Log("my" + numer.ToString("0.00") " super" + " expensive " + " string building code");
* #endif
*
* When creating a non-debug build or testing the game for performance, simply disable
* the debug messages from the Unity menu (menu name can be simply changed below).
*/
using UnityEngine;
using System.Collections;
public class TrajectoryCalculation : MonoBehaviour
{
public Rigidbody projectile;
public Transform target;
[Header("CalculateBestThrowSpeed")]
public float timeToTarget = 1f;
[Header("CalculateTrajectory")]
using UnityEngine;
using System.Collections;
// based on http://unitytipsandtricks.blogspot.com/2013/05/camera-shake.html
public class PerlinShake : MonoBehaviour
{
public float duration = 2f;
public float speed = 20f;
public float magnitude = 2f;
public AnimationCurve damper = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(0.9f, .33f, -2f, -2f), new Keyframe(1f, 0f, -5.65f, -5.65f));
@Mesidin
Mesidin / CustomEditorBase.cs
Created March 23, 2016 03:15 — forked from t0chas/CustomEditorBase.cs
Default Custom Inspector-Editor for Unity3D with ReorderableLists for arrays handling
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
[CustomEditor(typeof(UnityEngine.Object), true, isFallback = true)]
[CanEditMultipleObjects]
public class CustomEditorBase : Editor
{
@Mesidin
Mesidin / VRUtility.cs
Created March 4, 2016 19:39 — forked from radiatoryang/VRUtility.cs
a script I give to my Unity VR students that demonstrates a few useful "quality of VR" features for their games -- lowering visual quality for higher framerate, and HMD recentering
using UnityEngine;
using System.Collections;
using UnityEngine.VR; // you always need this to use special VR functions
public class VRUtility : MonoBehaviour {
// Use this for initialization
public void Start () {
// set render quality to 50%, sacrificing visual quality for higher FPS
@Mesidin
Mesidin / RaycastTargetTrigger.cs
Created March 4, 2016 19:39 — forked from radiatoryang/RaycastTargetTrigger.cs
a script I give to my Unity VR classes to detect when the player is looking at something... put it on anything with a collider, and it'll know if it's being looked at or not
using UnityEngine;
using System.Collections;
using UnityEngine.VR; // we need this line here for InputTracking and VRSettings functions
// USAGE: put this on a thing you want the player to look at!
// this code will enable that thing to know if it is being looked at!
[RequireComponent (typeof(Collider)) ] // this thing needs a collider if we should look at it
public class RaycastTargetTrigger : MonoBehaviour {
@Mesidin
Mesidin / camera-fader.cs
Created January 13, 2016 14:57 — forked from ashblue/camera-fader.cs
Unity camera fader script. Supports cross fades, callbacks, and delays. Works with Unity 4.6 and above. You'll need a canvas overlay image of pure black attached to the overlay property in order for this to work.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class CameraFade : MonoBehaviour {
public static CameraFade current;
public delegate void Callback();
[SerializeField] bool debug;
@Mesidin
Mesidin / normalize-slope.cs
Created January 13, 2016 14:56 — forked from ashblue/normalize-slope.cs
Unity 2D slope normalizer for walking up and downhill with corner snapping. Based upon https://www.youtube.com/watch?v=xMhgxUFKakQ
// @NOTE Must be called from FixedUpdate() to work properly
void NormalizeSlope () {
// Attempt vertical normalization
if (grounded) {
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1f, whatIsGround);
if (hit.collider != null && Mathf.Abs(hit.normal.x) > 0.1f) {
Rigidbody2D body = GetComponent<Rigidbody2D>();
// Apply the opposite force against the slope force
// You will need to provide your own slopeFriction to stabalize movement