Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / opt_fsr.fxh
Created June 15, 2022 05:25 — forked from atyuwen/opt_fsr.fxh
An optimized AMD FSR implementation for Mobiles
//==============================================================================================================================
// An optimized AMD FSR's EASU implementation for Mobiles
// Based on https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/master/ffx-fsr/ffx_fsr1.h
// Details can be found: https://atyuwen.github.io/posts/optimizing-fsr/
// Distributed under the MIT License. Copyright (c) 2021 atyuwen.
// -- FsrEasuSampleH should be implemented by calling shader, like following:
// AH3 FsrEasuSampleH(AF2 p) { return MyTex.SampleLevel(LinearSampler, p, 0).xyz; }
//==============================================================================================================================
void FsrEasuL(
out AH3 pix,
@unitycoder
unitycoder / EditPolygonCollider2D.cs
Created June 19, 2022 08:31
Enable PolygonCollider2D editor from script using Reflection (unity)
// https://forum.unity.com/threads/is-it-possible-to-toggle-the-edit-collider-mode-of-a-polygon-collider-2d-via-script.546561/
#if UNITY_EDITOR
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
 
namespace yourCoolNamespace
{
    /// <summary>
@unitycoder
unitycoder / Readme.txt
Created June 20, 2022 19:49 — forked from jcward/Readme.txt
Generating iOS P12 / certs without Mac OSX Keychain (on linux, windows, etc)
1) Generate a private key and certificate signing request:
openssl genrsa -out ios_distribution.key 2048
openssl req -new -key ios_distribution.key -out ios_distribution.csr -subj '/emailAddress=me@example.com, CN=Example, C=US'
2) Upload CSR to apple at: https://developer.apple.com/account/ios/certificate/create
- choose Production -> App Store and Ad Hoc
3) Download the resulting ios_distribution.cer, and convert it to .pem format:
@unitycoder
unitycoder / CheckTouch.cs
Created July 3, 2022 17:37
Check for Touch
using System.Collections;
using System.Collections.Generic;
using UnityEmployees = UnityEngine.Input;
using UnityEngine;
using UnityEditor;
public class CheckTouch : MonoBehaviour
{
// Update is called once per frame
void Update()
@unitycoder
unitycoder / NeRF.md
Last active June 6, 2024 10:21
How to compile Nvidia NeRF (NVlabs / instant-ngp) on Windows 10 and VS 2019

NeRF

Repo: https://github.com/NVlabs/instant-ngp

Steps (see their readme also)

@unitycoder
unitycoder / Unity Wheel Colliders.md
Created July 15, 2022 20:47
How Unity Wheel Colliders Work

// backup from https://forum.unity.com/threads/the-dark-art-of-unity-wheel-colliders-what-unity-doesnt-tell-you.1109261/

I've been working on the physics for a racing game for a while now, and (like many) struggling to get Unity's wheel colliders to behave themselves. I've recently taken some big steps forward, and wanted to share a couple of tricks I discovered along the way, some of them less intuitive than others.

Background : How Unity Wheel Colliders Determine Grip

If you've done anything with wheel colliders you'll already know about the forward and sideways Friction curves, which relate the amount of opposing force generated to the slip the wheel is experiencing. Skip this section if you're already comfortable with the theory of how they work. Or don't - you might be wrong! I was, no end of times.

Focusing on Sideways friction only, there are five values to configure: Extremum Slip, Extremum Value, Asymptote Slip, Asymptote Value, and Stiffness. There are easy-to-find diagrams illustrating the

@unitycoder
unitycoder / Platform_AndroidTV.cs
Created July 17, 2022 08:06 — forked from ChrisNZL/Platform_AndroidTV.cs
Detects Android TV using Unity.
using UnityEngine;
// DERIVED FROM https://stewmcc.com/post/check-for-android-tv-in-unity/
public class Platform_AndroidTV : MonoBehaviour {
#if UNITY_ANDROID
sbyte isAndroidTV = -1; // -1 == not checked yet; 0 == false; 1 == true
@unitycoder
unitycoder / unity YAML.md
Last active August 1, 2022 16:59
unity YAML notes

fileID

For a loose script, the fileID is always 11500000, which is the class ID for MonoScript multiplied by 100,000. https://forum.unity.com/threads/text-based-asset-fileid-guid.203629/#post-1627827

type

  • Type 2: Assets that can be loaded directly from the Assets folder by the Editor, like Materials and .asset files
  • Type 3: Assets that have been processed and written in the Library folder, and loaded from there by the Editor, like Prefabs, textures, and 3D models

Resources

@unitycoder
unitycoder / get_exe_version.c
Created July 28, 2022 21:13 — forked from djha-skin/get_exe_version.c
Get version from EXE file on linux
/* Distributed under the CC-wiki license.
* user contributions licensed under cc by-sa 3.0 with attribution required: https://creativecommons.org/licenses/by-sa/3.0/
* Originally taken from the answer by @rodrigo, found here: http://stackoverflow.com/a/12486703/850326
*/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdint.h>
#include <sys/stat.h>
@unitycoder
unitycoder / vs.md
Last active August 13, 2024 18:22
visual studio notes VS

suddenly errors "Error (active) CS1061 'MainWindow' does not contain a definition for 'chkOpenOutputFolder' and no accessible extension method 'chkOpenOutputFolder' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)"

close vs, delete .vs folder, start vs, if still issues, rename new .vs, undelete original .vs, now works!?

prebuild script to replace timestamp in Version.cs with current timestamp

public static string Stamp = "03-03-2024 12:04:05";

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass -Command &quot;$pattern = 'public static string Stamp = \&quot;.*?\&quot;;'; $date = Get-Date -Format 'dd-MM-yyyy HH:mm:ss'; $replacement = 'public static string Stamp = \&quot;' + $date + '\&quot;;'; $path = '$(ProjectDir)Version.cs'; $content = Get-Content $path -Raw; $newContent = $content -replace $pattern, $replacement; [System.IO.File]::WriteAllText($path,