Skip to content

Instantly share code, notes, and snippets.

@haramakoto
haramakoto / GetScreenMatrix
Created October 16, 2012 00:02
GetScreenMatrix
#define GETSCREENMATRIX GLdouble m[16],l;glGetDoublev(GL_MODELVIEW_MATRIX,m);m[0] = m[5] = m[10] = 1.0;m[1] = m[2] = m[4] = m[6] = m[8] = m[9] = 0.0;glLoadMatrixd(m);
@haramakoto
haramakoto / gist:4538657
Last active December 11, 2015 03:38
Line rendering code in Unity(Pro Only). Add to MonoBehaviour Class.
void OnPreRender() {
GL.wireframe = true;
}
void OnPostRender() {
GL.wireframe = false;
}
@haramakoto
haramakoto / gist:4555853
Created January 17, 2013 13:12
All children's layer to arbitrary layer.
public void SetLayerRecursively(GameObject go, int layerNumber)
{
foreach (Transform trans in go.GetComponentsInChildren<Transform>(true))
{
trans.gameObject.layer = layerNumber;
}
}
@haramakoto
haramakoto / attractorFlag.cs
Created January 28, 2013 14:11
NavMeshのサンプルattractorFlagのCS化
using UnityEngine;
using System.Collections;
public class attractorFlag : MonoBehaviour {
public enum FlagColor { Green, Red, Blue }
public FlagColor flagColor = FlagColor.Green;
public float speed = 0.0f;
@haramakoto
haramakoto / agentLocomotion.cs
Created January 28, 2013 14:14
NavMeshのサンプルコードagentLocomotionのCS化
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (NavMeshAgent))]
public class agentLocomotion : MonoBehaviour {
private string locoState_ = "Locomotion_Stand";
private NavMeshAgent agent_;
private Animation anim_;
private Vector3 linkStart_;
@haramakoto
haramakoto / OVRMoveCheckAndDoSomething.cs
Last active August 29, 2015 13:59
Riftが動いたら何かするコンポーネント
using UnityEngine;
using System.Collections;
/// <summary>
/// Riftが動いたら何かするコンポーネント。OculusUnityIntegrationに含まれる、OVRDevice.csもAddComponentされている必要があります。
/// </summary>
public class OVRMoveCheckAndDoSomething : MonoBehaviour {
#region parameters
float preRotX;
Quaternion ovrRot;
@haramakoto
haramakoto / ParamPrefsSetter
Created July 7, 2014 08:04
ローカルアプリ用の調整パラメータをPlayerPrefsに保存して取り出すやつ
using UnityEngine;
using System.Collections;
public class ParamPrefsSetter : MonoBehaviour {
#region singleton
static ParamPrefsSetter instance;
public static ParamPrefsSetter Instance
{
@haramakoto
haramakoto / MakeA3DObjectDraggable.cs
Last active December 31, 2021 22:41 — forked from SimonDarksideJ/MakeA3DObjectDraggable.cs
How to make a 3D object draggable in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
MAKE A 3D OBJECT DRAGGABLE
Riccardo Stecca
http://www.riccardostecca.net
@haramakoto
haramakoto / GetNearest.cs
Created December 8, 2022 20:48
Linqを用いて一番近いオブジェクトを取り出す
using System.Linq;
List<Transform> targetList;
Transform nearestTrans = targetList.OrderBy( x => (x.position - this.position).magnitude).First();
@haramakoto
haramakoto / ImageNumViewUnit.cs
Created January 25, 2023 01:59
画像で数字を表示する・1桁分
namespace com.etc.utility
{
using UnityEngine;
using UnityEngine.UI;
public class ImageNumViewUnit : MonoBehaviour
{
[SerializeField]
private Sprite[] numSprites;
[SerializeField]