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 / gist:9968809
Created April 4, 2014 05:44
did not tried yet but it seems to be a solution to resolve animation event offset problem...
animTime = Mathf.Round(Animation[myBody.attack1].normalizedTime * 10)/10;
if (animTime >= 0.5f) {
//do something
}
@kimsama
kimsama / near.cs
Last active January 8, 2021 08:40
근사값을 구하는 함수 예, 주어진 배열에서 p와 가장 근사한 배열값의 인덱스를 리턴. A function which returns the array index of most approximate value with the p.
/// <summary>
/// 주어진 배열에서 p와 가장 근사한 배열값의 인덱스를 리턴.
/// </summary>
public static int Near(float[] array, float p)
{
float tmp = 0f;
float min = 100f;
float near = 0f;
int found = 0;
@kimsama
kimsama / gist:d3535f21ee20e2e44809
Created June 3, 2014 04:02
특정 디렉토리 아래의 특정 확장자를 가진 파일을 모두 찾아 이에 대한 처리(command)를 하는 powershell script
>$files = Get-ChildItem -rec -Include *.MESH | ForEach-Object -Process ($_.FullName)
>for( $i=0; $i -lt $files.Count; $i++) {
> [command] $files[$i]
>}
>
>
@kimsama
kimsama / GetAssetsOfType.cs
Last active April 12, 2017 15:43
Retrieves certain type of assets with the specified file extension at the given path.
/// <summary>
/// Used to get assets of a certain type and file extension from entire project
/// Usage:
/// UnityEngine.Object[] pagePrefabs = GetAssetsOfType("Resources/Prefabs/PAGE", typeof(GameObject), ".prefab");
/// </summary>
/// <param name="type">The type to retrieve. eg typeof(GameObject).</param>
/// <param name="fileExtension">The file extention the type uses eg ".prefab".</param>
/// <returns>An Object array of assets.</returns>
public static UnityEngine.Object[] GetAssetsOfType(string path, System.Type type, string fileExtension)
{
@kimsama
kimsama / IEnumeratorSample.cs
Last active August 29, 2015 14:07
A sample which runs coroutine method within Update()
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
///
/// Add any IEnumerator function to the queue which to be executed in the Update()
///
public class IEnumeratorSample : MonoBehaviour
{
Queue<IEnumerator> queue = new Queue<IEnumerator>();
@kimsama
kimsama / ShaderMenuUtility.cs
Last active January 19, 2018 02:27
NGUI Tip: A way to apply a shader on one sprite in an atlas. Find UISprite.material property in the UISprite.cs then sustitue it with the following code. It works on NGUI 3.7.0 or higher version.
//////////////////////////////////////////////////////////////////////////
//
// ShaderMenuUtility
//
// Created by hwkim.
//
// Copyright 2014 MonsterSmile.Inc
// All rights reserved
//
//////////////////////////////////////////////////////////////////////////
@kimsama
kimsama / gist:e510e5fbfd8258eb7c44
Last active August 29, 2015 14:16
A VBA script which loads image file into a selected cell then resize cell to fit to loaded size of the image and insert only image filename into the nexe cell of the cell inserted an image.
Sub InsertPicture()
Dim iRange As Range
Dim strMessage As String
Dim x As Variant
Dim filename As String
Set iRange = ActiveCell
Application.ScreenUpdating = False
strMessage = Application.GetOpenFilename(filefilter:="picture(*.JPG;*.GIF;*.BMP;*.PNG),*.JPG;*.GIF;*.BMP;*.PNG", _
Title:="Select an image to insert into the selected cell.")
If strMessage = "False" Then
@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))
{
@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 / 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.
}