Skip to content

Instantly share code, notes, and snippets.

@vend9520
vend9520 / Blink.cs
Created January 10, 2018 08:11
TextかImageを点滅させる
@vend9520
vend9520 / Viewer.cs
Created October 15, 2016 18:51
3Dモデルビューワのような機能
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Viewer : MonoBehaviour {
public float maxAngle = 60.0F; //垂直方向に回転できる上限角度
public float minAngle = 300.0F; //垂直方向に回転できる下限角度
public float rotateSpeed = 30.0f; //回転速度(角度/秒)
@vend9520
vend9520 / Pinch.cs
Created October 15, 2016 18:38
ピンチイン/ピンチアウトでモデルを拡大/縮小する処理
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Pinch : MonoBehaviour {
public float pinchSpeed = 0.05f; //ピンチ時移動速度
private GameObject camera; //メインカメラ
private Vector2[] beforePoint; //1フレーム前のポイント(各指)
@vend9520
vend9520 / ParallelMove.cs
Last active October 15, 2016 18:18
2本指スワイプでカメラを並行移動する処理
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ParallelMove : MonoBehaviour {
public float moveSpeed = 0.05f; //スワイプ時移動速度
private GameObject camera; //メインカメラ
private Vector2[] beforePoint; //1フレーム前のポイント(各指)
@vend9520
vend9520 / Rotate.cs
Created October 15, 2016 17:50
スワイプでオブジェクトを中心に回転する処理
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Rotate : MonoBehaviour {
public float maxAngle = 60.0F; //垂直方向に回転できる上限角度
public float minAngle = 300.0F; //垂直方向に回転できる下限角度
public float rotateSpeed = 30.0f; //回転速度(角度/秒)
@vend9520
vend9520 / TapFocus.cs
Created September 18, 2016 19:03
DOF使用時に選択したオブジェクトへフォーカスを当てる
using UnityEngine;
using System.Collections;
using UnityStandardAssets.ImageEffects;
public class TapFocus : MonoBehaviour {
void Update () {
if (Input.GetMouseButton(0)) {
//レイを生成
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
@vend9520
vend9520 / TapAction.cs
Last active October 16, 2016 06:57
フリック、スワイプの判別処理
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TapAction : MonoBehaviour {
public float flickTime = 0.15f; //フリック判定用 時間しきい値
public float flickMagnitude = 100; //フリック判定用 移動距離
private Vector2 startPosition; //タップ開始ポイント
@vend9520
vend9520 / masterData.cs
Created September 4, 2016 07:59
マスタデータ用クラス
public class masterData {
public int id;
public string name;
public int hp;
public int sp;
}
@vend9520
vend9520 / loadMasterData.cs
Last active September 4, 2016 08:06
CSV形式マスタデータ読み込み
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class loadMasterData : MonoBehaviour {
//データ格納用List
public List<masterData> list = new List<masterData>();
void Awake() {
@vend9520
vend9520 / readText.cs
Last active September 4, 2016 07:51
外部テキストファイルの読み込み
using UnityEngine;
using System.Collections;
public class readText : MonoBehaviour {
void Start () {
//resourcesフォルダ内にあるsampleTextファイルをロード
TextAsset textAsset = Resources.Load("sampleText") as TextAsset;
//ロードした中身をstring型に変換
string text = textAsset.text;