Skip to content

Instantly share code, notes, and snippets.

using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace PvpGame
{
public class GridValue
{
public enum EntityType
@twobob
twobob / gist:84431c58ba65282f450f
Last active August 29, 2015 14:17
Add LOD suffixes to selected files
using UnityEngine;
using UnityEditor;
using System.Collections;
public class AddSuffixLOD : MonoBehaviour {
[MenuItem("Tools/AddSuffix/_LOD0")]
static void AddSuffix0()
{ // Suffixes _LOD0 to the name
AddSuffixViaString("_LOD0");
@twobob
twobob / gist:2f53c1daa835c54648bd
Created March 25, 2015 16:42
UpdateGridOnTrigger.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class UpdateGridOnTrigger : MonoBehaviour {
MonoBehaviour script;
readonly static float TerrainSize = 256f;
void Start(){
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class moveWhenFar : MonoBehaviour {
readonly static float TerrainSize = 256f;
@twobob
twobob / gist:637fd92aac7e1d578396
Last active August 29, 2015 14:17
FlipNormals on mesh (FlipNormals.cs in Editor Folder)
using UnityEngine;
using System.Collections;
using UnityEditor;
public class FlipNormals
{
[MenuItem("Tools/Flip Normals")]
static void FlipMeshNormals()
{ // Flip Mesh Normals on selected mesh(es)
/*
Based on EditorObjExporter.cs and TerrainObjExporter. Exports the current terrain plus selected objects to a single wavefront .obj file.
The approach is to not invert the x axis, as negatives mess with pathfinding libraries like recastnavigation. Instead we swap x and z on everything,
which works perfectly for pathfinding. With recast we just have to swap x and z on the vectors that we give it and get back from it.
This should be put in your "Editor"-folder. Use by selecting the objects you want to export, and select
"Custom->Export Scene" which will export to for_navmesh.obj in the root of your unity project.
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace PvpGame
{
public sealed class Objectpool2<T>
where T : new()
{
@twobob
twobob / gist:0ab2a30ecb92c4627c0d
Created April 9, 2015 14:51
PlaceParticles.cs Place Unity particles individually.
using UnityEngine;
using System.Collections;
public class PlaceParticles : MonoBehaviour
{
public ParticleSystem tree; // plural. like sheep.
public Transform ObjectToPopulateWithParticles;
// a flatish square mesh is a good idea since our helper will take a
// random point sample in the negative Y on a pre-defined square.
@twobob
twobob / GridTracking.cs
Created April 11, 2015 15:11
Reads vector3's from a scriptable object to do the tracking
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GridValue
{
// should we ever need it
public enum EntityType
{
None,
const float2 r = float2(
23.1406926327792690, // e^pi (Gelfond's constant)
2.6651441426902251); // 2^sqrt(2) (Gelfond–Schneider constant)
return frac( cos( fmod( 12345678., 1e-7 + 256. * dot(p,r) ) ) );
// Random, enjoy