블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2738)
Unity3D (817)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (70)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (11)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (475)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-29 11:53
using System;

// 1200초(20분) 받아서 시간:분:초 표시하기
TimeSpan ts = new TimeSpan(0, 0, 1200);
string strTemp = string.Format("{0:HH:mm:ss}", ts);

Debug.Log(strTemp);


[날짜/시간 출력 참조]

http://www.csharp-examples.net/string-format-datetime/


반응형
Posted by blueasa
, |
using UnityEngine;

public class SetRenderQueue : MonoBehaviour
{
    public int renderQueue = 3000;

    Material mMat;

    void Start ()
    {
        Renderer ren = renderer;

        if (ren == null)
        {
            ParticleSystem sys = GetComponent< ParticleSystem >();
            if (sys != null) ren = sys.renderer;
        }

        if (ren != null)
        {
            mMat = new Material(ren.sharedMaterial);
            mMat.renderQueue = renderQueue;
            ren.material = mMat;
        }
    }

    void OnDestroy () { if (mMat != null) Destroy(mMat); }
}



출처 : http://www.tasharen.com/forum/index.php?topic=776.msg34546#msg34546

반응형
Posted by blueasa
, |

[링크] http://www.gamecodi.com/board/zboard-id-GAMECODI_Talkdev-no-3545-z-6.htm


게임코디 '뜻밖의'님이 좋은 소스를 공유해 주셔서 링크해 놓습니다.




 Link : https://github.com/Raindayus/unityboot

새프로젝트 만들때마다, 공용 유틸클래스들과, 
프로젝트의 와꾸등을 이전 프로젝트에서 복사해왔는데, 
이게 귀찮아서, 공통 작업들을 "spring boot"같이 "unityboot"라는 프로젝트로 한번 묶어 봤습니다. 
링크를 누르시면 github으로 연결됩니다.

문서화가 안되어 있긴하지만,
뒤적거리시다보면, 뭔가 쓸모 있는게 있으실지도...

아래와 같은 것들이 포함되어 있습니다.

Service 
----
sb : 다국이 지원, Resources/StringBundles/StringBundle.txt 에서 텍스트 편집
bundle : 애셋 번들 다운로드 지원, 씬 / 리소스 다운로드 지원, 멀티 다운로드 지원
goPooler : 게임 오브젝트 풀러, 로컬/리모트 리소스 풀링 가능 (단 GoItem을 상속받은 클래스를 포함한 게임오브젝트만 풀링 가능)
encryption : 3Des 암호화 모듈
sound : 사운드 플레이 관련 서비스
setting : 설정 관련 서비스
time : 시간 관련 서비스

Editor 
----
Builder : 애셋번들 리소스 패커, 씬과 리소스를 아이퐁 / 안드로이드 타켓으로 패킹

Utils
----
AverageFilter : 평균값 필터, 스무스 카메라 개발등에 사용
CameraFade : 페이드인 / 아웃 / 블링크 지원
CsvParser : Csv 파일 파서
DescendantMap : 하위 컴포넌트를 쉽게 찾기 위한 맵, UI작업시 사용 
Ease : easing function 모음
GameObjectExtensions : 게임 오브젝트와 MonoBehaviour 확장
Logger : 로깅 클래스
PersistenceUtil : 파일 저장 / 로드 기능 제공, 암호화기능을 같이 제공
Phantom : 메모리 암호화 관련
Singleton : 싱글턴 클래스
Vector3Extensions : Vector3 기능 확장
WeakReference : 제네릭 WeakReference 클래스
Wheel : 간단한 회전 함수
UIArranger : NGUI 다양한 해상도 대응을 위한 클래스, BOOT_NGUI_SUPPORT 를 Define해줘야 돌아감..

ThirdParty
----
LitJson: Json파싱 모듈
CreatePlane : 간단한 플랜 생성 가능


아래 씬을 열면 테스트 가능합니다. 건저갈만한게 있으시길~
Assets/Demo/Scene/BootDemo/


반응형
Posted by blueasa
, |

유니티로 개발을 하다보면 스크립트에서 public으로 빼놓은 것을 

EditMode(작업모드)에서 바로 적용된 것을 보고 싶을때가 있습니다.

처음에 유니티를 하게되면 항상 ▶버튼을 눌러 실행을 한 후 확인하게 됩니다.


물론 ▶버튼을 눌러서 확인을 해야 하는 경우도 있지만 가볍게 변경된 것을 스크립트를 통해 바로 확인하고 싶을 때 사용하면 좋을 것 입니다.


[ExecuteInEditMode] 를 사용하여 바로 변경되도록 할 수 있는데요.

이 키워드를 스크립트에서 class위에 배치를 하면 Update부분에 적용한 것을 EditMode에서 바로 확인 하실 수 있습니다.


/* 예제 */

/*******************************************************************/

[ExecuteInEditMode]

public class UIRoot : MonoBehaviour

{

void Update()

{

//EditMode이든 실행되는 화면이든 변경되었으면 하는 부분 처리

}

}

/*******************************************************************/ 






위에 두 그림 처럼 Manual Height 의 값을 조정하면 Transform 부분에 Scale 부분에 값이 변하는 것을 확인 하실 수 있을껍니다.

위에 두 그림은 실행모드가 아닌 EditMode임을 말씀 드립니다.




출처 : http://jhc777.tistory.com/65




The functions are not called constantly like they are in play mode.
Update is only called when something in the scene changed.
OnGUI is called when the Game View recieves an Event.

OnRenderObject and the other rendering callback functions are called on every repaint of the Scene View or Game View.


참조 : http://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html

반응형
Posted by blueasa
, |
[파일]

2d 모바일 게임 만들때 유용합니다.
카메라에 붙여서 사용하시면 됩니다.
 
총 6 모드 지원합니다.
전부 보여주기, 좌우비율 맞추기, 가로 고정, 세로 고정, 여백 없음, 늘리기
 
https://gist.github.com/howlryu/6bf4305c96f7dda4a3f4




출처 : http://unitystudy.net/bbs/board.php?bo_table=tip&wr_id=124

반응형
Posted by blueasa
, |

timeScale Lerp – Custom Time Manager

By now I need a timeScale Lerp and this need to be Time.deltaTime independent so, for anyone who needs this too, here’s what I’ve got (C#). You can also use it to create slow motion effects and control the play /pause of your game (assuming that you are using a Time.timeScale dependent approach):

You cal also get this code at GitHub

/// <summary>
/// Time Manager.
/// Time.deltaTime independent Time.timeScale Lerp.
/// Author: Fabio Paes Pedro
/// </summary>
///
/// 

using UnityEngine;
using System.Collections;

public class CustomTimeManager : MonoBehaviour
{
    /// <summary>
    /// CustomTimeManager is Paused or not
    /// </summary>
    [SerializeField]
    private bool _isPaused = false;
    /// <summary>
    /// CustomTimeManager is Fading (from _minScale to _scale or vice-versa)
    /// </summary>
    [SerializeField]
    private bool _isFading = false;
    /// <summary>
    /// CustomTimeManager will pause after fading (is going from _scale to _minScale)
    /// </summary>
    [SerializeField]
    private bool _willPause = false;

    [SerializeField]
    private float _scale = 1f;
    private float _fadeToScaleDifference = 0f;
    private float _scaleToFade = 0f;
    [SerializeField]
    private float _deltaTime = 0f;
    private float _lastTime = 0f;
    private float _maxScale = 3f;
    private float _minScale = 0f;
    private bool _fadeToScaleIsGreater = false;



    #region PseudoSingleton
    private static CustomTimeManager _instance;
    public static CustomTimeManager Instance
    {
        get
        {
            return _instance;
        }
    }
    void Awake()
    {
        if (_instance != null) Debug.LogError("There's another instance of " + this + " already");
        _instance = this;
    }
    void OnDestroy()
    {
        _instance = null;
    }
    #endregion


    void Start()
    {
        Scale = Time.timeScale;
        StartCoroutine("UpdateDeltaTime");
    }

    public bool WillPause
    {
        get
        {
            return _willPause;
        }
    }

    public bool IsFading
    {
        get
        {
            return _isFading;
        }
    }

    public bool IsPaused
    {
        get
        {
            return _isPaused;
        }
    }


    /// <summary>
    /// Time.timeScale independent deltaTime
    /// </summary>
    /// <value>
    /// time.timeScale independent Delta Time
    /// </value>
    public float DeltaTime
    {
        get
        {
            return _deltaTime;
        }
    }

    /// <summary>
    /// Getter and Setter for the CustomTimeManager Scale (time.timeScale). This will set IsPaused to true automatically if the scale == 0f
    /// </summary>
    /// <value>
    /// Scale (Time.timeScale)
    /// </value>
    public float Scale
    {
        get
        {
            return _scale;
        }
        set
        {
            _scale = value;
            _scale = _scale < _minScale ? _minScale : _scale > _maxScale ? _maxScale : _scale;
            Time.timeScale = _scale;
            _isPaused = _scale <= 0.001f;
            if (_isPaused)
            {
                _scale = 0f;
                _willPause = false;
            }
        }
    }

    /// <summary>
    /// Pause toggle (Changes the "IsPaused" flag from true to false and vice-versa)
    /// </summary>
    /// </param>
    /// <param name='time'>
    /// Time until Pause or Play
    /// </param>
    /// <param name='playScale'>
    /// Play scale.
    /// </param>
    public void TogglePause(float time = 0f, float playScale = -1f)
    {
        StopStepper();
        // WillPause == true means that a "Pause" was already called: this will make "WillPause" change to false and call "Play" function. 
        // Else just toggle.
        _willPause = _willPause == true ? false : !_isPaused;
        if (_willPause)
        {
            Pause(time);
        }
        else
        {
            Play(time, playScale);
        }
    }

    void StopStepper()
    {
        _instance.StopCoroutine("FadeStepper");
    }

    /// <summary>
    /// CustomTimeManager Pause
    /// </summary>
    /// <param name='time'>Fading time until Time.timeScale == 0f</param>
    public void Pause(float time = 0f)
    {
        if (Mathf.Approximately(time, 0f))
        {
            _willPause = false;
            _instance.StopCoroutine("FadeStepper");
            Scale = 0f;
        }
        else
        {
            _willPause = true;
            FadeTo(0f, time);
        }
    }

    /// <summary>
    /// CustomTimeManager Play 
    /// </summary>
    /// <param name='time'>
    /// Fading time until Time.timeScale == scale param
    /// </param>
    /// <param name='scale'>
    /// Final scale for Time.timeScale
    /// </param>
    public void Play(float time = 0f, float scale = 1f)
    {
        if (Mathf.Approximately(time, 0f))
        {
            _instance.StopCoroutine("FadeStepper");
            Scale = scale;
        }
        else
        {
            FadeTo(scale, time);
        }
    }

    /// <summary>
    /// CustomTimeManager Scale Fading.
    /// </summary>
    /// <param name='scale'>
    /// The final Time.timeScale
    /// </param>
    /// <param name='time'>
    /// The transition time to reach the desired scale
    /// </param>
    public void FadeTo(float scale, float time)
    {
        _instance.StopCoroutine("FadeStepper");
        _scaleToFade = scale;
        _fadeToScaleDifference = scale - _scale;
        _fadeToScaleIsGreater = _fadeToScaleDifference > 0f;
        float scalePerFrame = _fadeToScaleDifference / time;
        _instance.StartCoroutine("FadeStepper", scalePerFrame);
    }

    /// <summary>
    /// Coroutine to fade the Unity's timeScale
    /// </summary>
    IEnumerator FadeStepper(float scalePerFrame)
    {
        bool achieved = false;
        _isFading = true;
        while (achieved == false)
        {
            Scale += scalePerFrame * _deltaTime;
            if (_fadeToScaleIsGreater)
            {
                achieved = _scale >= _scaleToFade;
            }
            else
            {
                achieved = _scale <= _scaleToFade;
            }
            yield return null;
        }
        Scale = _scaleToFade;
        _isFading = false;
        _willPause = false;
    }

    /// <summary>
    /// Updating our internal _deltaTime
    /// </summary>
    IEnumerator UpdateDeltaTime()
    {
        while (true)
        {
            float timeSinceStartup = Time.realtimeSinceStartup;
            _deltaTime = timeSinceStartup - _lastTime;
            _lastTime = timeSinceStartup;
            yield return null;
        }
    }

}



출처 : http://fliperamma.com/timescale-lerp-custom-time-manager/

반응형
Posted by blueasa
, |
IEnumerator fImageDownCheck() {

WWW www = new WWW(_url);
yield return www;

if(www.size == 0) {
mImage = true;
StopCoroutine("fImageDownCheck");
}  else {
noticeManager.fNoticeTextureMake(www.texture);
Debug.Log("Image Save");
//	Texture2D savedTexture = _materialToSave.mainTexture as Texture2D;
       Texture2D newTexture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.ARGB32, false);
 
             newTexture.SetPixels(0,0, www.texture.width, www.texture.height, www.texture.GetPixels());
       newTexture.Apply();
             byte[] bytes = newTexture.EncodeToPNG();
Debug.Log(bytes);
            File.WriteAllBytes(Application.temporaryCachePath+"/"+"test.png", bytes);
}
}
Application.temporaryCachePath 폴더 : /var/folders/dy/********************/T/DefaultCompany/ProjectName 에 저장 됩니다.




출처 : http://gods2000.tistory.com/67

반응형

'Unity3D > Script' 카테고리의 다른 글

다중 해상도 비율 고정 카메라  (0) 2015.04.21
timeScale Lerp for Unity 3D: Custom Time Manager  (0) 2015.03.09
Load Textrue with WWW  (0) 2014.12.02
OnGUI() 상에서 마우스 더블 클릭 구현  (0) 2014.11.20
LightMap 동적 로딩.  (0) 2014.10.01
Posted by blueasa
, |

Load Textrue with WWW

Unity3D/Script / 2014. 12. 2. 00:59

[WWW.texture] : http://docs.unity3d.com/ScriptReference/WWW-texture.html

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
    IEnumerator Start() {
        WWW www = new WWW(url);
        yield return www;
        renderer.material.mainTexture = www.texture;
    }
}



[WWW.LoadImageIntoTexture] : http://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html

	// Continuously get the latest webcam shot from outside "Friday's" in Times Square
	// and DXT compress them at runtime
	var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";

function Start () { // Create a texture in DXT1 format renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false); while(true) { // Start a download of the given URL var www = new WWW(url);

// wait until the download is done yield www;

// assign the downloaded image to the main texture of the object www.LoadImageIntoTexture(renderer.material.mainTexture); } }


반응형
Posted by blueasa
, |
void OnGUI()
 {
if (Event.current.clickCount == 2)
{
            Debug.Log("Tap Double Click");
}
 }



반응형

'Unity3D > Script' 카테고리의 다른 글

외부 이미지 다운로드 후 png 파일 저장 하는 방법  (0) 2014.12.02
Load Textrue with WWW  (0) 2014.12.02
LightMap 동적 로딩.  (0) 2014.10.01
좀 더 복잡한 데이터 저장하기  (6) 2014.09.25
Unity Serializer  (0) 2014.09.25
Posted by blueasa
, |

바하무트

유니티 인거죠?

UnityEngine 에 LightmapData 라고 있고,
LightmapSettings 라고 있습니다.

라이트맵을 구으면 텍스쳐가 나올거고 

씬 생성시에 
·미리보기 | 소스복사·
  1. LightmapData[] lightMapArray = new LightmapData[LIGHTMAP_COUNT];  
  2.   
  3. for (int i = 0; i < LIGHTMAP_COUNT; i++)  
  4. {  
  5.     LightmapData data = new LightmapData();  
  6.     data.lightmapFar = Resources.Load("텍스쳐 경로"as Texture2D;  
  7.   
  8.     lightMapArray[i] = data;  
  9. }  
  10.   
  11. LightmapSettings.lightmaps = lightMapArray;  
이런식으로 적용했었는데...

일단 제가 말한 키워드들로 검색해보세요.

저도 이게 테스트때 해본거라...-_-;; 장담을 못드리겠네요 ㅋ



출처 : http://www.gamecodi.com/board/zboard-id-GAMECODI_Talkdev-no-2903-z-1.htm

반응형

'Unity3D > Script' 카테고리의 다른 글

Load Textrue with WWW  (0) 2014.12.02
OnGUI() 상에서 마우스 더블 클릭 구현  (0) 2014.11.20
좀 더 복잡한 데이터 저장하기  (6) 2014.09.25
Unity Serializer  (0) 2014.09.25
Simple C# Unity Serializer  (0) 2014.09.25
Posted by blueasa
, |