This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vars | |
string[] optionList = new string[] {"Apples", "Oranges", "Androids"}; | |
int index = 0; | |
// loop | |
void OnGUI() | |
{ | |
GUI.changed = false; // not needed if EditorGUILayout.Popup is first in OnGUI | |
index = EditorGUILayout.Popup("My List",index, optionList); | |
if (GUI.changed) DoSomething(); // NOTE: gets also called if same item is selected from list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine.VR; | |
// toggle oculus on/off | |
VRSettings.enabled = !VRSettings.enabled; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2D array to 1D array | |
array[x,y] = array[y*width+x] | |
// 3D array to 1D array | |
array[x, y, z] = array[x+width*(y+depth*z)] | |
array[x, y, z] = array[x + HEIGHT* (y + WIDTH* z)] | |
array[x, y, z] = array[(z * xMax * yMax) + (y * xMax) + x] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.IO; | |
using System.Text; | |
using UnityEditor; | |
using UnityEngine; | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
[ExecuteInEditMode] | |
public class ForceGrassDistanceInEditor : MonoBehaviour { | |
public float distance=250; // 250 is max in terrain settings, but not here | |
Terrain terrain; | |
void Start () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (value % 2 == 0) print("even"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Code snippets from Unite 2015 - A coder's guide to spline-based procedural geometry */ | |
/* https://www.youtube.com/watch?v=o9RK6O2kOKo */ | |
// Optimized GetPoint | |
Vector3 GetPoint( Vector3[] pts, float t ) { | |
float omt = 1f-t; | |
float omt2 = omt * omt; | |
float t2 = t * t; | |
return pts[0] * ( omt2 * omt ) + | |
pts[1] * ( 3f * omt2 * t ) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************\ | |
* Copyright (C) Leap Motion, Inc. 2011-2014. * | |
* Leap Motion proprietary. Licensed under Apache 2.0 * | |
* Available at http://www.apache.org/licenses/LICENSE-2.0.html * | |
\******************************************************************************/ | |
// Original script: "MagneticPinch.cs" modified by unitycoder.com to just get the finger position & directions | |
using UnityEngine; | |
using System.Collections; | |
using Leap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Fade all current object anc child images & texts, code needs cleaning up.. */ | |
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
public class UIFadeEffect : MonoBehaviour | |
{ | |
public bool destroyRootAfterFade=false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add warning number after the disable (can see the error code from the console output) | |
// examples: | |
#pragma warning disable 0168 // variable declared but not used. | |
#pragma warning disable 0219 // variable assigned but not used. | |
#pragma warning disable 0414 // private field assigned but not used. |