KITASENJU DESIGN BLOG

memo, html, javascript, unity

Entries from 2021-03-01 to 1 month

simple ik

js + p5 https://editor.p5js.org/kitasenjudesign/sketches/43JWJ7gZw var balls = []; function setup() { createCanvas(window.innerWidth, window.innerHeight); for(var i=0;i<10;i++){ var b = new Ball(); balls.push(b); } } function draw() { back…

球 点 一様に

corysimon.github.io

vector3の高速化

【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計 from UnityTechnologiesJapan002 www.slideshare.net public static float Normalize(ref Vector3 v) { // Magnitude関数のインライン化 float mag = (float)S…

Vector2の直交ベクトル

Vector2.Perpendicular

jsonをjavascriptのみでファイル化&DL

Download a json file with javascript only. ref stackoverflow.com code <a id="downloadAnchorElem" style="display:none"></a> var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(storageObj)); var dlAnchorElem = document.getElementById('downloadAnchorElem'); dlAnch…

nativeのアラートを実装する

Unity3d iOS Plugins - How To Call Native iOS Alerts From Unity ? - YouTube iOSPluginCallBacksってgameObjectに名前つけて、以下とiOSPlugin.cs をくっつけたらうごいた。余計なこともやってるかも・・ どこからかiOSPluginCallBacksを呼び出している。…

人を動物に例えると差別的になりがち

豚 犬 猫をかぶる 猿 など

Handheld.Vibrate() does not work with Unity + iOS

If you use Microphone.Start(), the vibration on iOS doesn't seem to work. AudioServicesPlaySystemSound(soundId) on Obj-C does not work as well. Microphone.Start()を使っていると、バイブレーションが動かないようだ。

draggable UI from side to side

for smartphone and pc. 左右にドラッグできるUI タッチまたはマウスダウンで左右にドラッグするスクリプト。 スマホ、PC対応 めんどくさいので、もうつくりたくない・・ using System.Collections; using System.Collections.Generic; using UnityEngine; u…

Quaternionで徐々に対象の回転に向かう

毎フレームこれをやって、徐々に近づけた。 data.rotation = Quaternion.Lerp(data.rotation, tgtRot, 0.05f);

sceneビューのカメラ固定について

sceneビューでオブジェクトを中心にする ゲームオブジェクトが中心になるようにシーンビューをセンタリングするには、Hierarchy でゲームオブジェクトを選択し、マウスをシーンビューへ移動し、F を押します。メニューバーで Edit > Frame Selected を選択し…

Reset AR Foundation

AR FoundationをResetしたときのコード public static void ReloadMain(){ //ARKitリセット _arMeshManager.DestroyAllMeshes(); _arSession.Reset(); _arSession.enabled=false; _arSessionOrigin.enabled=false; Destroy(_arSession.gameObject); DOVirtua…

可視化することによるデバッグ

Debug.Log(Log/Warn/Error) の表示 Inspectorへ表示(できるだけMonoBehaviourにしたり、ScriptableObjectにしたり) 実機で確認必要ある場合はongui等に表示 jsonに書き出す。jsonはprettyにする。 Gizmoで座標に基づく情報を表示。ルートとかアイテムの属…

ヒエラルキーで、子供や孫を取得する

GetComponentsInChildren が入れ子の末端まで取得できる。スーパー便利。 _container.GetComponentsInChildren<MeshRenderer>() ※けどactiveSelf=trueじゃないと取得されないかも その場合は for(int i=0;i</meshrenderer>

iPhoneのUDIDを知る方法

手順1 MacとiPhoneをUSBで接続する 手順2 Finderの左のところにiPhoneが表示されるはずなので、それを選び、図の矢印の辺りをクリック! 手順3 こんな感じに表示が切り替わりますので右クリックして、UDIDをコピーします

enum 2 string

How to get Enum from String YourEnumType parsed_enum = (YourEnumType)System.Enum.Parse( typeof(YourEnumType), your_string );

scriptable object使う

kurokuru.hatenablog.com kan-kikuchi.hatenablog.com techblog.kayac.com 【Unity】今更ScriptableObject入門 - Qiita C# - scriptableObjectの動的に変化する中身の参照方法と中身の変更方法|teratail 動的なデータにはつかわないのか。。

xbox one controller + mac + unity

ドライバー入れる githubにドライバが落ちてる(URL失念 bluetoothでつなげた。ワイヤレスボタン+xboxボタン長押し後、macから接続。 ボタン X = joystick button 4 Y = joystick button 5 A = joystick button 1 B = joystick button 2 L = joystick button…

unity+vscode+macの補完がきかない時

いっぱい記事がでてきて、以下を試したが、どれもうまくいかず アプリ再起動、マック再起動 slnけして、unityのAssets>Open C# project パッケージマネージャーにあるVSCodeのやつを新しく monoをインストーラーで入れ直し setting.jsonのmonoの項目always …

3Dアクションゲーム的にLRジョイスティックでキャラとカメラを動かす

c#

How to move the character and camera with the LR joystick like a 3D action game. charaを動かす(左スティック) CharaControllerを使う。 Unity - Scripting API: CharacterController.Moveを改造。 Charaを進む方向は、カメラが向いている方向を使う…

navmesh

https://monolizm.com/sab/pdf/%E7%AC%AC26%E5%9B%9E_%E3%83%97%E3%83%AC%E3%82%BC%E3%83%B3%E8%B3%87%E6%96%99(Unity%E3%81%AF%E3%81%98%E3%82%81%E3%82%8B%E3%82%88%EF%BD%9ENavMesh%E5%9F%BA%E7%A4%8E%EF%BD%9E).pdf

ARマーカー に関する情報

stackoverflow.com The arcoreimg tool | ARCore | Google Developers

インスペクターにボタンを作る

how to make a button on inspector https://kan-kikuchi.hatenablog.com/entry/CustomEditor_Button ExampleScript.cs using UnityEngine; [ExecuteInEditMode] //エディター再生してない時、動くように? 場合によって使う public class ExampleScript : M…

text color on Gizmo - テキストの色

#if UNITY_EDITOR GUIStyle style = new GUIStyle(); void OnDrawGizmos() { Gizmos.color = new Color(1, 0, 0, 0.5f); Gizmos.DrawCube(transform.position,Vector3.one*0.1f); style.normal.textColor = Color.red; // 通常時の色 UnityEditor.Handles.La…

アニメーションのパラメータ

簡易シミュレーションのとき使う要素 位置 速度(毎フレ、位置にたす) 加速度(速度の変化量、速度をどう変化させるか) 速度の最大値(インフレを起こさないように制限1) 速度の摩擦(インフレを起こさないように制限2) v += a;//aは状況によって変わ…

"FOOTER"