unity
targetTransform.worldToLocalMatrixをc#で得て、shaderに渡す shaderの中で mul(unity_ObjectToWorld, v.vertex)で一回ワールド座標系に ワールド座標系から対象の座標系にmul(worldToLocal,vertex)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class HitTest : MonoBehaviour { // Start is called before the first frame update void Start() { } void OnCollisionStay(Collision collision) { Debug.Log("…
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Fusen : MonoBehaviour { #if UNITY_EDITOR [SerializeField, MultilineAttribute (2)] string message; #endif } }
usage descriptionに記述がないのが原因
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MyWebcam2 : MonoBehaviour { private WebCamDevice[] devices; private WebCamTexture webCamTexture; [SerializeField] private Material outputMat; priva…
//using UnityEditor.Recorder; var window = (RecorderWindow)EditorWindow.GetWindow(typeof(RecorderWindow)); if(!window.IsRecording()){ window.StartRecording(); } //stop! if(window.IsRecording()){ window.StopRecording(); } reference How to m…
UnityEditor.EditorApplication.isPaused = true;//pause or resume UnityEditorEditorApplication.EnterPlaymode();//play UnityEditorEditorApplication.ExitPlaymode();//exit
On UnityEditor, when I put my own button on inspector and press it, the Screen.width/Screen.height is wrong. It does not change on update() function. I think this is a very rare phenomenon. Screen.widthがおかしい時があった。 UnityEditor上…
save render texture as png pngとして画像を保存 using System.IO; using UnityEngine; using UnityEngine.Assertions; using UnityEngine.Rendering; using UnityEngine.UI; public class RenderTex2PNG : MonoBehaviour { [SerializeField] private Rende…
Vector3 getMousePos(){ var p = Input.mousePosition; _mousePos.x = 2f*(p.x / (float)Screen.width - 0.5f); _mousePos.y = 2f*(p.y / (float)Screen.height -0.5f); float screenH = (float)_camera.orthographicSize;//OrthographicCameraにおける高さ …
using System.Collections; using System.Collections.Generic; using UnityEngine; public class LineMesh : MonoBehaviour { [SerializeField] private int[] _triangles; // Start is called before the first frame update void Start() { MeshFilter me…
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; public class Duplicator : MonoBehaviour { [SerializeField] protected Mesh _mesh; [SerializeField] protected Material _mat; protecte…
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Duplicator : MonoBehaviour { [SerializeField] private Mesh _mesh; [SerializeField] private Material _mat; private MaterialPropertyBlock _block; pri…
iOSのダイアログを出す github.com _button.onClick.AddListener(_onClick); private void _onClick(){ string url = MyNativeBindings.GetSettingsURL(); CBNativeDialog.Instance.Show(title: "アクセス許可", message: "動画を保存するには写真へのアクセ…
void Update(){ var mousePos = Input.mousePosition; var p = new Vector3( (float)mousePos.x / Screen.width-0.5f, (float)mousePos.y / Screen.height-0.5f, 0 ); hoge.localPosition = new Vector3( p.x*1125,//canvasの大きさ p.y*2436, 0 ); }
gist.github.com
Unity - Scripting API: GraphicsFormat Unity - Scripting API: RenderTextureFormat チャンネルの名称 RGBA D=デプス S=ステンシル 数字=ビット数 8bit=2の8乗=256階調 16bit=2の16乗=65536階調 数値の名称 SNorm=signed normalized=[-1,1]の範囲 UNorm: …
11proで調べた。以下のようなコードで調べられた。 WebCamTexture.devices[i].availableResolutions 前面・背面ともに 192x144 352x288 480x360 640x480 1280x720 1920x1080 3840x2160 で、「横長」。 場合によっては縦横方向を変える必要あり。
assetstore.unity.com using System.Collections; using System.Collections.Generic; using UnityEngine; public class FontGen : MonoBehaviour { int _index = 0; string _texts="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; // S…
Event System - Dispatcher | Integration | Unity Asset Store 有料paid asset using System.Collections; using System.Collections.Generic; using UnityEngine; using com.ootii.Messages; public class EventDispatcher : MonoBehaviour { // Start is …
private void OnGUI(){ if(_style==null){ _style = new GUIStyle(GUI.skin.button); _style.fontSize = 22; _style.normal.textColor = Color.white; } if( GUI.Button(new Rect(0, Screen.height-100, 100, 100),"[BALL]",_style) ){ for(int i=0;i
clip( abs(fmod(round(uvv.x*ss)+stp1,2)-fmod(round(uvv.y*ss+_Time.x)+stp2,2))-0.5 );
Add a new string value to "UIRequiredDeviceCapabilities" available strings Apple Developer Documentation using System.IO; using UnityEditor; using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode; namespace Kitasenju { public class AddPl…
//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…