unity
//using System; System.DateTime.Now.ToString("yyMMddHHmmss");
LayerMaskというのがあるのだが、これは単一のレイヤーを指定するものではないようだ。 enumをinspectorに表示し、ドロップダウンで選び、その値をgameObject.layerにつっこむようにした。 enumを定義 スマートでは無いが、layer名が一致するように文字列を…
インスペクタに独自の型 using UnityEngine; using System.Collections; using System.Collections.Generic; [System.Serializable] public class HogeClass { public string name; public int index2; public int index3; } public class UITest : MonoBeha…
元のComputeScreenPos #define V2F_SCREEN_TYPE float4 inline float4 ComputeScreenPos (float4 pos) { float4 o = pos * 0.5f; //why myltiply by .5f #if defined(UNITY_HALF_TEXEL_OFFSET) o.xy = float2(o.x, o.y*_ProjectionParams.x) + o.w * _Screen…
めちゃくちゃ高速化したー! It's so much faster! 参考 light11.hatenadiary.com コード public override Color32[] GetPixels() { var colors = _texture.GetPixels32(); return colors; } void Update() { if(!IsInit) return; _Request(); } private voi…
cubemap shader for sphere (without skybox) Shader "Unlit/CubeMapForSphere" { Properties { _Cube ("Cubemap", Cube) = "grey" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 100 cull front Pass { CGPROGRAM #pragma vertex vert #pragma frag…
Clone mesh on Unity using System.Collections; using System.Collections.Generic; using UnityEngine; public class MeshUtil { public static Mesh CloneMesh(Mesh m, string name ){ var mesh = new Mesh(); mesh.name = name; mesh.vertices = m.verti…
How to bind bones only on Unity 骨をバインドする方法 Binding on Unity C# · GitHub using System.Collections; using System.Collections.Generic; using UnityEngine; public class BindTest : MonoBehaviour { [SerializeField] private Mesh _mesh; […
手順 BoneWeight[] weightsを頂点数ぶん用意 weights[2].boneIndex0 = 1;//2番目の頂点のウェイトは1番目のボーンの影響下 weights[2].weight0 = 1;//その度合い _mesh.boneWeights = weights;//ウェイトぶちこみ ボーンを用意 ボーン作る。ボーンはgameOb…
関連:https://kitasenjudesign.hatenablog.com/entry/2021/11/13/133126 using System.Collections; using System.Collections.Generic; using UnityEngine; public class LineMesh : MonoBehaviour { [SerializeField] private MeshFilter _meshFilter; [S…
以下の四つ projectSettingのqualityがlowとかになっていないかチェック Sceneのウィンドウの上部で、ライトがオンになっているのをチェック DirectionalLightとかで、shadow castがオンになっているのをチェック 対象物のshadow caster recieverをチェック
count frame every second. using System.Collections; using System.Collections.Generic; using UnityEngine; public class FPSCounter : MonoBehaviour { private int _counter=0; private float _time = 0; public int fps =0; public static int Fps=0;…
render outside safe areaにチェックを入れる
feedbackするためには、現在のフレームframe(t)に過去フレームframe(t-1)を描画する必要がある。 frame(t) = effect( frame(t), frame(t-1) ); ① メインcameraのonRenderImageでrenderTextureAに描画(ノイズ等でずらしたり、位置を動かしたり)。これは描画…
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Rakka : MonoBehaviour { [SerializeField] private Ball[] _prefabs; private int _count=0; void Start() { _loop(); } private void _loop(){ int index =…
string[] youbiAry = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; string[] monthAry = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; var time = DateTime.Now; var hh = time.Hour.ToString("00"); va…
ランダムに線を描く using System.Collections; using System.Collections.Generic; using UnityEngine; public class Lines : MonoBehaviour { [SerializeField] private MeshFilter _meshFilter; private Vector3[] _positions; private Mesh _mesh; // St…
おかしいので trail rendererだけgameObjectを単独にし、使う時だけInstansiateする。
using UnityEngine.VFX; VisualEffect _effect; _effect.Play(); _effect.Stop();
var info = new RenderTextureDescriptor(); info.dimension=UnityEngine.Rendering.TextureDimension.Tex3D; info.colorFormat = RenderTextureFormat.ARGB32; info.width = 512; info.height=256; info.volumeDepth=90; info.depthBufferBits = 0; info.ms…
using UnityEngine; public class SingletonExample : MonoBehaviour { private static SingletonExample _instance; void Awake(){ if (_instance == null){ _instance = this; DontDestroyOnLoad(this.gameObject); //Rest of your Awake code } else { De…
must add order number to write multi line texts [Header("●ARBackgroundからテクスチャを作るクラス",order = 1)] [Space(10,order = 2)] [Header("ARFoundation機能への参照",order = 3)]
Select "output particle quad". Check "use alpha clipping" on inspector.
You can made sine wave sound like this in Unity using UnityEngine; public class SineGanerator : MonoBehaviour { private AudioSource AudioSource; [SerializeField, Range(0, 1)] private float Volume = 1; [SerializeField, Range(100, 1000)] pri…
WebcamをDropdownから選べるようにする using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class WebCamSelector : MonoBehaviour { [SerializeField] private TMP_Dropdown _dro…
複数のdotweenを一つにする 関数名 Append Sequenceの最後にTween/Sequenceを追加する Insert 指定した秒数後に再生開始するTween/Sequenceを追加する Join 直前に追加されたTween/Sequenceと同時再生する Prepend Sequenceの最初にTween/Sequenceを追加する…
slitscan with 3d texture using System.Collections; using System.Collections.Generic; using UnityEngine; public class slitscan3d : MonoBehaviour { public RenderTexture _rt3d; public Material _mat; private WebCamTexture _tex; private int _in…
_distMat.CopyPropertiesFromMaterial(_srcMat)
Unity でクロマキーシェーダを作ってみた - 凹みTips をpost effectで使えるようにしてみました。 Shader "ChromaKey/ChromaKey_PostEffect" { Properties { [Header(Material)] _Color ("Color", Color) = (1, 1, 1, 1) _MainTex("Texture", 2D) = "white" …