dot 형식의 마스크 애니메이션 ( 셰이더 )

이미지
DOT 형식의 마스크 애니메이션을 할 수 있을까 싶어서 셰이더로 만들어 봤다. 장점은 DOT이 아무리 늘어나도 부하가 걸리지 않는 다는 것이다. TEXTURE의 TILE만 늘려주면 되니까! 사용된 텍스쳐들 마스크 이미지. Shader   "Custom/flip_Vertex"  { Properties  { _Color ( "Color" , Color) = (1,1,1,1) _MainTex ( "Albedo (RGB)" , 2D) =  "white"  {} _AlphaTex( "Alpha Tex" , 2D) =  "white"  {} _MaskTex( "Mask Tex" , 2D) =  "white"  {} _AnimRange( "Value" ,Range(-10,10)) = 5 _Angle( "Angle" , Range(-5.0,  5.0)) = 0.0     } SubShader  { Tags  {  "RenderType" = "Opaque"   "Queue" = "Transparent" } cull back CGPROGRAM #pragma  surface surf Lambert vertex:vert noshadow  alpha:fade sampler2D  _MainTex; sampler2D  _AlphaTex; sampler2D  _MaskTex; float  _AnimRange; float  _Angle; fixed4 ...
이미지

GetSpectrumData 사운드에 맞춰 게임오브젝트의 형태 변환

이미지
using  UnityEngine; using  System.Collections; public   class   soundMag  :  MonoBehaviour  {      AudioSource  audio;      float [] spectrum =  new   float [64];      public   GameObject  cube;           void  Start () {         audio = GetComponent< AudioSource >(); } void  Update () {         MusicVisualization();     }           void  MusicVisualization()     {         audio.GetSpectrumData(spectrum, 0,  FFTWindow .BlackmanHarris);         cube.transform.localScale =  new   Vector3 (1,...

유니티 에티터 곡선 연결 노드 만들기

http://gamedevst.tistory.com/category/Unity5

타겟방향을 따라 회전 하기

using  UnityEngine; using  System.Collections; public   class   test_rotation  :  MonoBehaviour  {      public   Transform  target;      Vector3  lookDir;      void  Start () { } void  Update () {                   // 방향은 노멀라이즈 사용         lookDir = (target.position - transform.position).normalized;          Quaternion  from = transform.rotation;          Quaternion  to =  Quaternion .LookRotation(lookDir);         transform.rotation =  Quaternion .Lerp(from, to,  Time .fixedDeltaTime); } }

프레임 레이트 화면에 표시 하기 fps display

http://wiki.unity3d.com/index.php?title=FramesPerSecond 프레임 레이트 화면에 표시 하기 using UnityEngine ; using System.Collections ;   public class FPSDisplay : MonoBehaviour { float deltaTime = 0 . 0f ;   void Update ( ) { deltaTime += ( Time . deltaTime - deltaTime ) * 0 . 1f ; }   void OnGUI ( ) { int w = Screen . width , h = Screen . height ;   GUIStyle style = new GUIStyle ( ) ;   Rect rect = new Rect ( 0 , 0 , w, h * 2 / 100 ) ; style . alignment = TextAnchor . UpperLeft ; style . fontSize = h * 2 / 100 ; style . normal . textColor = new Color ( 0 . 0f, 0 . 0f, 0 . 5f, 1 . 0f ) ; float msec = deltaTime * 1000 . 0f ; float fps = 1 . 0f / deltaTime ; string text = string . Format ( "{0:0.0} ms ({1:0.} fps)" , msec, fps ) ; GUI . Label ( rect, text, style ) ; } }

포커스 컨트롤 사용하기 텍스트 필드 포커스 이동 GUI.FocusControl("");

http://www.devkorea.co.kr/reference/Documentation/ScriptReference/GUI.FocusControl.html GUI .FocusControl( "" ); // 포커스 아웃 // "사용자 이름"Textfield 선택된 때, 버튼을 누르면. var username : String = "username" ; var pwd : String = "a pwd" ; function OnGUI () { //textfield 집합 내부 이름 GUI.SetNextControlName ( "MyTextField" ); // 실제 텍스트 필드를 확인합니다. username = GUI.TextField ( Rect (10,10,100,20), username); pwd = GUI.TextField ( Rect (10,40,100,20), pwd); // 사용자가이 버튼을 누를 경우 키보드 포커스가 이동합니다. if ( GUI.Button ( Rect (10,70,80,20), "Move Focus" )) GUI.FocusControl ( "MyTextField" ); }