[Unity]NGUIã§Unityã®2Dã¹ãã©ã¤ããã¢ãã¡ã¼ã·ã§ã³ãã
NGUI 㧠Unity 4.3 ã® 2D ã¹ãã©ã¤ãã使ãæ¹æ³ã¯ [Unity]NGUIã§Unityã®2Dã¹ãã©ã¤ãã使ã ã«æ¸ãã¾ããã、ä»åã¯ãããã¢ãã¡ã¼ã·ã§ã³ãããæ¹æ³ã§ã。
NGUI ã®ãã¼ã¸ã§ã³ã¯ 3.0.6f6 以éãå¿ è¦ã§ã。
ã¾ãã¯ä¸è¨è¨äºãªã©ãåèã«、Unity 4.3 ã® 2D ã¹ãã©ã¤ã表示ã¨ã¢ãã¡ã¼ã·ã§ã³、NGUI 㧠Unity ã® 2D ã¹ãã©ã¤ã表示ãã§ããã¨ããã¾ã§æºåãã¦ãã ãã。
ãã¨ã¯ SpriteRenderer 㨠Animator ãã¢ã¿ãããã¦、æ°è¡ã®ã³ã¼ãã追å ããã°å®æã§ã。(空ã®ãªãã¸ã§ã¯ãã«ä¸ã®ã³ã¼ãã ãã¢ã¿ããããã°、å¿ è¦ãªã¹ã¯ãªããã¯å ¨ã¦ã¢ã¿ããããã¾ã。)
ã³ã¼ãã¯ä»¥ä¸。( GitHub : unity-ngui/UI2DSpriteAnimation.cs )
ãã¤ã³ã㯠UI2DSprite.nextSprite ã使ããã¨ã§ã。UI2DSprite.sprite ãç´æ¥æ¸ãæããã¨ç¹æ» ãã¾ã。
nextSprite ã¯ç´æ¥ã¢ãã¡ã¼ã·ã§ã³ã§æå®ã§ããªãã®ã§、é表示ã«ãã SpriteRenderer çµç±ã§ã³ãã¼ããå¿ è¦ãããã¾ã。(åè : Animation Curve ãè¨å®ã§ããåã¯ãã¡ã + Unity 4.3 㧠Boolean ã¨ã¹ãã©ã¤ãé¢é£ã追å ããã模æ§)
ã¹ã¯ãªããã追å ããã、Animator Controller ãã¤ã³ã¹ãã¯ã¿ã® Animator ã«ãã©ãã°&ãããããã¦ãã ãã。
ããã§åãã¾ã。
ç¾æç¹ã§ã¯å ¬å¼ããã¥ã¡ã³ãã« UI2DSprite.nextSprite ã®èª¬æ㯠"To be used with animations." ã¨ããæ¸ãã¦ãã¾ããã、ã½ã¼ã¹ã³ã¼ããè¦ãç¯å²ã§ã¯ãã¶ãééã£ã¦ããªãã¨ãããã¾ã。
2013/12/9 è¿½è¨ : UI2DSpriteAnimation.cs ãã¢ã¿ããããã°ä»ã®å¿ è¦ãªã¹ã¯ãªãããã¢ã¿ããããããã¨ã追è¨。
NGUI ã®ãã¼ã¸ã§ã³ã¯ 3.0.6f6 以éãå¿ è¦ã§ã。
ãã¨ã¯ SpriteRenderer 㨠Animator ãã¢ã¿ãããã¦、æ°è¡ã®ã³ã¼ãã追å ããã°å®æã§ã。(空ã®ãªãã¸ã§ã¯ãã«ä¸ã®ã³ã¼ãã ãã¢ã¿ããããã°、å¿ è¦ãªã¹ã¯ãªããã¯å ¨ã¦ã¢ã¿ããããã¾ã。)
ã³ã¼ãã¯ä»¥ä¸。( GitHub : unity-ngui/UI2DSpriteAnimation.cs )
using UnityEngine; using System; [RequireComponent(typeof(UI2DSprite))] [RequireComponent(typeof(SpriteRenderer))] [RequireComponent(typeof(Animator))] public class UI2DSpriteAnimation : MonoBehaviour { System.WeakReference spriteRenderer_ = new System.WeakReference(null); SpriteRenderer spriteRenderer { get { return (spriteRenderer_.Target ?? (spriteRenderer_.Target = GetComponent<SpriteRenderer>())) as SpriteRenderer; } } System.WeakReference ui2dSprite_ = new System.WeakReference(null); UI2DSprite ui2dSprite { get { return (ui2dSprite_.Target ?? (ui2dSprite_.Target = GetComponent<UI2DSprite>())) as UI2DSprite; } } void Reset () { if (spriteRenderer) { spriteRenderer.enabled = false; } } void Update () { if (!spriteRenderer || !ui2dSprite) { return; } spriteRenderer.enabled = false; ui2dSprite.nextSprite = spriteRenderer.sprite; // NOT ui2dSprite_.sprite2D = spriteRenderer_.sprite; } }
ãã¤ã³ã㯠UI2DSprite.nextSprite ã使ããã¨ã§ã。UI2DSprite.sprite ãç´æ¥æ¸ãæããã¨ç¹æ» ãã¾ã。
nextSprite ã¯ç´æ¥ã¢ãã¡ã¼ã·ã§ã³ã§æå®ã§ããªãã®ã§、é表示ã«ãã SpriteRenderer çµç±ã§ã³ãã¼ããå¿ è¦ãããã¾ã。(åè : Animation Curve ãè¨å®ã§ããåã¯ãã¡ã + Unity 4.3 㧠Boolean ã¨ã¹ãã©ã¤ãé¢é£ã追å ããã模æ§)
ã¹ã¯ãªããã追å ããã、Animator Controller ãã¤ã³ã¹ãã¯ã¿ã® Animator ã«ãã©ãã°&ãããããã¦ãã ãã。
ããã§åãã¾ã。
ç¾æç¹ã§ã¯å ¬å¼ããã¥ã¡ã³ãã« UI2DSprite.nextSprite ã®èª¬æ㯠"To be used with animations." ã¨ããæ¸ãã¦ãã¾ããã、ã½ã¼ã¹ã³ã¼ããè¦ãç¯å²ã§ã¯ãã¶ãééã£ã¦ããªãã¨ãããã¾ã。
2013/12/9 è¿½è¨ : UI2DSpriteAnimation.cs ãã¢ã¿ããããã°ä»ã®å¿ è¦ãªã¹ã¯ãªãããã¢ã¿ããããããã¨ã追è¨。
ã³ã¡ã³ã
ã³ã¡ã³ããæ稿