Main render:
<React3/>
<scene>
{this.state.gameStarted ? <Game/> : <Title/>}
</scene>
<React3>
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) | |
{ |
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class HighlightHelper { | |
private static readonly Type HierarchyWindowType; |
class MyComponent extends React.Component{ | |
constructor(props, context) { | |
super(props, context); | |
this.editorControls = null; | |
this.focusFunction = (objectToFocus) => { | |
if(!this.editorControls) { | |
return; | |
} |
Main render:
<React3/>
<scene>
{this.state.gameStarted ? <Game/> : <Title/>}
</scene>
<React3>
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() { |
#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 ) |
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); |
//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 ( |
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class HighlightHelper | |
{ | |
private static Type HierarchyWindowType; |
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) { |