This file contains 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 struct DijkstraData | |
{ | |
public float cost; | |
public Node parent; | |
} | |
// Route search as a Dijkstra whose cost between nodes is always 1 | |
protected List<Node> CalcRoute(Node from, Node to) | |
{ | |
List<Node> ret = null; |
This file contains 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 Triangle | |
{ | |
public Vector3[] vertices { get; protected set; } | |
public Triangle(Vector3 vtx0, Vector3 vtx1, Vector3 vtx2) | |
{ | |
vertices = new[] { vtx0, vtx1, vtx2 }; | |
} |
This file contains 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.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
using UnityEditorInternal; | |
using System.Linq; | |
public class TwinBuild : EditorWindow | |
{ | |
public const string configKey = "TwinBuildReimportAsset"; | |
public const char configKeySeparator = ','; |
This file contains 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
// https://forum.unity.com/threads/oblique-near-plane-clipping.194722/ | |
public class Clipper : MonoBehaviour | |
{ | |
Matrix4x4 projection; | |
Camera offscreenCam; | |
void Start () | |
{ | |
projection = camera.projectionMatrix; | |
} |
This file contains 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.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GUIOutSideDraggableSample : MonoBehaviour { | |
public Vector2 mousePos; | |
Vector2 boxSize = new Vector2(100f, 100f); | |
GUIStyle whiteBoxStyle; |
This file contains 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 BoolDataTemplateSelector : DataTemplateSelector | |
{ | |
public DataTemplate TrueTemplate { get; set; } | |
public DataTemplate FalseTemplate { get; set; } | |
public override DataTemplate SelectTemplate(object item, DependencyObject container) | |
{ | |
// Null value can be passed by IDE designer | |
if (item == null) return null; |
This file contains 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 static class IEnumerableExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> Chunks<T>(this IEnumerable<T> list, int size) | |
{ | |
var buf = list; | |
while (buf.Any()) | |
{ | |
yield return buf.Take(size); | |
buf = buf.Skip(size); | |
} |
This file contains 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
Shader "Custom/SimplestGSBillboard" | |
{ | |
Properties | |
{ | |
_Size ("Size", Float) = 1.0 | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" } |
This file contains 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 static class ComputerShaderExtension | |
{ | |
public static void DispatchThreadNum(this ComputeShader cs, int kernel, int threadNumX, int threadNumY, int threadNumZ) | |
{ | |
uint x, y, z; | |
cs.GetKernelThreadGroupSizes(kernel, out x, out y, out z); | |
cs.Dispatch(kernel, Mathf.CeilToInt((float)threadNumX / x), Mathf.CeilToInt((float)threadNumY / y), Mathf.CeilToInt((float)threadNumZ / z)); | |
} | |
} |
This file contains 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
#ifndef NOISE_INCLUDED | |
#define NOISE_INCLUDED | |
// | |
// Description : Array and textureless GLSL 2D simplex noise function. | |
// Author : Ian McEwan, Ashima Arts. | |
// Maintainer : ijm | |
// Lastmod : 20110822 (ijm) | |
// License : Copyright (C) 2011 Ashima Arts. All rights reserved. | |
// Distributed under the MIT License. See LICENSE file. | |
// https://github.com/ashima/webgl-noise |