Skip to content

Instantly share code, notes, and snippets.

@takashicompany
takashicompany / UseInterface.cs
Created March 25, 2014 16:34
Unityでシーン内のGameObjectの共通化をInterfaceで行った例。
// 共通化のインターフェース
public interface IMyButton
{
void Press ();
}
// IMyButtonを実装したクラス
public class StartButton : MonoBehaviour, IMyButton
{
public void Press ()
@takashicompany
takashicompany / gist:9091a190af859d9b023e
Created May 13, 2014 16:35
foreach (Transform child in gameObject.transform)でgameObjectの子オブジェクトを参照する
foreach (Transform child in gameObject.transform)
{
// gameObjectの子オブジェクト(child)を操作できる
// 子だけで、孫(子の子)は含まれない
}
@takashicompany
takashicompany / foreach-transform-child
Last active August 29, 2015 14:01
foreach (Transform child in gameObject.transform)でgameObjectの子オブジェクトを参照する
foreach (Transform child in gameObject.transform)
{
// gameObjectの子オブジェクト(child)を操作できる
// 子だけで、孫(子の子)は含まれない
}
int layerMask = 1 << 8;
// PlayerレイヤーにあるオブジェクトとRayが相互作用するか判定します。
if (Physics.Raycast(transform.position,Vector3.down,Mathf.Infinity,layerMask))
{
Debug.Log("RayがGroundに当たりました");
}
@takashicompany
takashicompany / LayerMaskSample.cs
Created June 17, 2014 17:55
UnityでLayerMaskをビット演算なしで指定する
public LayerMask mask;
public void IsGrounded()
{
if (Physics.Raycast(transform.position, Vector3.down, Mathf.Infinity, mask))
{
Debug.Log("RayがGroundに当たりました");
}
}
@takashicompany
takashicompany / TwitterAndLinePost.cs
Created June 18, 2014 18:03
Unityでお手軽にTwitter・Line投稿をつくるサンプル
// WebブラウザのTwitter投稿画面を開く
Application.OpenURL("http://twitter.com/intent/tweet?text=" + WWW.EscapeURL("テキスト #hashtag"));
// Lineに投稿
Application.OpenURL("http://line.naver.jp/R/msg/text/?" + WWW.EscapeURL("テキスト", System.Text.Encoding.UTF8));
@takashicompany
takashicompany / HOTween_And_iTween_Sample.cs
Last active August 29, 2015 14:03
HOTweenとiTweenのサンプル
// targetが1秒かけて、座標(0,0,0)へ、イージングをしながら移動する
HOTween.To(
target.transform,
1f,
new TweenParms()
.Prop("position", Vector3.zero)
.Ease (EaseType.EaseOutBack)
);
@takashicompany
takashicompany / AnimationByUpdate.cs
Last active August 29, 2015 14:03
Updateでアニメーションを作る例
void Update()
{
// 1秒で右に10m進む
float speed = 10f;
transform.Translate(Vector3.right * speed * Time.deltaTime);
}
@takashicompany
takashicompany / NoUseCallbackSample.cs
Last active August 29, 2015 14:03
コールバックを使わずに、親クラスが子クラスのアニメーションや処理の終了を取得するサンプル
public Child child;
private IEnumerator StartPlay()
{
child.Play();
while (!child.isComplete)
{
// childのisComplete変数がtrueになるまで待機
yield return new WaitForEndOfFrame();
@takashicompany
takashicompany / ssh_config_sample
Created July 7, 2014 02:24
Gitでsshを使ってcloneする時に、時間がかかるのを対応
Host *
ServerAliveInterval 60
Host github.com
Compression yes
Ciphers arcfour128,arcfour256,arcfour,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc