Skip to content

Instantly share code, notes, and snippets.

View yty's full-sized avatar

Terry yty

  • ShangHai
View GitHub Profile
@aras-p
aras-p / ImportMeshUtility.cpp
Created May 31, 2012 15:01
Unity tangent space calculation
// THIS IS ONLY A PORTION OF THE FILE
// WILL NOT COMPILE OUT OF THE BOX!
void OrthogonalizeTangent (TangentInfo& tangentInfo, Vector3f normalf, Vector4f& outputTangent)
{
TangentInfo::Vector3d normal = { normalf.x, normalf.y, normalf.z };
TangentInfo::Vector3d tangent = tangentInfo.tangent;
TangentInfo::Vector3d binormal = tangentInfo.binormal;
@JISyed
JISyed / MoveCamera.cs
Last active November 29, 2022 11:24
Camera movement script in Unity3D. Supports rotating, panning, and zooming. Attach to the main camera. Tutorial explaining code: http://jibransyed.wordpress.com/2013/02/22/rotating-panning-and-zooming-a-camera-in-unity/
// Credit to damien_oconnell from http://forum.unity3d.com/threads/39513-Click-drag-camera-movement
// for using the mouse displacement for calculating the amount of camera movement and panning code.
using UnityEngine;
using System.Collections;
public class MoveCamera : MonoBehaviour
{
//
// VARIABLES
@benblo
benblo / EditorCoroutine.cs
Created April 15, 2014 13:26
EditorCoroutine: coroutines for Unity editor operations. Usage: EditorCoroutine.start(myIEnumerator)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Swing.Editor
{
public class EditorCoroutine
using UnityEngine;
using System.Collections.Generic;
public class HighFreqInput : MonoBehaviour {
struct InputEvent {
public readonly bool keyUp;
public readonly KeyCode keyCode;
public readonly int frame;
public readonly float time;
@simonbroggi
simonbroggi / TouchScriptInputModule.cs
Last active May 7, 2024 09:16
Input Module to use the new unity ui with multitouch from https://github.com/TouchScript
/**
* Input Module to use the new unity ui with multitouch from https://github.com/TouchScript
* Install TouchScript in your unity project, then add an EventSystem and replace the InputModules by this one.
*
*
* Basically modified TouchInputModule from
* https://bitbucket.org/Unity-Technologies/ui/src/5fc21bb4ecf4b40ff6630057edaa070252909b2e/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs?at=4.6
* and changing ProcessTouchEvent to take events from TouchScript
*
* Got the TouchScript stuff from
@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 {
@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;
@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);
@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
@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;
}