Skip to content

Instantly share code, notes, and snippets.

View p-chin's full-sized avatar

Takahiro Sudoh p-chin

View GitHub Profile
@p-chin
p-chin / GitHubPageJumper.cs
Last active August 29, 2015 14:01
UnityのProjectWindowからAssetを選択して右クリックして出たメニューからgithubのページを開いてくれるEditorTool
using UnityEngine;
using UnityEditor;
public class GitHubPageJumper
{
// ref https://github.com/p-chin/dotfiles
private static readonly string gitHubTeamName = "p-chin";
private static readonly string gitHubRepositoryName = "dotfiles";
private static readonly string gitHubBranchName = "master";
@p-chin
p-chin / DefineSymbolSwitcher.cs
Last active January 3, 2016 00:49
プロジェクトで良く切り替えるScriptDefineSymbolのグループをEditorToolからサクっと切り替えられると便利
using UnityEditor;
public static class DefineSymbolSwitcher
{
private static BuildTargetGroup CurrentPlatform = EditorUserBuildSettings.selectedBuildTargetGroup;
private static void Log() {
UnityEngine.Debug.Log(string.Format("done! Platform: {0}, DefineSymbol: {1}",
CurrentPlatform, PlayerSettings.GetScriptingDefineSymbolsForGroup(CurrentPlatform)));
}
@p-chin
p-chin / Debug.cs
Created October 11, 2013 11:51
開発環境じゃなかったらLogを出さなくする仕組み
#if !DEV
using UnityEngine;
using System.Collections;
/// <summary>
/// 自家製のDebugクラス.
/// Debug.Logの出力をDEV環境以外では空にする為に作った
/// </summary>
public class Debug : MonoBehaviour
{
using UnityEngine;
using System.Collections;
/// TODO 衝突したら何らかの動作を行う様に設計したい
public class ActionTrigger : MonoBehaviour {
public float speed = 3.0f;
void Start () {
}
@p-chin
p-chin / PlayerController.cs
Created September 3, 2013 23:22
https://gist.github.com/p-chin/6098518 を使ったPlayerControllerクラス
using UnityEngine;
using System.Collections;
public class PlayerController : BaseCharactorController {
void Update() {
ReceiveInput(); // player only
}
@p-chin
p-chin / CodingRuleChecker.cs
Created August 4, 2013 14:02
とりあえずは、Assets以下のcsファイル検索まで。 AssetPostProccesser使えば楽なんだけど、任意のタイミングで処理をさせたいから使えない。
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class CodingRuleChecker : Editor
{
[MenuItem("Tools/CheckCodingRule")]
static void Run ()
@p-chin
p-chin / BaseCharactorController.cs
Last active December 20, 2015 08:09
RigidBodyで移動させた方が移動処理的に優しいらしいので書いてみた
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Base charactor controller.
/// ゲームに登場するキャラクターの共通機能を書きたいクラス
/// </summary>
[RequireComponent (typeof (Rigidbody))]
@p-chin
p-chin / Fugu.cs
Created June 9, 2013 00:42
this渡しは参照渡しと同じ意味っぽい
using UnityEngine;
using UnityEditor;
using System.Collections;
public interface IFugu {
int life
{
get;
set;
@p-chin
p-chin / DictionaryExtension.cs
Last active December 17, 2015 18:29
入れ子構造になってるJSONとかパースした場合にDictionaryクラスから入れ子になってるdictionaryの中のvalueを引っ張ってくる拡張メソッド。
using System;
using System.Collections;
namespace P.ExtensionMethods.Dictionary
{
public static class DictionaryExtension {
public static T NestValue<T>(this IDictionary dict, params string[] keys) {
T result = default(T);
IDictionary tmpDict = dict;
for (int i = 0; i < keys.Length; i++) {
@p-chin
p-chin / SetActiveChildrens.cs
Last active December 14, 2015 07:08
【Unity3D】指定したGameObjectの子のactiveを変更する関数。 To change the active function of the children of the specified GameObject. 
private void SetActiveChildrens(GameObject go, bool active)
{
int goChildCount = go.transform.childCount;
for(int i=0; i < goChildCount; i++){
go.transform.GetChild(i).gameObject.SetActive(active);
}
}