Skip to content

Instantly share code, notes, and snippets.

@peroon
peroon / gist:72463676ac94175b6259
Created June 20, 2014 07:06
ファイルを1行ずつ処理
open( "./text.txt" ) {|f|
f.each {|s|
puts s
}
}
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public static class GameObjectExtensions
{
// 直下の子供のみからコンポネント含むObjectのリストを取得
public static T[] GetComponentsInChildrenBeneath<T>(this GameObject self) where T : Component
@peroon
peroon / gist:f3a50dc975fe5384c5bc
Created June 5, 2015 16:26
直下の子供全削除
using UnityEngine;
public static class TransformExtensions
{
// 直下の子供全削除
public static void DestroyAllChildren(this Transform self)
{
foreach (Transform trans in self) {
Object.Destroy(trans.gameObject);
}
if (Physics.Raycast(ray, out hit) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()){}
iTween.MoveTo(gameObject,iTween.Hash("path",iTweenPath.GetPath("New Path 2"),"time",10f, "orienttopath", true));
using UnityEngine;
using DG.Tweening;
public static class TransformExtensions
{
public static void SmoothLookAt(this Transform self, Vector3 pos, float time)
{
self.DORotate (Quaternion.LookRotation (pos).eulerAngles, time);
}
}
@peroon
peroon / gist:9edce7942fc29c663f9a
Created June 12, 2015 11:34
Orbit Camera マウスでグリグリできる。タッチは未検証
using UnityEngine;
using System.Collections;
// http://twiik.net/articles/realtime-reflections-in-unity-5
public class OrbitCamera : MonoBehaviour {
public Transform target;
public float rotateSpeed = 3.0f;
@peroon
peroon / gist:6d2bcea2c2804bcafe9d
Created June 14, 2015 12:44
Smooth Follow Camera #unity
Import Utility/SmoothFollow.cs
@peroon
peroon / gist:2e5c3eea47238cac7268
Created June 16, 2015 15:26
ピンチインカメラ(エディタではなく端末向け)
using UnityEngine;
using System.Collections;
public class PinchInCamera : MonoBehaviour {
public float minHeight = 1.0f;
public float maxHeight = 10.0f;
private float touchDistance = 0.0f;
private float scaleSpeed = 0.1f;
@peroon
peroon / gist:4b217b16a32a427ab0b4
Created June 17, 2015 07:16
カラーバスシェーダ。赤が強いところだけカラーにする
Shader "Custom/ColorBathRed" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Threshold( "Threshold", Range(0.0, 1.0) ) = 0.5 // added
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
CGPROGRAM