Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / webglcompress.bat
Last active April 7, 2021 11:19
Unity Compress WebGL Build Manually from Commandline (Brotli)
echo off
REM add egg path
set PYTHONPATH=D:/Program Files/Unity2019_4/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Brotli/dist/Brotli-0.4.0-py2.7-win-amd64.egg
REM rename uncompressed data files (because brotli cannot overwrite same file that its packing)
move /Y "F:\Your\Project\Build\uncompressed.wasm.framework.unityweb" "F:\Your\Project\Build\uncompressed.wasm.framework.unityweb2"
move /Y "F:\Your\Project\Build\uncompressed.wasm.code.unityweb" "F:\Your\Project\Build\uncompressed.wasm.code.unityweb2"
move /Y "F:\Your\Project\Build\uncompressed.data.unityweb" "F:\Your\Project\Build\uncompressed.data.unityweb2"
REM compress
@unitycoder
unitycoder / CornerCheat.cs
Created April 7, 2021 12:10 — forked from grapefrukt/CornerCheat.cs
Makes a CircleCollider2D slide smoothly along the inner edge of a rounded EdgeCollider2D
using UnityEngine;
public class CornerCheat : MonoBehaviour {
public CircleCollider2D circle;
public Rigidbody2D body;
EdgeCollider2D edge;
[Range(0, .2f)] public float distanceThreshold = .03f;
[Range(0, 1)] public float dotThreshold = .96f;
@unitycoder
unitycoder / UnityUtils.cs
Created April 14, 2021 09:04 — forked from stonstad/UnityUtils.cs
Locate Unity Assets Which Contain Broken References
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Threading.Tasks;
public class UnityUtils: MonoBehaviour
{
[MenuItem("Tools/Find Broken GUIDs")]
@unitycoder
unitycoder / GrayscaleGradOp.compute
Created April 19, 2021 08:10
compute shader, grayscale and gradient op
// My first pass is a grayscale filter
// and my second "pass" is a gradient operation that requires to look to adjacent pixels.
// https://forum.unity.com/threads/it-is-possible-to-have-a-multipass-compute-shader.1094386/#post-7053916
#pragma kernel CSMain
// ( CPU -> GPU )
Texture2D inputTexture;
// ( GPU -> CPU )
RWTexture2D <float4> outputTexture;
@unitycoder
unitycoder / errors.md
Created April 19, 2021 08:47
maxscript notes

-- Syntax error: at for, expected -- In line: for o -- In line: ) -- Syntax error: at ), expected -- In line: )

Solution: you are missing ( ) from somewhere (like button-do)

@unitycoder
unitycoder / GetAudioURL.cs
Created April 21, 2021 15:10
webrequest callback
// https://forum.unity.com/threads/unitywebrequest-doesnt-work-with-external-servers.1096930/
private IEnumerator GetAudioURL(Action<UnityWebRequest> callback)
{
string url = serverIP.Trim() + ":8088/get-audio=" + UnityWebRequest.EscapeURL(DataHolderBehaviour.Instance.youtubeUrl);
Debug.Log("connecting to: " + url);
using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{
yield return webRequest.SendWebRequest();
callback(webRequest);
}
@unitycoder
unitycoder / DelayedScene.cs
Last active May 11, 2021 05:58
scene manager loader
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DelayedScene : MonoBehaviour
{
public float delay = 2;
public int sceneToLoad = 1;
public bool allowSkip = true;
@unitycoder
unitycoder / youtube.md
Created April 29, 2021 07:53
youtube notes

How to create additional youtube channel

  • login to youtube (with your personal account, not with channel account)
  • click create channel if your profile drop down menu
@unitycoder
unitycoder / CustomParticleCulling.cs
Created April 30, 2021 07:30 — forked from karljj1/CustomParticleCulling.cs
Custom particle culling
using UnityEngine;
public class CustomParticleCulling : MonoBehaviour
{
public float cullingRadius = 10;
public ParticleSystem target;
CullingGroup m_CullingGroup;
Renderer[] m_ParticleRenderers;
@unitycoder
unitycoder / CurvatureImageEffect.shader
Created April 30, 2021 11:49 — forked from MattRix/CurvatureImageEffect.shader
Cavity/Curvature image effect shader based on the Blender node graph in this post: https://blender.community/c/rightclickselect/J9bbbc/
Shader "Milkbag/CurvatureImageEffect"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_LightStrength ("LightStrength", Float) = 0.3
_DarkStrength ("DarkStrength", Float) = 0.3
_Spread ("Spread", Float) = 1.0
[Toggle(USE_MULTIPLY)] _UseMultiply("Use Multiply", Float) = 0
[Toggle(CURVATURE_ONLY)] _CurvatureOnly("Curvature Only", Float) = 0