Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / RaylibTest.cs
Created December 8, 2019 20:22
Using raylib.dll in Unity
// https://unitycoder.com/blog/2019/12/09/using-raylib-dll-in-unity
using UnityEngine;
using Raylib;
using rl = Raylib.Raylib;
using Color = Raylib.Color;
public class RaylibTest : MonoBehaviour
{
void Start()
@unitycoder
unitycoder / FocusReplacer.cs
Created December 17, 2019 17:39
Unity F Frame Object Finally Fixed - Helper Script
// https://forum.unity.com/threads/f-for-frame-selected-why-does-it-zoom-out-so-much.502796/#post-5291352
using UnityEditor;
using UnityEngine;
public class FocusReplacer
{
[MenuItem("Edit/Focus Selected _f")]
static void Focus()
{
if (Selection.activeObject == null)
@unitycoder
unitycoder / PlaceOnTerrain.cs
Created December 18, 2019 15:20
Drop Object To Terrain (Editor Script)
// from package https://assetstore.unity.com/packages/tools/terrain/tom-s-terrain-tools-527
using UnityEngine;
using UnityEditor;
namespace TTT
{
public class PlaceOnTerrain : ScriptableObject
{
@unitycoder
unitycoder / ipad-reset.txt
Last active December 19, 2019 19:50
ipad hard reset stuck at "ipad activation could not be completed"
ERRORS:
"ipad activation could not be completed"
"we’re sorry, we are unable to continue with your activation at this time."
SOLUTION
- switch to another wifi,
- connect to pc, install itunes from microsoft store
- login to itunes with account (not sure if needs to be original account)
- itunes, help, diagnostics (do network tests)
- keep clicking try again on ipad
@unitycoder
unitycoder / focus.cs
Created January 15, 2020 11:49
Camera zoom extends all
// https://forum.unity.com/threads/fit-object-exactly-into-perspective-cameras-field-of-view-focus-the-object.496472/#post-3229700
float cameraDistance = 2.0f; // Constant factor
Vector3 objectSizes = bounds.max - bounds.min;
float objectSize = Mathf.Max(objectSizes.x, objectSizes.y, objectSizes.z);
float cameraView = 2.0f * Mathf.Tan(0.5f * Mathf.Deg2Rad * camera.fieldOfView); // Visible height 1 meter in front
float distance = cameraDistance * objectSize / cameraView; // Combined wanted distance from the object
distance += 0.5f * objectSize; // Estimated offset from the center to the outside of the object
camera.transform.position = bounds.center - distance * camera.transform.forward;
@unitycoder
unitycoder / VFace.shader
Created January 27, 2020 17:00
VFace Fragment Shader
Shader "Unlit/VFace"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Transparent" }
Cull Off
@unitycoder
unitycoder / Streamer.cs
Created January 30, 2020 08:34
Stream to Youtube from Unity?
// https://stackoverflow.com/questions/59971550/transmitting-the-video-to-youtube-streaming-api-v3-with-unity
{
private Thread thread;
IEnumerator Start()
{
// GOOGLE API KEYS
var clientId = "";
var clientSecret = "";
var code = ""; // LEAVE IT
@unitycoder
unitycoder / Standard Triplanar Slots.shader
Last active January 28, 2023 23:50
Keijiro Standard Triplanar Shader with Added Glossiness and Metallic Texture Slots (and updated material inspector)
// Standard shader with triplanar mapping
// https://github.com/keijiro/StandardTriplanar
Shader "Standard Triplanar Slots"
{
Properties
{
_Color("", Color) = (1, 1, 1, 1)
_MainTex("", 2D) = "white" {}
@unitycoder
unitycoder / win10-mixed-reality.txt
Created February 3, 2020 07:43
Windows Mixed Reality setup in Windows 10 (Enterprise setup)
- set this registry value: https://www.windowscentral.com/how-to-unlock-mixed-reality-settings-windows-10
- do the powershell & group policy settings here: https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development
- reboot computer
- can also run windows update and update GPU drivers
// ERRORS (if didnt do those steps above)
"Couldn't install Windows Mixed Reality"