Skip to content

Instantly share code, notes, and snippets.

@baobao
baobao / detectCollisions.cs
Created August 21, 2014 23:39
動的にRigidbodyのアクティブを制御するだけ? だったら、enabledのtrue/falseでも良い気がするが。 他に意味があるのかもしれない。 https://bitbucket.org/hoge_foo_bar_piyo/basic-unity/commits/70110ffbe1e9b817ec4dbd088f59fac7b400b108?at=master
//参考
//http://docs.unity3d.com/ScriptReference/Rigidbody-detectCollisions.html
transform.rigidbody.detectCollisions = false;
@baobao
baobao / CoroutineManager.cs
Created August 22, 2014 00:47
コルーチンを一括管理するマネージャークラスをつくろうとしたけど、IEnumratorのAPIが少なくて、断念したソース
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CoroutineManager : MonoBehaviour {
private static int coroutineID = 0;
private Dictionary<int, IEnumerator> _dic;
public object GretCurrent (int id)
@baobao
baobao / AddRange.cs
Last active December 7, 2018 03:51
AddRangeの処理内容 3行目の確認
public void AddRange (IEnumerable<T> collection)
{
if (collection == ) {
throw new ArgumentNullException ();
}
ICollection<T> collection2 = collection as ICollection<T>;
if (collection2 != ) {
this.AddCollection (collection2);
}
else {
@baobao
baobao / SelectedWidgetImage.cs
Created August 24, 2014 05:20
選択したUIWidgetのプレビュー機能
using UnityEngine;
using System.Collections;
using UnityEditor;
/// <summary>
/// 選択したWidget内にある画像を表示する
/// </summary>
public class SelectedWidgetImage : EditorWindow
{
[MenuItem("Window/SelectedWidgetImage")]
static public void Init ()
public static bool TryParse (string s, out float result)
{
return float.TryParse (s, NumberStyles.Any, , out result);
}
@baobao
baobao / coordinate.cs
Created August 26, 2014 23:48
スクリーン座標をワールド座標に変換する From http://bao-bao.postach.io/
static public bool TryGetCoordinate (Vector3 mousePosition, Camera cam, out Vector3 worldPosition)
{
// 3D上の座標を取得したい平面を生成
Plane plane = new Plane (Vector3.up, Vector3.zero);
// インプットスクリーン座標とカメラ位置を通る直線を求める
Ray ray = cam.ScreenPointToRay (mousePosition);
float depth;
// 平面とrayが交差するかチェック
// 第2引数は交差した際に距離(float)が返却される
if (plane.Raycast(ray, out depth))
@baobao
baobao / blender_shortcut.md
Last active December 7, 2018 03:39
Blenderでよく使いそうなショートカット

【space】 ・・・・ツール検索 ctr + ⌥ + 【U】 ・・・ユーザー設定画面表示

【tab】 ・・・モード変更

カーソル

【shift + C】 ・・・3Dカーソルをセンターに持ってくる ※パースペクティブで実行すると全座標原点に移動する

@baobao
baobao / uilabel.swift
Created October 5, 2014 23:16
Helloworld Swift
//
// ViewController.swift
// helloworld-swift
//
// Created by Shunsuke Ohba on 2014/10/04.
// Copyright (c) 2014年 Shunsuke Ohba. All rights reserved.
//
import UIKit
@baobao
baobao / flashlike.swift
Created October 5, 2014 23:16
UIViewのカテゴリ。Flashライクにポジションアクセス
extension UIView
{
var anchorPoint:CGPoint {
get {
return self.layer.anchorPoint
}
set {
self.layer.anchorPoint = newValue
}
}
@baobao
baobao / Sort.cs
Created October 8, 2014 02:32
C#ソート関数
class SortTest {
void Start ()
{
List<Foo> a = new List<Foo> ();
a.Add (new Foo (1));
a.Add (new Foo (100));
a.Add (new Foo (30));
a.Add (new Foo (20));
a.Add (new Foo (99));