Skip to content

Instantly share code, notes, and snippets.

View yty's full-sized avatar

Terry yty

  • ShangHai
View GitHub Profile
// Copyright 2020 nariakiiwatani
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@ssabii
ssabii / LoadAssetBundlesFromUnityWebRequestAsync.cs
Last active December 22, 2022 17:47
UnityWebRequest로 에셋번들을 비동기 방식으로 로드하는 코드
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class LoadAssetBundlesFromUnityWebRequestAsync : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine(LoadAssetBundleAsync());
}
@keenanwoodall
keenanwoodall / NativeCurve
Last active February 18, 2024 06:53
A struct that makes using animation curves with the job system easy.
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using Unity.Collections;
using static Unity.Mathematics.math;
public struct NativeCurve : IDisposable
{
public bool IsCreated => values.IsCreated;
@CloudyWater
CloudyWater / Starfield.shader
Created February 23, 2018 03:31
Conversion of ShaderToy to Unity Shader
Shader "Starfield"
{
Properties
{
_iMouse ("iMouse", Vector) = (0,0,0,0)
_Iterations ("Iterations", int) = 17
_Formuparam ("Formuparam", float) = .53
_Steps ("Steps", int) = 20
_StepSize ("StepSize", float) = .1
_Zoom ("Zoom", float) = .8
@TouiSoraHe
TouiSoraHe / PrefabLightmapData
Created February 7, 2018 02:32
Unity5.x 2017动态加载烘焙贴图
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[ExecuteInEditMode, DisallowMultipleComponent]
public class PrefabLightmapData : MonoBehaviour
{
[System.Serializable]
struct RendererInfo
{
@ousttrue
ousttrue / AlphaClip.cs
Last active May 2, 2018 11:57
A custom timeline track for Unity2017.3. File name must be same as class name at clip and track.
using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class AlphaBehaviour : PlayableBehaviour
{
public float Alpha;
}
@allfake
allfake / Patch Unity Text mesh pro For fix thai vowel Raw
Last active October 5, 2023 02:45
Patch Unity Text mesh pro For fix thai vowel
For Unity 2019 plase use this
==> https://github.com/rutcreate/TextMesh-Pro-Thai
==> 90% of font need to edit for some character
==> or add
==> "com.unity.textmeshpro": "https://github.com/rutcreate/TextMesh-Pro-Thai.git"
==> To manifest.json in your project
==> Unity5 or lower
Manual Patch
@unitycoder
unitycoder / UNITY_MATRIX_IT_MV.shader
Last active October 12, 2023 03:31
UNITY_MATRIX_IT_MV[] Vectors in Shader
UNITY_MATRIX_IT_MV[0].xyz = ???
UNITY_MATRIX_IT_MV[1].xyz = Camera Up
UNITY_MATRIX_IT_MV[2].xyz = Camera Forward
float3 forward = -normalize(UNITY_MATRIX_V._m20_m21_m22);
float3 up = normalize(UNITY_MATRIX_V._m10_m11_m12);
float3 right = normalize(UNITY_MATRIX_V._m00_m01_m02);
float3 cameraUp = unity_CameraInvProjection[1].xyz;
float3 camRight = cross(unity_CameraInvProjection[2].xyz, cameraUp);
@mutoo
mutoo / CircleText.cs
Last active May 31, 2023 03:17
the code is based on Unity3d 4.6.x, the api may changed.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class CircleText : BaseVertexEffect
{
public int radius = 50;
public float spaceCoff = 1f;
@gering
gering / Toolkit
Last active January 25, 2024 12:32
persitent data path handling in Unity with fallback
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 {