Skip to content

Instantly share code, notes, and snippets.

Avatar

takashi1975 takashi1975

View GitHub Profile
View RPScreenWriter.swift
import Foundation
import AVFoundation
import ReplayKit
class RPScreenWriter {
// Write video
var videoOutputURL: URL
var videoWriter: AVAssetWriter?
var videoInput: AVAssetWriterInput?
// Write audio
@takashi1975
takashi1975 / RoundTrip.cs
Created Sep 13, 2020
Unity ゲームオブジェクトの往復移動
View RoundTrip.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Lerpでゲームオブジェクトを移動させる
///
/// [参考URL]
/// UnityでLerpを使って収縮運動や往復運動をさせる
/// https://getabakoclub.com/2020/01/30/lerp%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E5%8F%8E%E7%B8%AE%E9%81%8B%E5%8B%95%E3%82%84%E5%BE%80%E5%BE%A9%E9%81%8B%E5%8B%95%E3%82%92%E3%81%95%E3%81%9B%E3%82%8B/
@takashi1975
takashi1975 / hanoi.js
Last active Jan 26, 2020
ハノイの塔
View hanoi.js
/**
* 「解く手順を考えた結果、再帰でできそうだ、という流れ」 の解説図がわかりやすいです。
* https://qiita.com/ting/items/134b37bbeb756655ca6b
*/
//ハノイの塔(再帰関数)
function hanoi(saucer, from, to, work) {
if (saucer == 0) return;
//ハノイの塔 再帰呼び出し
@takashi1975
takashi1975 / Aim1.cs
Last active Nov 14, 2019
Quaternion.LookRotation 例
View Aim1.cs
//目標の方を向く例 1
public class Aim : MonoBehaviour
{
[SerializeField]
private GameObject _target;
void Update()
{
var directionToFace = this._target.transform.position - this.transform.position;
View RayHit.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RayHit : MonoBehaviour
{
[SerializeField]
private GameObject _hitObject = null;
public GameObject HitObject {
get { return this._hitObject; }
@takashi1975
takashi1975 / DrawLineManager.cs
Created Jul 24, 2019
Unity DrawLine multi (いったん描画したら機能停止させる)
View DrawLineManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawLineManager : MonoBehaviour
{
[field: SerializeField]
public GameObject prefabDrawLine { get; private set; }
[field: SerializeField]
@takashi1975
takashi1975 / DrawLine.cs
Created Jul 23, 2019
Unity LineRender (マウスで線を描く)
View DrawLine.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
* https://unitycoder.com/blog/2017/08/27/drawing-lines/
*
* Unity ver.2018.3.13f1 で確認
*/
@takashi1975
takashi1975 / Userdefaults+Extension.swift
Last active Jul 18, 2018
[Swift] Userdefaults+Extension (デフォルト値の考慮)
View Userdefaults+Extension.swift
extension UserDefaults {
//Get (デフォルト値あり)
internal static func get<T>(key: String, defaultValue: T) -> T {
let userdefaults = UserDefaults.standard
if userdefaults.object(forKey: key) != nil {
//Float
View BallTap.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallTap : MonoBehaviour, TapBehaviour {
/** タッチしたとき */
public void TapDown(ref RaycastHit hit) {
Debug.Log("TapDown : " + hit);
View sample.swift
override func viewWillDisappear(_ animated: Bool) {
/**
* UINavigationControllerの戻る[back]処理のイベントを取得する方法
* https://qiita.com/syamaoka/items/509ff50fcab485347600
* ... viewWillDisappearが呼ばれる時に、戻る処理を行っていれば、NavigationControllerのviewControllersの中にselfは存在していない
*/
if let viewControllers = self.navigationController?.viewControllers {
let existsSelfInViewControllers = viewControllers.filter{$0 == self}.count == 0
if existsSelfInViewControllers {