This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static string[] _persistentDataPaths; | |
| public static bool IsDirectoryWritable(string path) { | |
| try { | |
| if (!Directory.Exists(path)) return false; | |
| string file = Path.Combine(path, Path.GetRandomFileName()); | |
| using (FileStream fs = File.Create(file, 1)) {} | |
| File.Delete(file); | |
| return true; | |
| } catch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/tobspr/GLSL-Color-Spaces/blob/master/ColorSpaces.inc.glsl | |
| /* | |
| GLSL Color Space Utility Functions | |
| (c) 2015 tobspr | |
| ------------------------------------------------------------------------------- | |
| The MIT License (MIT) | |
| Copyright (c) 2015 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shader "Custom/SurfaceDepthTexture" { | |
| 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 | |
| _InvFade ("Soft Factor", Range(0.01,3.0)) = 1.0 | |
| } | |
| SubShader { | |
| Tags { "Queue"="Transparent" "RenderType"="Transparent" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //// get aspect ratio https://stackoverflow.com/a/32593158/5452781 | |
| int sourceWidth = 3000; | |
| int sourceHeight = 2000; | |
| int targetWidth = 1920; | |
| int targetHeight = 1080; | |
| float percent = (new List<float> { (float)targetWidth / (float)sourceWidth, (float)targetHeight / (float)sourceHeight }).Min(); | |
| Size resultSize = new Size((int)Math.Floor(sourceWidth * percent), (int)Math.Floor(sourceHeight * percent)); | |
| Console.WriteLine("size= " + sourceWidth + "x" + sourceHeight + " percent= " + percent + " result=" + (sourceWidth * percent) + "x" + (sourceHeight * percent)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://forum.unity.com/threads/world-globe-with-latitude-and-longitude.992414/#post-6444961 | |
| using UnityEngine; | |
| namespace YourNamespace { | |
| public struct LatLong { | |
| public const float PI = Mathf.PI; | |
| public const float TWO_PI = 2f * PI; | |
| public const float PI_HALF = .5f * PI; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ZigZag-Encoding | |
| --------------- | |
| Maps negative values to positive values while going back and | |
| forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...) | |
| (i >> bitlength-1) ^ (i << 1) | |
| with "i" being the number to be encoded, "^" being | |
| XOR-operation and ">>" would be arithemtic shifting-operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEngine.U2D; | |
| [ExecuteInEditMode] | |
| public class SpriteWaterShape : MonoBehaviour | |
| { | |
| public SpriteShapeController controller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://forum.unity.com/threads/invert-colors-shader.205244/#post-3060583 | |
| Shader "Particles/Negative" { | |
| Properties { | |
| _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) | |
| _MainTex ("Texture", 2D) = "white" {} | |
| _Glow ("Intensity", Range(0,10)) = 1 //Allows color saturation in HDR rendering. | |
| } | |
| SubShader { | |
| Tags { "Queue" = "Transparent" "PreviewType" = "Plane"} | |
| LOD 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/ | |
| /* | |
| ** Photoshop & misc math | |
| ** Blending modes, RGB/HSL/Contrast/Desaturate | |
| ** | |
| ** Romain Dura | Romz | |
| ** Blog: http://blog.mouaif.org | |
| ** Post: http://blog.mouaif.org/?p=94 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### New 2022: install every tool on their default folders! (that is c: usually.. it fixes many problems) | |
| trying to build c++ project: | |
| *command to test with: | |
| cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_GENERATOR_INSTANCE="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" -DNV_INSTALL_FOLDER=bin .. && cmake --build . --config RelWithDebInfo --target install | |
| error when click build: | |
| "could not find specified instance of Visual Studio: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" |