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

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
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-20 00:00

Unity编辑器类在Scene下显示Lable文字




[csharp] view plaincopy
  1. 在Editor文件夹中创建代码如下  
  2.   
  3. using UnityEngine;  
  4. using System.Collections;  
  5. using UnityEditor;  
  6.   
  7.   
  8. [CustomEditor(typeof(Arraw))]  
  9. public class HandlerTest : Editor {  
  10.   
  11.     Vector3[] positions;  
  12.   
  13.     void OnSceneGUI()  
  14.     {  
  15.         float width = HandleUtility.GetHandleSize(Vector3.zero) * 0.5f;  
  16.         Arraw arraw = (Arraw)target;  
  17.   
  18.         Handles.Label( arraw.transform.position + Vector3.up * 1.5f, arraw.transform.position.ToString()+ "\nAAAA");   //绘制文字, 参数1 为坐标,参数2 为要显示的文字  
  19.    
  20.         if (GUI.changed)  
  21.         {  
  22.              EditorUtility.SetDirty(arraw);  
  23.         }  
  24.   
  25.     }  
  26. }  
  27.   
  28.   
  29.   
  30. Arraw脚本如下,将其拖拽到需要绘制Label的对象上即可  
  31. using UnityEngine;  
  32. using System.Collections;  
  33.   
  34. public class Arraw : MonoBehaviour {  
  35.   
  36.     public float shieldArea = 5;  
  37.   
  38. }  


출처 : http://blog.csdn.net/liqiangeastsun/article/details/42175199

반응형
Posted by blueasa
, |
  1. //Somehow achieves an effect similar to this:
  2. //#define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
  3. Shader "Photoshop/Overlay"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  12. ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend DstColor SrcColor
  13. LOD 110
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert_vct
  18. #pragma fragment frag_mult
  19. #pragma fragmentoption ARB_precision_hint_fastest
  20. #include "UnityCG.cginc"
  21. sampler2D _MainTex;
  22. float4 _MainTex_ST;
  23. struct vin_vct
  24. {
  25. float4 vertex : POSITION;
  26. float4 color : COLOR;
  27. float2 texcoord : TEXCOORD0;
  28. };
  29. struct v2f_vct
  30. {
  31. float4 vertex : POSITION;
  32. fixed4 color : COLOR;
  33. half2 texcoord : TEXCOORD0;
  34. };
  35. v2f_vct vert_vct(vin_vct v)
  36. {
  37. v2f_vct o;
  38. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  39. o.color = v.color;
  40. o.texcoord = v.texcoord;
  41. return o;
  42. }
  43. float4 frag_mult(v2f_vct i) : COLOR
  44. {
  45. float4 tex = tex2D(_MainTex, i.texcoord);
  46. float4 final;
  47. final.rgb = i.color.rgb * tex.rgb * 2;
  48. final.a = i.color.a * tex.a;
  49. return lerp(float4(0.5f,0.5f,0.5f,0.5f), final, final.a);
  50. }
  51. ENDCG
  52. }
  53. }
  54. }




출처 : http://answers.unity3d.com/questions/384550/shader-photoshop-overlay-effect.html

반응형
Posted by blueasa
, |


링크 : http://rcasio80.blogspot.kr/2015/03/wwwloadfromcacheordownload.html

반응형

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

[링크] 에셋번들 로딩 방식 4가지  (0) 2017.03.03
[링크] Unity5-AssetBundleSetting  (0) 2016.07.25
AssetBundle 가이드  (0) 2015.01.26
AssetBundle 버전체크 방식..  (0) 2014.04.21
Unity AssetBundle Dependencies  (0) 2014.03.11
Posted by blueasa
, |

NGUI로 여러 해상도 대응 꽉 채우기

(참조 : http://hanamoni.tistory.com)



 1280x720 해상도 기준


[순서]

1) NGUI-UIRoot.cs 열기.


2) Inspector Window 에서 설정.

    Scaling Style - Constrained On Mobiles

    Content Width - 1280 Fit  (Check)

    Content Height - 720 Fit  (Check)


3) UIRoot-Update() 함수에서 아래를 교체

   [원본]

    mTrans.localScale = new Vector3(size, size, size);


   [변경]

    float fX = (NGUITools.screenSize.x / 1280f);

    float fTemp = (720f * fX);

    float fY = NGUITools.screenSize.y / fTemp;

    mTrans.localScale = new Vector3(size, size * fY, size);





[참조 링크의 내용]


NGUI 새로운 버젼.. 


해상도가 안맞아서 해상도에 맞게 늘릴려고 만든. 코드.


UIRoot 에서


기준을 1280 X 720 할때.


Inspector Window 에서 설정.

Scaling Style - Constrained On Mobiles

Content Width - 1280 Fit  Check 

Content Height - 720 Fit  Check



UIRoot 스크립트 에서  변경.



void Update ()  에서.


mTrans.localScale = new Vector3(size, size, size);  < -  이코드를 




float x_value = (screen.x / 1280f);

float temp_value = (720f * x_value);

float y_value = screen.y / temp_value;


mTrans.localScale = new Vector3(size , size * y_value, size );


요렇게 변경하면


기준 1280 x 720 으로 잡고 모든해상도에 맞게 잘 늘어나거나 줄어든다.

반응형
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
, |


링크 : http://jinhomang.tistory.com/category/Unity/Unity%205

반응형
Posted by blueasa
, |

[파일]


$NShader.zip



위 파일 설치하면 됨..



[참조]

Ok. Here's small update:
http://www.jostavo.net/NShader.rar (it's a new fork for 2013 by SilentSouls that uses embedded coloring, the one Nims mentioned before)

I've added support of .shader.compute.cginc (sorry just handling not native support, see attach)

*optional* - in VisualStudio go Tools > Extensions and Updates find NShader and uninstall it, reboot studio (it need to be restarted to remove files)
Make sure Visual Studio is closed

Who afraid to download my file, install one from jostavo.net and then create and add .reg:
For future updates:
{af99cc5c-2a8a-3547-b255-896525bc39d1} - is UUID for current build only!

To find one You needed - open NShader.pkgdef and look for:
Or after install go
There will be yours.
 

Attached Files:




[출처] http://forum.unity3d.com/threads/tutorial-how-to-use-nshader-with-unity-shaders.108995/

반응형
Posted by blueasa
, |

"Infinite Scrolling" for Unity3D Using NGUI's UIScrollView (1st attempt)

For latest update please check this post instead 
I've been using NGUI for UI related work on my Unity project for the past few weeks and it is a breath of fresh air when compared to the stock UnityGUI (OnGUI()).

Part of my project relate to display a relatively large amount of data dynamically (well not very large but in thousands) and instantiating a prefab for each data element didn't seem like a good idea to me :-)

So instead I decided to add some logic to do a scroll view with fixed pool of items that I reuse and position according to the direction of the scroll and get it fed with the correct data. 

Although I am sure that there are existing solutions I decided to do my own.

The logic so far is built using UIGrid with fixed cell height for the moment (not well suited for UITable with different cell height) and the panel is using soft clip. the Scroll view is using momentum only (Spring physics breaks my current logic for some reason)

Initialization steps: 
  1. Pool size is calculated using the cell height against the panel height plus some buffer (currently I am using a buffer of 4 list items)
  2. List items' pool is instantiated with corresponding data from the data list
  3. A map is maintained to keep track of which data item are used in which list items
While Scrolling:
  1. Any item that turns a visible from an invisible state will notify the main controller
  2. We check the direction of the scroll based on which item is visible (e.g. if the next item is visible means that we are dragging upwards)
  3. based on the direction we reuse the items at the top or the bottom of the list accordingly (e.g. if direction is up the top item moves to the bottom and get populated with data from the corresponding data element)

 

 This is a first attempt and further posts will follow as the logic evolve.

==UPDATE==
I am in the process of making this component available as open source.
Meanwhile we've launched a free app on Android that uses it called Avatar Messenger
==UPDATE 2==
 The component is available as open source
https://github.com/OrangeLabsUK/InfiniteList_NGUI



[파일]

InfiniteList_NGUI-master.zip



출처 : http://www.geekyhamster.com/2013/12/infinite-scrolling-for-unity3d-using.html

반응형

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

NGUI UI의 현재 위치 표시하기[수정중]  (0) 2015.05.08
NGUI 다양한 해상도 대응하기  (2) 2015.04.21
NGUI: Symbols & Emoticons  (0) 2015.02.12
NGUI Emoticons  (0) 2015.02.12
NGUI UILabel로 Emoticon 넣기..  (0) 2015.02.12
Posted by blueasa
, |


Link : http://forum.unity3d.com/threads/the-asset-bundle-cant-be-loaded.240015/

반응형
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
, |