Skip to content

Instantly share code, notes, and snippets.

@derwodaso
derwodaso / ScriptingDefineSymbolToggler.cs
Created March 14, 2017 10:34
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));
@say4n
say4n / LICENSE
Last active May 9, 2017 06:37
Just a plain simple boring xkcd comic downloader with download progress indicator.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Sayan Goswami <goswami.sayan47@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@t0chas
t0chas / CustomEditorBase.cs
Last active September 2, 2024 06:54
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
{
@radiatoryang
radiatoryang / VRUtility.cs
Created March 4, 2016 19:30
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
@radiatoryang
radiatoryang / RaycastTargetTrigger.cs
Last active August 2, 2022 05:14
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 {
@ashblue
ashblue / RestoreScriptableObject.cs
Last active January 13, 2016 14:53
Save and restore a scriptable object reference after your custom editor windows have been re-compiled.
using UnityEngine;
using UnityEditor;
public static class Wm {
const string DATABASE_ID_KEY = "MyCustomDatabase";
public static MyScriptableObject _db;
public static MyScriptableObject Db {
get {
if (_db == null && EditorPrefs.HasKey(DATABASE_ID_KEY)) {
_db = GetDatabaseFromStorage();
Shader "Custom/Gamma Image Effect" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_SaturationAmount ("Saturation Amount", Range(0.0, 1.0)) = 1.0
_BrightnessAmount ("Brightness Amount", Range(0.0, 1.0)) = 1.0
_ContrastAmount ("Contrast Amount", Range(0.0,1.0)) = 1.0
}
SubShader
{
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public class CopyComponents : EditorWindow {
private GameObject originalObject = null;
private GameObject targetObject = null;
[MenuItem("Window/CopyComponent")]