Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / custom-button-vr.cs
Created May 9, 2017 03:42
Create Custom Buttons in Cardboard VR Mode
// cannot use unity UI, because eventsystem gaze blocks it
// but can use OnGUI buttons!
@unitycoder
unitycoder / FastEqualVector3.cs
Created May 4, 2017 13:54
Faster Equal Vector3 Check
// https://twitter.com/JoachimHolmer/status/859974266233794560
// tested with 10million random vectors
// 1100ms
public static bool EqualVector3(Vector3 a, Vector3 b)
{
return a==b;
}
@unitycoder
unitycoder / SmoothMovementTest.cs
Created May 3, 2017 09:21
Smooth Movement Test
//SmoothMovementTest
// https://forum.unity3d.com/threads/smoothmovementtest-should-help-eliminating-hiccup-sources.162694/
using UnityEngine;
using System.Collections;
public class SmoothMovementTest : MonoBehaviour {
public Transform cube;
public Transform cubeRigid;
@unitycoder
unitycoder / check-layer.cs
Last active June 9, 2024 10:22
Check if Layer Exists (by name), Assign Gameobject to layer using LayerMask
// assign gameobject layer using layermask NOTE returns -2147483648 if you havent set the layermask in inspector!
go.layer = (int)(Mathf.Log((uint)layermask.value, 2));
// set layers to children also
foreach (Transform t in go.transform)
{
t.gameObject.layer = (int)(Mathf.Log((uint)layermask.value, 2));
}
// check if layer exists by name
@unitycoder
unitycoder / MoonSharp_Threading.cs
Created May 2, 2017 02:12 — forked from xanathar/MoonSharp_Threading.cs
MoonSharp threading example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MoonSharp.Interpreter;
using MoonSharp.Interpreter.Interop;
namespace Playground
@unitycoder
unitycoder / EventHandlers in MoonSharp
Created May 2, 2017 02:11 — forked from xanathar/EventHandlers in MoonSharp
Sample of event handlers in MoonSharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MoonSharp.Interpreter;
namespace PerformanceComparison
{
class Sample
@unitycoder
unitycoder / Do-Copy.cs
Created May 1, 2017 09:48
Invoke Copy
// you can either select the object and execute a menu command
public static void PerformOperation(string operation)
{
EditorApplication.ExecuteMenuItem("Edit/" + operation);
}
Selection.activeObject = myObj;
PerformOperation("Copy");
// http://answers.unity3d.com/answers/707375/view.html
@unitycoder
unitycoder / Rename.cs
Created May 1, 2017 09:47
Call Rename GameObject manually
// Here's a solution via reflection. This is the same method that gets called when you F2 or Right Click | Rename
[MenuItem("Test/Rename")]
public static void Rename()
{
var type = typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow");
var hierarchyWindow = EditorWindow.GetWindow(type);
var rename = type.GetMethod("RenameGO", BindingFlags.Instance | BindingFlags.NonPublic);
rename.Invoke(hierarchyWindow, null);
}
@unitycoder
unitycoder / SharpNavTest.cs
Created April 21, 2017 13:22
Using SharpNav.dll with Unity
using SharpNav;
using SharpNav.Geometry;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vector3 = UnityEngine.Vector3;
public class SharpNavTest : MonoBehaviour
{
// assign your mesh here, try the example mesh provided in https://github.com/Robmaister/SharpNav/blob/96ddd939f292a4f4e76b460c1f783cdf1e9bcf41/Source/SharpNav.Examples/nav_test.obj
@unitycoder
unitycoder / ld.md
Last active April 21, 2017 10:24
LudumDare#38

Dark / Light

You control the game, not the player

  • rewind, pause?

Parallel Dimensions

  • ..

Pausing has Consequences