Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / Standard-2Sided-FixNormals.shader
Last active October 2, 2023 14:40
Standard Shader - 2 Sided (cull off) - Also, 2 Sided Standard Surface Shader with Fixed Normals
// 2 sided standard surface shader (using 2 passes), with fixed normals for flipped faces
Shader "Custom/TwoSided (FixedNormals)"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
@unitycoder
unitycoder / DllNotFoundException.txt
Last active January 26, 2017 11:14
DllNotFoundException: Magick.NET-Q8-x64.Native.dll
DllNotFoundException: Magick.NET-Q8-x64.Native.dll
ImageMagick.MagickSettings+NativeMagickSettings..ctor ()
ImageMagick.MagickSettings..ctor ()
ImageMagick.MagickImage..ctor ()
ImageMagick.MagickImage..ctor (System.String fileName)
MagicK.CreateWatermark () (at Assets/MagicKNet/MagicK.cs:26)
MagicK.Start () (at Assets/MagicKNet/MagicK.cs:17)
solution: copy missing dll into project root (not inside Assets/, but below it)
@unitycoder
unitycoder / ImageMagick.cs
Last active October 17, 2019 21:55
Using ImageMagick with Unity
// using ImageMagick with unity : http://1darray.com/blog/2017/01/27/using-imagemagick-with-unity/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ImageMagick;
public class ImageMagickTest : MonoBehaviour
{
void Start()
@unitycoder
unitycoder / toggle-ison-false.cs
Created February 1, 2017 02:23
Toggle wont turn off with script
// nothing happens
mytoggle.isOn = false;
// fix: enable [x] Allow Switch Off, in the toggle group
@unitycoder
unitycoder / UniPython.py
Last active February 3, 2017 12:41
UniPython Test
from UnityEngine import GameObject, Vector3, PrimitiveType
from MyScripts import MyCustomClass
for i in xrange(10):
g = GameObject.CreatePrimitive(PrimitiveType.Sphere)
g.name = 'PySphere' + str(i)
g.transform.position = Vector3(i-10, i, 0)
g.AddComponent(MyCustomClass)
c = g.GetComponent(MyCustomClass)
c.someValue = i
@unitycoder
unitycoder / GetBoundsWithChildren.cs
Last active January 11, 2021 14:02
Get Recursive Mesh Bounds
// https://forum.unity.com/threads/fit-object-exactly-into-perspective-cameras-field-of-view-focus-the-object.496472/#post-6712018
public static Bounds GetBoundsWithChildren(this GameObject gameObject)
{
Renderer parentRenderer = gameObject.GetComponent<Renderer>();
Renderer[] childrenRenderers = gameObject.GetComponentsInChildren<Renderer>();
Bounds bounds = parentRenderer != null
? parentRenderer.bounds
: childrenRenderers.FirstOrDefault(x => x.enabled).bounds;
@unitycoder
unitycoder / StopStartCoroutine.cs
Created February 8, 2017 03:59
Stop StartCoroutine before Running it again
if (isRunning == true)
{
abortCoRoutine = true; // then inside coroutine loop, check this and yield break;
yield return 0; // need to wait, otherwise startcoroutine starts before previous one ends
}
StartCoroutine(SlideEffectForOldSlide());
@unitycoder
unitycoder / InspectorButtonsTest.cs
Created February 8, 2017 04:46 — forked from LotteMakesStuff/InspectorButtonsTest.cs
Code running pack! two property drawing scripts that make it super easy to trigger code via buttons in the inspector, and get feedback! [TestButton] draws you little buttons that call a method on your MonoBehaviour, and [ProgressBar] give you a great way to show feedback from long running methods. These are *super* helpful for things like proced…
using UnityEngine;
using System.Collections;
public class InspectorButtonsTest : MonoBehaviour
{
[TestButton("Generate world", "DoProcGen", isActiveInEditor = false)]
[TestButton("Clear world", "ClearWorld", 2, isActiveInEditor = false)]
[ProgressBar(hideWhenZero = true, label = "procGenFeedback")]
public float procgenProgress = -1;
@unitycoder
unitycoder / baseConverter.js
Created February 9, 2017 05:11 — forked from faisalman/baseConverter.js
Convert From/To Binary/Decimal/Hexadecimal in JavaScript
/**
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* https://gist.github.com/faisalman
*
* Copyright 2012-2015, Faisalman <fyzlman@gmail.com>
* Licensed under The MIT License
* http://www.opensource.org/licenses/mit-license
*/
(function(){
@unitycoder
unitycoder / GyroAttitude.cs
Last active January 2, 2023 17:30
Gyroscope Camera Script
// https://www.digikey.com/Site/Global/Layouts/DownloadPdf.ashx?pdfUrl=E7EEB830E57D43B09CE51BD7DF0E74D8
void Start()
{
gyro = Input.gyro; // Store the reference for Gyroscope sensor gyro.enabled = true; //Enable the Gyroscope sensor
}
void Update()
{
if (Time.timeScale != 0)
{