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
#define CLOCK_PRECISION (1E9) | |
struct timespec requestStart, requestEnd; | |
clock_gettime(CLOCK_REALTIME, &requestStart); | |
func(grid); | |
clock_gettime(CLOCK_REALTIME, &requestEnd); | |
// Calculate the time it took | |
double accum = ( requestEnd.tv_sec - requestStart.tv_sec ) | |
+ ( requestEnd.tv_nsec - requestStart.tv_nsec ) |
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
public class Modification : IDisposable { | |
private readonly Object[] objects; | |
public Modification(string action, params Object[] objects) { | |
this.objects = objects; | |
EditorHelpers.RecordUndo(action, objects); | |
} | |
public void Dispose() { | |
foreach (Object o in objects) { |
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.Generic; | |
using System.Xml; | |
using UnityEditor; | |
using UnityEngine; | |
public class TextureAtlasSlicer : EditorWindow { | |
[MenuItem("CONTEXT/TextureImporter/Slice Sprite Using XML")] | |
public static void SliceUsingXML(MenuCommand command) | |
{ |
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.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class HighlightHelper { | |
private static readonly Type HierarchyWindowType; |
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.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class HighlightHelper | |
{ | |
private static Type HierarchyWindowType; |
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
//http://mathworld.wolfram.com/Point-PlaneDistance.html | |
float distanceToPlane(float3 planePosition, float3 planeNormal, float3 pointInWorld) | |
{ | |
//w = vector from plane to point | |
float3 w = - ( planePosition - pointInWorld ); | |
return ( | |
planeNormal.x * w.x + | |
planeNormal.y * w.y + | |
planeNormal.z * w.z | |
) / sqrt ( |
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
private static Vector2 WorldToPixelCoords(Vector3 projectedPoint, Sprite sprite, Transform transform) | |
{ | |
var textureRect = sprite.textureRect; | |
var spriteBounds = sprite.bounds; | |
var localPoint = transform.InverseTransformPoint(projectedPoint); | |
localPoint.x = (localPoint.x - spriteBounds.min.x) / (spriteBounds.size.x); | |
localPoint.y = (localPoint.y - spriteBounds.min.y) / (spriteBounds.size.y); |
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
import Module from 'react-three-renderer/lib/Module'; | |
import PropTypes from 'react/lib/ReactPropTypes'; | |
import events from 'events'; | |
const { EventEmitter } = events; | |
// or shim EventEmitter | |
class UpdateAllObjects extends Module { | |
constructor() { |
Main render:
<React3/>
<scene>
{this.state.gameStarted ? <Game/> : <Title/>}
</scene>
<React3>
OlderNewer