Skip to content

Instantly share code, notes, and snippets.

View kimsama's full-sized avatar
🏠
Working from home

Kim, Hyoun Woo kimsama

🏠
Working from home
View GitHub Profile
@kimsama
kimsama / GreyScale.shader
Created September 27, 2016 06:34
Unity shader file for unlit transparent texture with greyscale effect.
//////////////////////////////////////////////////////////////////////////
// GreyScale.shader
//
// unlit transparent texture with greyscale effect.
//
// (c) 2014 hwkim
//////////////////////////////////////////////////////////////////////////
Shader "Extension/GrayScale"
{
Properties
@kimsama
kimsama / AngleAroundAxis.cs
Created September 15, 2016 04:04
A way to calculate the angle around an axis (make it turn around its head y axis).
public static float AngleAroundAxis (Vector3 dirA, Vector3 dirB, Vector3 axis)
{
// Project A and B onto the plane orthogonal target axis
dirA = dirA - Vector3.Project (dirA, axis);
dirB = dirB - Vector3.Project (dirB, axis);
// Find (positive) angle between A and B
float angle = Vector3.Angle (dirA, dirB);
@kimsama
kimsama / Ghost.shader
Created September 3, 2016 04:59 — forked from tsubaki/Ghost.shader
ghost shader
Shader "FX/Ghost" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_NormalTex ("Normal (RGB)", 2D) = "white" {}
_EmissionTex ("Emission (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Blightness ("Metallic", Range(0,3)) = 0.0
}
@kimsama
kimsama / SerializedObjectEditor.cs
Last active August 12, 2016 08:28 — forked from n-yoda/SerializedObjectEditor.cs
Editor script for Editor window which shows all serializable properties of the selected object. http://ny.hateblo.jp/entry/2014/03/23/051546
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// 「Window/SerializedObject Editor」で起動。
/// 選択中のObjectと関連ObjectからSerializedObjectを作ってPropertyを全て表示する。
/// </summary>
public class SerializedObjectEditor : EditorWindow
#if UNITY_EDITOR
AnimatorController mecanimController = null ;
// Animation Controller 파일을 생성
mecanimController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ( "Assets / Resources / Mecanims / HeroMecanim.controller" );
// Animation Controller에 애니메이션을 전환시키기위한 조건이되는 매개 변수를 추가
mecanimController.AddParameter ( "RunTrigger" , AnimatorControllerParameterType.Trigger);
mecanimController.AddParameter ( "JumpTrigger" , AnimatorControllerParameterType.Trigger);
mecanimController.AddParameter ( "SlidingTrigger" , AnimatorControllerParameterType.Trigger);
mecanimController.AddParameter ( "DownTrigger" , AnimatorControllerParameterType.Trigger);
@kimsama
kimsama / gist:c442b13957d092c1493a
Created March 25, 2016 03:52
http://forum.unity3d.com/threads/standard-shader-how-to-add-lightmap-from-3dsmax-on-uv2.278166/#post-1923095 Modifying the Standard shader is not a way to fix it. Lightmaps should go where they belong and that is the LightmapSettings.lightmaps array. A specific Renderer can then use a lightmap by using its index (Renderer.lightmapIndex) and then…
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class SetLightmapsManually : MonoBehaviour
{
public int m_lightmapIndex = 255;
public float m_lightmapTilingX = 1f;
public float m_lightmapTilingY = 1f;
public float m_lightmapOffsetX = 0f;
@kimsama
kimsama / LoomEditorWindow.cs
Last active March 21, 2016 14:05
scrapped from http://answers.unity3d.com/questions/305882/how-do-i-invoke-functions-on-the-main-thread.html "If anyone is interested I reworked the Loom Class from @whydoidoit 's Unity Gems link to an EditorWindow. This way you can easily thread long processes without locking up the editor window."
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using System.Threading;
using System;
using System.IO;
using System.Linq;
public class LoomEditorWindow : EditorWindow {
@kimsama
kimsama / NGUI-EventTrigger
Last active February 4, 2016 03:14
Various NGUI and its EventTrigger usage on script side.
// with tweening animation...
TweenAlpha transition = TweenAlpha.Begin(FadeOut.gameObject, this.fadeInTime, duration);
transition.from = 0f;
transition.ResetToBeginning();
EventDelegate.Add(transition.onFinished, OnFinished, true);
void OnFinished()
{
// called at the end of alpha tweening animation.
}
@kimsama
kimsama / substitute.vba
Created March 24, 2015 08:05
Excel VBA script which substitute the given data in the ranged multiple cells
Sub MultipleSubs()
Dim rng As Range
Dim cell As Range
Set rng = Sheets("CardDataTable").Range("K2:K323")
For Each cell In rng
cell = WorksheetFunction.Substitute(cell, "_base", "")
Next
@kimsama
kimsama / Unity-GetAllFilesUnderSelectedFoder.cs
Last active August 22, 2024 06:28
Code snip which shows gather all files under selected folder in Unity's Project View
/// <summary>
/// Retrieves selected folder on Project view.
/// </summary>
/// <returns></returns>
public static string GetSelectedPathOrFallback()
{
string path = "Assets";
foreach (UnityEngine.Object obj in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets))
{