Skip to content

Instantly share code, notes, and snippets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
[SerializeField] private float moveSpeed = 2.0f;
[SerializeField] private float moveAngleX = 20.0f;
@kazukitanaka0611
kazukitanaka0611 / TouchMove
Created March 26, 2018 06:16
Unity でマウスの位置に徐々に移動するスクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchMove : MonoBehaviour {
[SerializeField] private GameObject cube;
[SerializeField]private float speed = 2.0f;
// Update is called once per frame
void Update ()
void FixedUpdate ()
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.y = 0.0f;
transform.position = mousePos;
}
@kazukitanaka0611
kazukitanaka0611 / HoloLens Air Tap Create Plane
Last active March 31, 2018 11:24
HoloLens Air Tap Create Plane Gaze rotateion
using UnityEngine;
using HoloToolkit.Unity.InputModule;
using HoloToolkit.Unity.SpatialMapping;
public class TapAndAddWindow : MonoBehaviour, IInputClickHandler
{
[SerializeField]
GameObject prefab;
[SerializeField]
@kazukitanaka0611
kazukitanaka0611 / Mole.cs
Last active April 2, 2018 07:02
Unity whack a mole game 見てわかるUnityゲーム制作超入門 http://www.shuwasystem.co.jp/products/7980html/3849.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mole : MonoBehaviour {
[SerializeField] private float delta = 0.01f;
[SerializeField] private float checkY = 1;
[SerializeField] private float startY = -1;
[SerializeField] private float timeDelta = 0;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mole : MonoBehaviour {
[SerializeField] private float visibleHeight = 0.1f;
[SerializeField] private float hiddenHeight = -0.5f;
[SerializeField] private float speed = 4f;
[SerializeField] private float disappearDuration = 1.25f;
@kazukitanaka0611
kazukitanaka0611 / Unity mouse camera rotate
Created May 15, 2018 07:12
Unity mouse camera rotate
void FixedUpdate ()
{
float X_Rotation = Input.GetAxis("Mouse X");
float Y_Rotation = Input.GetAxis("Mouse Y");
Camera.main.transform.Rotate(0, -X_Rotation, 0);
Camera.main.transform.Rotate(Y_Rotation, 0, 0);
Ray ray = new Ray (Camera.main.transform.position, Camera.main.transform.forward);
Debug.DrawRay(ray.origin, ray.direction * 30f, Color.red);
}
@kazukitanaka0611
kazukitanaka0611 / Singleton
Created May 26, 2018 12:05
Unity Singleton
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour {
private static T instance;
public static T Instance {
get {
//Check if instance already exists
if (instance == null){
@kazukitanaka0611
kazukitanaka0611 / OpenCV For Unity gray
Last active July 14, 2019 02:27
OpenCV For Unityグレースケール変換最小のコード
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using OpenCVForUnity.UnityUtils.Helper;
using OpenCVForUnityExample;
using UnityEngine;
[RequireComponent(typeof(WebCamTextureToMatHelper), typeof(FpsMonitor))]
public class MyFilterSample : MonoBehaviour
{
@kazukitanaka0611
kazukitanaka0611 / OpenCV For Unity thresholdMat
Last active July 14, 2019 02:31
OpenCV For Unity 二値化の最小コード
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using OpenCVForUnity.UnityUtils.Helper;
using OpenCVForUnityExample;
using UnityEngine;
[RequireComponent(typeof(WebCamTextureToMatHelper), typeof(FpsMonitor))]
public class MyFilterSample : MonoBehaviour
{