Skip to content

Instantly share code, notes, and snippets.

Avatar

Firtina Ozbalikci toxicFork

View GitHub Profile
@toxicFork
toxicFork / MyComponent.jsx
Created Mar 25, 2016
exposing function to child
View MyComponent.jsx
class MyComponent extends React.Component{
constructor(props, context) {
super(props, context);
this.editorControls = null;
this.focusFunction = (objectToFocus) => {
if(!this.editorControls) {
return;
}
View example.md

Main render:

<React3/>
  <scene>
    {this.state.gameStarted ? <Game/> : <Title/>}
  </scene>
<React3>
@toxicFork
toxicFork / UpdateAllObjects.js
Created Mar 2, 2016
react-three-renderer module example
View UpdateAllObjects.js
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() {
@toxicFork
toxicFork / pixel-to-world.cs
Created Jul 7, 2015
Pixel -> World coordinates | World -> Pixel coordinates
View pixel-to-world.cs
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);
@toxicFork
toxicFork / distanceToPlane.glsl
Last active Aug 29, 2015
Algorithm to get the distance of a point in the world to a plane in the world. Gist created for http://wp.me/p1tYzm-38
View distanceToPlane.glsl
//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 (
View HighlightHelper.cs
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class HighlightHelper
{
private static Type HierarchyWindowType;
View HighlightHelper.cs
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class HighlightHelper {
private static readonly Type HierarchyWindowType;
@toxicFork
toxicFork / TextureAtlasSlicer.cs
Last active Nov 24, 2019
TextureAtlasSlicer.cs
View TextureAtlasSlicer.cs
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)
{
@toxicFork
toxicFork / Modification.cs
Created Sep 27, 2014
Modification disposable
View Modification.cs
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) {
You can’t perform that action at this time.