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

카테고리

분류 전체보기 (2824)
Unity3D (874)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (236)
협업 (64)
3DS Max (3)
Game (12)
Utility (140)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (52)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

1. Rendering Components 
This group contains all Components that have to do with rendering in-game and user interface elements. Lighting and special effects are also included in this group. 
해당 그룹에 속한 컴포넌트들은 게임안의 렌더링과 사용자 인터페이스 요소안에 쓰여지는 것을 이란다. 빛과 특별한 효과들은 모두 이 그룹에 포함되어 있데유  

  1) Camera  : http://unity3d.com/support/documentation/Components/class-Camera.html
 **새로운 프로젝트를 만들 때 포함된 기본 asset 패키지에 도움이 될만한 카메라 스크립트들(메뉴의 Components->Camera-Control)
  2) Flare Layer(Camera 연계) : http://unity3d.com/support/documentation/Components/class-FlareLayer.html
  3) GUILayer (Camera 연계): http://unity3d.com/support/documentation/Components/class-GUILayer.html
  4) GUI Text : http://unity3d.com/support/documentation/Components/class-GuiText.html
  5) GUI Texture : http://unity3d.com/support/documentation/Components/class-GuiTexture.html
  6) Halo (후광) : http://unity3d.com/support/documentation/Components/class-Halo.html
  7) Halo Layer(Camera 연계) : http://unity3d.com/support/documentation/Components/class-HaloLayer.html
  8) Lens Flare : http://unity3d.com/support/documentation/Components/class-LensFlare.html
  9) Light : http://unity3d.com/support/documentation/Components/class-Light.html
  10) Projector : http://unity3d.com/support/documentation/Components/class-Projector.html
  11) Sky box  : http://unity3d.com/support/documentation/Components/class-Skybox.html


2. Movie Texture ( tex·ture 미국∙영국 [|tekstʃə(직물의) 감촉[질감])
 http://unity3d.com/support/documentation/Components/class-MovieTexture.html
 ==> 요건 지난번에 설명을 한것 같기도 하고.. Pro 버전에서만 지원을 한다... texture를 사용해서 적용하면 되는 것 뭐 어려운것 없다.. play 와 stop 정도만 ^^;; 

3. Game Object
 http://unity3d.com/support/documentation/Components/class-GameObject.html
게임 오브젝트들은 하나의 저장고 !!
라이트 매핑된 섬이라든가 물리적인 효과가 적용된 자동차와 같은 여러 다른 조각들을 담을 수 있는 빈 박스와 같습니다. 이 각각의 조각들은 구성요소(Componets)라 불립니다. (cf..스크립트도 구성요소로 볼수 있다는 점도 기억하시길 바랍니다. 스크립트 내에 모든 가변요소들은 게임 오브젝트의 인스펙터상에 편집이나 링크가 가능하구요....)
어떤 오브젝트를 만들고 싶은가에 따라 서로 다른 구성요소의 조합을 게임 오브젝트에 더 해 주게 됩니다. 게임 오브젝트를 하나의 빈 과자틀이라 가정하고 구성요소들을 게임이라는 과자를 굽는데 필요한 다양한 재료라고 생각하면 됩니다.

모든 게임 Object에는 Object Name, Tag, Layer, Transform Component의 구성요소를 가지고 있다.
이중에 Transform Component는 게임 오브젝트의 Position, Rotation , Scale ...필수적인 성질을 정의
Transform Compoonet는 유니티의 편집기능에 이용되는 페어런팅(Parenting - 상하위 관계를 형성하는 것을 의미)도 가능하게 합니다.

 * Transform Component
 http://unity3d.com/support/documentation/Components/class-Transform.html

** shift + Ctrl + N : Game Object 생성 단축키

 
4. Prefabs   ( pre·fab 미국∙영국 [|pri:fӕb] 조립식 건물 )
http://unity3d.com/support/documentation/Manual/Prefabs.html

Prefabs은 씬에서 재사용될 수 있는 게임오브젝트와 구성요소의 집합체입니다. 
몇 개의 동일한 오브젝트들이 하나의 Prefab에서 만들어질 수 있습니다. (이를 instancing이라 합니다.)

나무로 예를 들어 보겠습니다. 
나무 Prefab을 만든다면 몇 개의 동일한 나무들을 복사하여(instance) 당신의 씬에 넣는 것입니다.
모든 나무들은 Prefab에 링크되어 있기 때문에 Prefab에 적용되는 모든 변화들은 자동적으로 모든 복사된 나무들에게도(tree instance) 적용이 됩니다. 
그렇기 때문에 매시나 재질이나 기타 다른 사항들을 변경하기 원한다면 Prefab만 한 번 바꿔주면 됩니다.
반대로 복사된 오브젝트를 수정한 뒤 메인메뉴의 GameObject->Apply Changes to Prefab을 통해서도 가능합니다. 이 작업은 asset을 설정해주고 업데이트 하는데 많은 시간을 절약할 수 있게 해줍니다.

다수의 구성요소들과 하위게임오브젝트를 포함하는 게임오브젝트가 있다면 최상위의 게임오브젝트의 Prefab을 만들고 그 모든 집합체를 재사용할 수도 있습니다.

Prefab을 게임오브젝트의 구조에 대한 청사진으로 생각하십시오. 모든 Prefab의 복제는 청사진과 동일합니다. 그렇기 때문에 청사진이 업데이트 되면 Prefab의 복제도 마찬가지로 업데이트 됩니다. Prefab의 복제 중 하나를 변경하고 그 변경사항을 청사진에 적용함으로써 Prefab자체를 업데이트 할 수 있는 다양한 방법들이 있습니다. 


5. Scene 
게임의 오브젝트들을 포함( 배경,장애물 , 장식들) 배치
메인 메뉴를 만들거나, 개별 레벨을 만드는데 사용 

6. Asset ( asset미국·영국 [|ӕset] : [명사]~ (to sb/sth)자산(이 되는 사람・물건) )


7. Asset 작업 과정
 1) 3D 모델링 프로그램을 이용해서 asset 의 러프 버전(초기 모델의 의미) 제작 
 2) import : Unity Asset 폴더에 저장을 하면, 자동으로 임포트 
 3) import Setting 
 4) Scene에 Asset 추가 : Mesh 를 프로젝트 뷰에서 클릭하여 Hierarchy 나 Scene 뷰에 드래그 추가
 5) 다른 Asset 함께 위치
 - texture 는 material에 적용
 - material은 Game Object에 적용 (with an Mesh Render Component) 
- Animation은 Game Object에 적용(with an Animation Component)
 - A sound file is applied to a Game Object (with an Audio Source Component)
6) Prefab 만들기
7) Assets Update

* Mesh Render 구성요소를 지닌 게임오브젝트를 만들고 있음을 의미
텍스쳐 나 사운드 파일로 작업 중이라면, 이미 씬이나 프로젝트에 존재하는 게임오브젝트에 그것을 추가해 줘야 함.


8. Script 호출 순서
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html

Assets->Create->JavaScript 의 순서로 제작을 하며...

Awake => Start => Update

Awake : 이 스크립트를 사용하는 인스턴스들이 Start하기전에 무조건 딱한번 실행됩니다.
Start :  현재 인스턴스가 활성화될때 Update 바로 직전 딱한번 호출됩니다.

스크립트를 사용하는 인스턴스가 1,2 가 있다면
Awake1 - Awake2 - Start1 - Start2  (0)
Awake1 - Start1 - Awake2 - Start2  (x)




반응형
Posted by blueasa
, |

FadeInOut

Unity3D/Script / 2012. 10. 31. 17:19

FadeInOut


Contents

 [hide

JavaScript

Introduction

Author: PsychicParrot

Little script to fade an image (stretched to fit the screen, so use a 1x1 black pixel for a simple black fade in/out).

Simply apply it to your camera (or an empty GameObject), set the texture to use, set the fadeSpeed and call fadeIn() or fadeOut()

Easiest way is probably to apply this script to your main camera in the scene, then wherever you want to fade use something like:

Camera.main.SendMessage("fadeOut");

or

Camera.main.SendMessage("fadeIn");

Enjoy!

Source (FadeInOut.js)

// FadeInOut
//
//--------------------------------------------------------------------
//                        Public parameters
//--------------------------------------------------------------------
 
public var fadeOutTexture : Texture2D;
public var fadeSpeed = 0.3;
 
var drawDepth = -1000;
 
//--------------------------------------------------------------------
//                       Private variables
//--------------------------------------------------------------------
 
private var alpha = 1.0; 
 
private var fadeDir = -1;
 
//--------------------------------------------------------------------
//                       Runtime functions
//--------------------------------------------------------------------
 
//--------------------------------------------------------------------
 
function OnGUI(){
 
	alpha += fadeDir * fadeSpeed * Time.deltaTime;	
	alpha = Mathf.Clamp01(alpha);	
 
	GUI.color.a = alpha;
 
	GUI.depth = drawDepth;
 
	GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
 
//--------------------------------------------------------------------
 
function fadeIn(){
	fadeDir = -1;	
}
 
//--------------------------------------------------------------------
 
function fadeOut(){
	fadeDir = 1;	
}
 
function Start(){
	alpha=1;
	fadeIn();
}

Boo

Introduction

Author: Adrian

Extended version written in Boo (put it into "Standard Assets/Scripts" to use it from within JavaScript files).

Main change is that rather than defining a fade speed you can set the duration of the fade in seconds.

Also provides methods to set the fade duration when the method is called and static methods to call the fade script on the main camera (by calling CameraFade.FadeInMain()).

Source (CameraFade.boo)

import UnityEngine
 
class CameraFade (MonoBehaviour): 
 
	# ---------------------------------------- #
	# PUBLIC FIELDS
 
	# Alpha start value
	public startAlpha as single = 1
 
	# Texture used for fading
	public fadeTexture as Texture2D
 
	# Default time a fade takes in seconds
	public fadeDuration as single = 2
 
	# Depth of the gui element
	public guiDepth as int = -1
 
	# Fade into scene at start
	public fadeIntoScene as bool = true
 
	# ---------------------------------------- #
	# PRIVATE FIELDS
 
	# Current alpha of the texture
	currentAlpha as single = 1
 
	# Current duration of the fade
	currentDuration as single
 
	# Direction of the fade
	fadeDirection as int = -1
 
	# Fade alpha to
	targetAlpha as single = 0
 
	# Alpha difference
	alphaDifference as single = 0
 
	# Style for background tiling
	private backgroundStyle as GUIStyle = GUIStyle()
	private dummyTex as Texture2D
 
	# ---------------------------------------- #
	# START FADE METHODS
 
	def FadeIn(duration as single, to as single):
		# Set fade duration
		currentDuration = duration
		# Set target alpha
		targetAlpha = to
		# Difference
		alphaDifference = Mathf.Clamp01(currentAlpha - targetAlpha)
		# Set direction to Fade in
		fadeDirection = -1
 
	def FadeIn():
		FadeIn(fadeDuration, 0)
 
	def FadeIn(duration as single):
		FadeIn(duration, 0)
 
	def FadeOut(duration as single, to as single):
		# Set fade duration
		currentDuration = duration
		# Set target alpha
		targetAlpha = to
		# Difference
		alphaDifference = Mathf.Clamp01(targetAlpha - currentAlpha)
		# Set direction to fade out
		fadeDirection = 1
 
	def FadeOut():
		FadeOut(fadeDuration, 1)
 
	def FadeOut(duration as single):
		FadeOut(duration, 1)
 
	# ---------------------------------------- #
	# STATIC FADING FOR MAIN CAMERA
 
	static def FadeInMain(duration as single, to as single):
		GetInstance().FadeIn(duration, to)
 
	static def FadeInMain():
		GetInstance().FadeIn()
 
	static def FadeInMain(duration as single):
		GetInstance().FadeIn(duration)
 
	static def FadeOutMain(duration as single, to as single):
		GetInstance().FadeOut(duration, to)
 
	static def FadeOutMain():
		GetInstance().FadeOut()
 
	static def FadeOutMain(duration as single):
		GetInstance().FadeOut(duration)
 
	# Get script fom Camera
	static def GetInstance() as CameraFade:
		# Get Script
		fader as CameraFade = Camera.main.GetComponent(CameraFade)
		# Check if script exists
		if (fader == null):
			raise System.Exception("No CameraFade attached to the main camera.")
		return fader
 
	# ---------------------------------------- #
	# SCENE FADEIN
 
	def Start():
		dummyTex = Texture2D(1,1)
		dummyTex.SetPixel(0,0,Color.clear)
		backgroundStyle.normal.background = fadeTexture
		currentAlpha = startAlpha
		if fadeIntoScene:
			FadeIn()
 
	# ---------------------------------------- #
	# FADING METHOD
 
	def OnGUI():
 
		# Fade alpha if active
		if ((fadeDirection == -1 and currentAlpha > targetAlpha)
				or
			(fadeDirection == 1 and currentAlpha < targetAlpha)):
			# Advance fade by fraction of full fade time
			currentAlpha += (fadeDirection * alphaDifference) * (Time.deltaTime / currentDuration)
			# Clamp to 0-1
			currentAlpha = Mathf.Clamp01(currentAlpha)
 
		# Draw only if not transculent
		if (currentAlpha > 0):
			# Draw texture at depth
			GUI.color.a = currentAlpha;
			GUI.depth = guiDepth;
			GUI.Label(Rect(-10, -10, Screen.width + 10, Screen.height + 10), dummyTex, backgroundStyle)


Another Fade Script in C#

Introduction

Author: Kentyman

Hello everybody! I was looking for an easy way to fade the screen and found this page. The scripts here didn't do quite what I wanted, so I rewrote the C# version. This one will fade from any color to any color. Usage: use "SetScreenOverlayColor" to set the initial color, then use "StartFade" to set the target color and the fade duration (in seconds) and start the fade.

Source (CameraFade.cs)

 
// simple fading script
// A texture is stretched over the entire screen. The color of the pixel is set each frame until it reaches its target color.
 
 
using UnityEngine;
 
 
public class CameraFade : MonoBehaviour
{   
	private GUIStyle m_BackgroundStyle = new GUIStyle();		// Style for background tiling
	private Texture2D m_FadeTexture;				// 1x1 pixel texture used for fading
	private Color m_CurrentScreenOverlayColor = new Color(0,0,0,0);	// default starting color: black and fully transparrent
	private Color m_TargetScreenOverlayColor = new Color(0,0,0,0);	// default target color: black and fully transparrent
	private Color m_DeltaColor = new Color(0,0,0,0);		// the delta-color is basically the "speed / second" at which the current color should change
	private int m_FadeGUIDepth = -1000;				// make sure this texture is drawn on top of everything
 
 
	// initialize the texture, background-style and initial color:
	private void Awake()
	{		
		m_FadeTexture = new Texture2D(1, 1);        
        m_BackgroundStyle.normal.background = m_FadeTexture;
		SetScreenOverlayColor(m_CurrentScreenOverlayColor);
 
		// TEMP:
		// usage: use "SetScreenOverlayColor" to set the initial color, then use "StartFade" to set the desired color & fade duration and start the fade
		//SetScreenOverlayColor(new Color(0,0,0,1));
		//StartFade(new Color(1,0,0,1), 5);
	}
 
 
	// draw the texture and perform the fade:
	private void OnGUI()
    {   
		// if the current color of the screen is not equal to the desired color: keep fading!
		if (m_CurrentScreenOverlayColor != m_TargetScreenOverlayColor)
		{			
			// if the difference between the current alpha and the desired alpha is smaller than delta-alpha * deltaTime, then we're pretty much done fading:
			if (Mathf.Abs(m_CurrentScreenOverlayColor.a - m_TargetScreenOverlayColor.a) < Mathf.Abs(m_DeltaColor.a) * Time.deltaTime)
			{
				m_CurrentScreenOverlayColor = m_TargetScreenOverlayColor;
				SetScreenOverlayColor(m_CurrentScreenOverlayColor);
				m_DeltaColor = new Color(0,0,0,0);
			}
			else
			{
				// fade!
				SetScreenOverlayColor(m_CurrentScreenOverlayColor + m_DeltaColor * Time.deltaTime);
			}
		}
 
		// only draw the texture when the alpha value is greater than 0:
		if (m_CurrentScreenOverlayColor.a > 0)
		{			
            		GUI.depth = m_FadeGUIDepth;
            		GUI.Label(new Rect(-10, -10, Screen.width + 10, Screen.height + 10), m_FadeTexture, m_BackgroundStyle);
		}
    }
 
 
	// instantly set the current color of the screen-texture to "newScreenOverlayColor"
	// can be usefull if you want to start a scene fully black and then fade to opague
	public void SetScreenOverlayColor(Color newScreenOverlayColor)
	{
		m_CurrentScreenOverlayColor = newScreenOverlayColor;
		m_FadeTexture.SetPixel(0, 0, m_CurrentScreenOverlayColor);
		m_FadeTexture.Apply();
	}
 
 
	// initiate a fade from the current screen color (set using "SetScreenOverlayColor") towards "newScreenOverlayColor" taking "fadeDuration" seconds
	public void StartFade(Color newScreenOverlayColor, float fadeDuration)
	{
		if (fadeDuration <= 0.0f)		// can't have a fade last -2455.05 seconds!
		{
			SetScreenOverlayColor(newScreenOverlayColor);
		}
		else					// initiate the fade: set the target-color and the delta-color
		{
			m_TargetScreenOverlayColor = newScreenOverlayColor;
			m_DeltaColor = (m_TargetScreenOverlayColor - m_CurrentScreenOverlayColor) / fadeDuration;
		}
	}
}

C#

Introduction

Author: ratmat2000

Extended version written in C# (put it into "Standard Assets/Scripts" to use it from within JavaScript files).

This version is identical to the Boo version but written in C#.

Source (CameraFade.cs)

using UnityEngine;
 
public class CameraFade : MonoBehaviour
{    
    // ---------------------------------------- 
    // 	PUBLIC FIELDS
    // ----------------------------------------
 
    // Alpha start value
    public float startAlpha = 1;
 
    // Texture used for fading
    public Texture2D fadeTexture;
 
    // Default time a fade takes in seconds
    public float fadeDuration = 2;
 
    // Depth of the gui element
    public int guiDepth = -1000;
 
    // Fade into scene at start
    public bool fadeIntoScene = true;
 
    // ---------------------------------------- 
    // 	PRIVATE FIELDS
    // ----------------------------------------
 
    // Current alpha of the texture
    private float currentAlpha = 1;
 
    // Current duration of the fade
    private float currentDuration;
 
    // Direction of the fade
    private int fadeDirection = -1;
 
    // Fade alpha to
    private float targetAlpha = 0;
 
    // Alpha difference
    private float alphaDifference = 0;
 
    // Style for background tiling
    private GUIStyle backgroundStyle = new GUIStyle();
    private Texture2D dummyTex;
 
    // Color object for alpha setting
    Color alphaColor = new Color();
 
    // ---------------------------------------- 
    // 	FADE METHODS
    // ----------------------------------------
 
    public void FadeIn(float duration, float to)
    {
        // Set fade duration
        currentDuration = duration;
        // Set target alpha
        targetAlpha = to;
        // Difference
        alphaDifference = Mathf.Clamp01(currentAlpha - targetAlpha);
        // Set direction to Fade in
        fadeDirection = -1;
    }
 
    public void FadeIn()
    {
        FadeIn(fadeDuration, 0);
    }
 
    public void FadeIn(float duration)
    {
        FadeIn(duration, 0);
    }
 
    public void FadeOut(float duration, float to)
    {
        // Set fade duration
        currentDuration = duration;
        // Set target alpha
        targetAlpha = to;
        // Difference
        alphaDifference = Mathf.Clamp01(targetAlpha - currentAlpha);
        // Set direction to fade out
        fadeDirection = 1;
    }
 
    public void FadeOut()
    {
        FadeOut(fadeDuration, 1);
    }    
 
    public void FadeOut(float duration)
    {
        FadeOut(duration, 1);
    }
 
    // ---------------------------------------- 
    // 	STATIC FADING FOR MAIN CAMERA
    // ----------------------------------------
 
    public static void FadeInMain(float duration, float to)
    {
        GetInstance().FadeIn(duration, to);
    }
 
    public static void FadeInMain()
    {
        GetInstance().FadeIn();
    }
 
    public static void FadeInMain(float duration)
    {
        GetInstance().FadeIn(duration);
    }
 
    public static void FadeOutMain(float duration, float to)
    {
        GetInstance().FadeOut(duration, to);
    }
 
    public static void FadeOutMain()
    {
        GetInstance().FadeOut();
    }
 
    public static void FadeOutMain(float duration)
    {
        GetInstance().FadeOut(duration);
    }
 
    // Get script fom Camera
    public static FadeInOut GetInstance()
    {
    	// Get Script
        FadeInOut fader = (FadeInOut)Camera.main.GetComponent("FadeInOut");
        // Check if script exists
        if (fader == null) 
        {
            Debug.LogError("No FadeInOut attached to the main camera.");
        }    
        return fader;
	}
 
    // ---------------------------------------- 
    // 	SCENE FADEIN
    // ----------------------------------------
 
    public void Start()
    {
    	Debug.Log("Starting FadeInOut");
 
        dummyTex = new Texture2D(1,1);
        dummyTex.SetPixel(0,0,Color.clear);
        backgroundStyle.normal.background = fadeTexture;
        currentAlpha = startAlpha;
        if (fadeIntoScene)
        {
            FadeIn();
        }
    }
 
    // ---------------------------------------- 
    // 	FADING METHOD
    // ----------------------------------------
 
    public void OnGUI()
    {   
        // Fade alpha if active
        if ((fadeDirection == -1 && currentAlpha > targetAlpha) ||
            (fadeDirection == 1 && currentAlpha < targetAlpha))
        {
            // Advance fade by fraction of full fade time
            currentAlpha += (fadeDirection * alphaDifference) * (Time.deltaTime / currentDuration);
            // Clamp to 0-1
            currentAlpha = Mathf.Clamp01(currentAlpha);
        }
 
        // Draw only if not transculent
        if (currentAlpha > 0)
        {
            // Draw texture at depth
            alphaColor.a = currentAlpha;
            GUI.color = alphaColor;
            GUI.depth = guiDepth;
            GUI.Label(new Rect(-10, -10, Screen.width + 10, Screen.height + 10), dummyTex, backgroundStyle);
        }
    }
}


The following bugs have been identified in the code segment above

LINE 133: FadeInOut should read CameraFade

LINE 136: Replace FadeInOut occurances with CameraFade

Also when I was trying to use it, if I didn't FadeIn on start the value for currentAlpha would end up NaN. I had to do some rearranging, but when I was done there were conditions that would cause currentAlpha to equal the targetAlpha when I issued a FadeIn command. I corrected this by placing the following code in the FadeIn method and an equivalent one in the FadeOut.


    	//Check to see if currentAlpha is set to 1.  It will need to be 1 to fade properly
    	if (currentAlpha != 1){
          currentAlpha = 1;	
        }

I would replace this code with mine, but I've already changed my so much I am hesitant to do so, I'll leave that exercise to someone else.







반응형
Posted by blueasa
, |

런타임tl 프리팹을 인스턴스화 하기 Instantiating Prefabs at runtime

이 시점에서 사용자는 프리팹 Prefabs 에 관한 기초적인 개념을 이해하고 있어야 합니다. 프리팹은 사용자의게임을 통털어 재사용이 가능한 미리 설정된 게임오브젝트 GameObjects들과 컴포넌트 Components들의 집합입니다. 프리팹이 무엇인지 모르실 경우, 기초 지식을 위해Prefabs 페이지를 읽어보시길 권유합니다.

프리팹은 복잡한 게임오브젝트를 런타임때 인스턴스화(instantiate) 시키길 원하는 경우 매우 유용합니다. 프리팹을 인스턴스화 하는 것 외에 다른 방안은 코드를 사용해 처음부터 게임오브젝트를 만드는 것입니다. 프리팹 인스턴스화는 이런 대안에 비하여 더 많은 장점들을 가지고 있습니다:

  • 사용자는 한 줄의 코드로 완전한 기능을 가진 프리팹의 인스턴스화를 할 수 있습니다. 똑같은 게임오브젝트를 코드로 처음부터 만드는 것은 평균 5줄 혹은 더 이상이 필요하게 됩니다.
  • 사용자는 씬 Scene과 인스펙터 Inspector 에서 프리팹을 더 빠르고 쉽게 설정하고 테스트하고 수정할 수 있습니다.
  • 사용자는 인스턴스 되어진 프리팹을 그것을 인스턴스화하는 코드를 변경하지 않고도 해당 프리팹을 변경할 수 있습니다. 가령 코드 변경없이도 일반 로켓탄을 슈퍼 충전된 로켓으로 변경할 수 있습니다.

일반적인 시나리오들 Common Scenarios

프리팹의 강점을 설명하기 위해서, 프리팹이 유용하게 쓰여지는 기본적인 상황들을 고려해 보겠습니다:

  1. 벽돌 프리팹을 각각 다른 위치로 여러 차례 생성하여 벽을 만들수 있습니다.
  2. 로켓발사기는 로켓을 쏘았을 때 날으는 로켓탄 프리팹을 인스턴스화 합니다. 그 프리팹은 메쉬, 강체Rigidbody충돌체 Collider, 그리고, 자신의 흔적 trail 파티클 시스템 Particle System을 가진 자식 child 게임오브젝트를 포함합니다.
  3. 많은 조각들로 폭발하는 로봇. 완전하게 작동하던 로봇은 부서진후 파괴된_로봇_프리팹 으로 교체됩니다. 이 프리팹들은 각각의 강체 Rigidbodies 들과 파티클 시스템들이 설정된 여러 개의 파트들로 나눠진 로봇으로 구성될 것입니다. 이 테크닉은 로봇을 많은 조각으로 폭발시키며 한 개의 객체를 한 개의 프리팹으로 교체하는 것을 단 한 줄의 코드로 할 수 있게 해줍니다.

벽 짓기 Building a wall

아래의 설명은 프리팹을 사용하는 것과 코드로 객체를 생성하는 것의 비교를 통하여 프리팹 사용의 장점을 보여줄 것입니다.

우선, 코드로부터 벽돌을 만들어 봅니다:

function Start () {
    for (var y = 0; y < 5; y++) {
        for (var x = 0; x < 5; x++) {
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.AddComponent(Rigidbody);
            cube.transform.position = Vector3 (x, y, 0);
        }
    }
} 
  • 위의 스크립트를 사용하기 위해서는, 사용자는 단순히 스크립트를 저장하고 비어있는 게임오브젝트로 스크립트를 드래그 합니다.
  • GameObject->Create Empty로 빈 게임오브젝트를 생성합니다.

만약 위의 코드를 실행하면, 사용자가 플레이 모드 Play Mode 로 들어갈 때 벽돌 벽 전체를 보게 될 것입니다. 거기에는 각각의 벽돌의 기능에 관련된 두 개의 코드 줄이 있습니다. 이들은 CreatePrimitive()와 AddComponent()입니다. 지금 이것도 나쁘지는 않지만, 벽돌들은 텍스쳐를 가지고 있지 않습니다. 텍스쳐 texture, 마찰력 friction, 강체의 질량 Rigidbody mass을 바꾸는 것처럼 벽돌에 행해지는 각각의 추가적인 행동들은 모두 추가적인 줄을 필요로 하게 됩니다.

만약 사용자가 프리팹을 생성하여, 모든 설정을 사전에 해놓는다면, 각 벽돌의 설정과 생성을 수행하기 위해서 한 줄의 코드만 사용하게 됩니다. 이것은 사용자가 무언가 수정을 해야한다고 느꼈을 때 많은 코드들을 관리하고 수정하는 수고를 덜어 줄 것 입니다. 프리팹을 사용하면 사용자는 단지 수정한 후 플레이하면 됩니다. 코드의 수정이 따로 필요 없습니다.

개개의 벽돌을 위해 프리팹을 사용할 것이라면, 다음이 사용자가 벽을 생성하기 위해 필요한 코드입니다.

var cube : Transform;
function Start () {
    for (var y = 0; y < 5; y++) {
        for (var x = 0; x < 5; x++) {
            var cube = Instantiate(cube, Vector3 (x, y, 0), Quaternion.identity);
        }
    }
} 

위의 코드는 아주 깔끔할 뿐만 아니라 재사용이 가능합니다. 여기에는 큐브를 인스턴스화한다 instantiating 라던지 큐브가 강체 rigidbody 를 포함 해야 한다 라는 말이 필요 없습니다. 이 모든 것은 프리팹에서 정의되고 에디터에서 빠르게 생성될 수 있습니다.

이제 사용자는 에디터 안에서 프리팹을 만들기만 하면 됩니다. 다음과 같은 방법으로 프리팹을 생성합니다:

  1. GameObject->Create Other->Cube를 선택합니다.
  2. Component->Physics->Rigidbody를 선택합니다.
  3. Assets->Create Prefab를 선택합니다.
  4. 프로젝트 뷰 Project View에서, 새로운 프리팹의 이름을 "Brick"으로 바꿉니다.
  5. 계층 Hierarchy에서 생성한 큐브를 드래그하여 프로젝트 뷰의 “Brick” 프리팹에 놓습니다.
  6. 생성된 프리팹으로 사용자는 계층에서 안전하게 큐브를 삭제할 수 있습니다 (윈도우에서는 Delete, 맥에서는 Command-Backspace)

이제 벽돌 프리팹이 생성되었습니다. 이제 사용자는 이것을 스크립트의 cube 변수에 붙여야 attach 합니다. 스크립트를 포함하는 빈 게임오브젝트를 선택하세요. 인스펙터에서 새로운 변수인 "cube"가 나타난 것을 보게 될 것입니다.


이 변수는 어떤 게임오브젝트나 프리팹도 받아들일 수 있습니다

이제 "Brick" 프리팹을 프로젝트 뷰에서 인스펙터의 cube 변수위로 드래그 합니다. 플레이 Play 를 누르면 프리팹을 사용하는 벽을 보게 될 것입니다.

이것은 유니티에서 굉장히 많이 사용되는 작업방식 패턴입니다. 사용자는 처음에 코드로부터 큐브를 생성하는 스크립트가 단 2줄이 더 긴데 왜 이 방식이 훨씬 더 낫다는 건지 의아해 할 수도 있습니다.

그러나 지금은 프리팹 사용으로 인해 단 몇 초 내에 프리팹을 수정할 수 있습니다. 모든 인스턴스의 질량 수정이 필요합니까? 그렇다면 해당 프리팹 안의 강체를 수정하세요. 모든 인스턴스들에 각각 다른 재질 Material을 사용하기 원합니까? 그렇다면 해당 프리팹으로 재질을 한번만 드래그 해놓으면 됩니다. 마찰의 수정을 원하십니까? 그렇다면 프리팹의 충돌체에 다른 피직 재질 Physic Material을 사용하십시오. 여기 모든 박스에 파티클 시스템을 추가 하시겠습니까? 그렇다면 프리팹에 자식 child 을 한 번만 추가하시면 됩니다.

로켓과 폭발의 인스턴스화 Instantiating rockets & explosions

다음은 프리팹이 어떻게 이 시나리오에 들어맞는지에 대한 설명입니다:

  1. 로켓 발사기는 사용자가 로켓을 발사할 때, 로켓 프리팹을 인스턴스화 instantiate 합니다. 이 프리팹은 메쉬, 강체, 충돌체, 그리고 흔적 파티클 시스템 trail particle system 을 포함하는 자식 게임오브젝트를 가지고 있습니다.
  2. 로켓은 폭발 프리팹에 영향을 미치고 인스턴스화 시킵니다. 폭발 프리팹은 시간이 지나며 점점 희미해지는 빛의 파티클 시스템과 주위의 게임오브젝트들에 데미지를 가하는 스크립트를 지니고 있습니다.

로켓 게임오브젝트를 코드로 처음부터 작성하여 수동으로 컴포넌트 추가하고 속성 설정하는 것도 가능하지만 프리팹을 인스턴스화 하는 것이 훨씬 더 쉽습니다. 로켓의 프리팹이 얼마나 복잡하던지 간에 로켓을 한 줄의 코드로 로켓을 인스턴스화 할 수 있습니다. 프리팹을 인스턴스화 한 후에 사용자는 인스턴스화한 객체의 어떤 속성도 변경이 가능합니다 (예: 로켓 강체의 속도 설정).

사용이 쉬운 것 이외에도 프리팹은 나중에 업데이트가 가능하다는 장점이 있습니다. 가령 사용자가 로켓을 만든다면, 로켓에 당장 흔적 파티클을 추가할 필요가 없습니다. 나중에 업데이트 하는 것이 가능하기 때문입니다. 나중에 사용자가 자식 게임오브젝트로서 흔적 trail 을 프리팹에 추가하면, 사용자의 인스턴스 instance 화 된 모든 로켓들은 흔적 파티클들을 가지게 될 것입니다. 그리고 마지막으로 사용자는 인스펙터의 로켓 프리팹의 속성들을 빨리 수정해서 게임을 정교하게 가다듬는 것을 더 쉽게 만들어 줍니다.

이 스크립트는 Instantiate() 함수를 사용하여 어떻게 로켓을 발사하는지 보여줍니다.

// 로켓이 강체가 되어야 합니다.
// 그래야 사용자가 강체없이 프리팹 할당을 못합니다.
var rocket : Rigidbody;
var speed = 10.0;

function FireRocket () {
    var rocketClone : Rigidbody = Instantiate(rocket, transform.position, transform.rotation);
    rocketClone.velocity = transform.forward * speed;
    // 사용자는 복제품의 컴포넌트나 스크립트에 접근할 수 있습니다.
    rocketClone.GetComponent(MyRocketScript).DoSomething();
}

//CTRL나 마우스를 누르고 있을때 발사 메쏘드를 호출합니다.
function Update () {
    if (Input.GetButtonDown("Fire1")) {
        FireRocket();
    }
} 

캐릭터를 랙돌 ragdoll 이나 망가진 것으로 교체하기 Replacing a character with a ragdoll or wreck

만약 사용자가 완전히 리깅된 적 캐릭터를 가지고 있는데 그가 죽었다고 가정해 보세요. 이 경우 사용자는 단순히 캐릭터에 죽음 애니메이션이 작동하게 하고 그 적 캐릭터의 로직을 다루는 모든 스크립트를 사용불가 disable 상태로 만들수도 있습니다. 이때 사용자는 몇몇 스크립트들을 제거하고, 다른 아무도 죽은 적을 더 이상 공격하지 않는 몇몇 커스텀 로직을 더해야 하는 등등의 여러가지 청소 작업에 신경 써야 할 것입니다.

하지만 이보다 더 좋은 접근법은 캐릭터를 통체로 즉시 삭제하고, 그 캐릭터를 인스턴스화된 망가진 프리팹 인스턴스로 교체하는 것입니다. 이는 사용자에게 더 많은 유연성을 제공해 줍니다. 죽은 캐릭터를 위해서 다른 재질 을 사용할 수도 있고, 완전히 다른 스크립트들을 붙일 수도 있을 것이며, 산산조각난 적을 연출하기 위해 여러 개로 쪼개진 그 객체를 포함하는 프리팹을 만들거나 혹은 단순히 그 캐릭터의 버전을 포함하는 프리팹을 인스턴스 시킬 수도 있을 것입니다.

이 어떤 선택사항들도 Instantiate()로 한번의 호출로 가능하며, 사용자는 간단히 그것을 맞는 프리팹으로 연결만하면 완료가 되는 것입니다!

이 중 꼭 기억해야 할 중요한 파트은 사용자가 Instantiate() 명령어를 사용해 만든 부서진 캐릭터를 원래와 완전히 다른 객체들로 구성할 수 있다는 점입니다. 예를 들어 사용자가 비행기가 있을시 사용자는 두 가지 버전으로 그것을 모델링 할 것입니다. 비행기가 메쉬 렌더러 Mesh Renderer와 비행기 피직스 (물리) physics 를 위한 스크립트들을 가진 하나의 게임오브젝트로 구성된 모델의 경우를 봅니다. 이 모델을 하나의 게임오브젝트에 간직함으로 인하여, 사용자는 더 적은 수의 삼각형들로 구성된 모델로 만들 수 있으므로 사용자의 게임 속도는 더욱 더 향상될 것입니다. 그리고 더 적은 수의 객체들로 구성됨으로 인해, 여러개의 작은 파트들을 많이 사용하는 경우에 비해 렌더 속도도 더 빠를 것입니다. 또한 비행기에 문제없이 날고 있다면, 굳이 분리된 파트들로 구성된 모델을 가지고 있을 이유가 없습니다.

망가진 비행기 프리팹을 만들기 위한 일반적인 단계는 다음과 같습니다:

  1. 사용자가 선호하는 3D 모델링 프로그램으로 많은 파트들로 구성된 비행기를 모델링합니다.
  2. 비어있는 씬 empty Scene 을 생성합니다.
  3. 모델을 빈 씬으로 드래그 합니다.
  4. 모든 파트들을 선택하고 Component->Physics->Rigidbody 메뉴를 선택해서 강체 Rigidbodies 를 모든 파트들에 더합니다.
  5. 모든 파트들을 선택하고 Component->Physics->Box Collider를 선택해서 박스 충돌체를 모든 파트들에 더합니다.
  6. 추가적인 특수 효과를 위해서 각 파트들에 연기와 같은 파티클 시스템을 자식 child 게임오브젝트로써 더합니다.
  7. 이제 사용자는 복수개의 폭발된 파트들로 구성된 비행기를 가지고 있고 이것들은 피직스 physic 에 의해 땅으로 떨어지고 부착된 파티클 시스템으로 인하여 흔적 파티클들을 만들어 낼 것입니다. 재생 play 을 눌러 모델이 어떤 식으로 반응하는지 살펴본 후 필요한 변경을 가해 주세요.
  8. Assets->Create Prefab를 선택합니다.
  9. 비행기 파트들을 모두 포함한 루트 root 게임오브젝트를 프리팹 안으로 드래그 합니다.
var wreck : GameObject;

//한 예로 우리는 3초 후에 자동적으로 게임오브젝트가 망가진 것으로 바뀌도록 해봅니다.
function Start () {
    yield WaitForSeconds(3);
    KillSelf();
}

// CTRL이나 마우스를 누를때 발사 메쏘드를 호출합니다.
function KillSelf () {
    // 우리가 있는 같은 위치로 부서진 게임오브젝트의 인스턴스를 생성합니다.
    var wreckClone = Instantiate(wreck, transform.position, transform.rotation);

    // 때로 우리는 이 객체로부터 몇몇 변수들을 가져올 필요가 있습니다.
    // 부서진 게임오브젝트로 말입니다.
    wreckClone.GetComponent(MyScript).someVariable = GetComponent(MyScript).someVariable;

    // 우리를 파괴합니다.
    Destroy(gameObject);
} 

일인칭 슈팅 게임 튜토리얼(강좌)은 캐릭터를 랙돌 ragdoll 버젼으로 어떻게 바꾸고 애니메이션의 마지막 상태로 팔다리를 동기화하여 맞추는지 설명합니다. 이 강좌는 Tutorials 페이지에서 찾으실 수 있습니다.

여러 개의 객체들을 특정한 패턴으로 배치하기 Placing a bunch of objects in a specific pattern

사용자가 다양한 오브젝트들을 그리드나 원형의 패턴에 놓고 싶어한다고 합시다. 예전에는 이것들을 다음과 같은 방법들로 실현했습니다:

  1. 완전히 코드만으로 객체를 만듭니다. 이는 굉장히 지루합니다. 한 스크립트에 값들을 넣는 것은 작업속도가 느려질 뿐만 아니라 직관적이지도 않아 힘만 들게 됩니다.
  2. 완전히 리깅된 오브젝트를 만들고, 그것을 복제해서 씬 Scene 의 여러 곳에 배치하는 방법입니다. 이 또한 지루한 작업이며, 객체들을 그리드 (좌표) grid 에 정확하게 놓는 것은 어렵습니다.

그러므로, 프리팹과 Instantiate() 를 이용하세요! 이러한 시나리오들에서 왜 프리팹들이 유용한지 이제는 이해가 되실 것입니다. 이 시나리오들을 위해 필요한 코드는 다음과 같습니다:

// 원 안에서 프리팹 인스턴스들 만들기

var prefab : GameObject;
var numberOfObjects = 20;
var radius = 5;

function Start () {
    for (var i = 0; i < numberOfObjects; i++) {
        var angle = i * Mathf.PI * 2 / numberOfObjects;
        var pos = Vector3 (Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius;
        Instantiate(prefab, pos, Quaternion.identity);
    }
} 
//그리드 안에 프리팹 인스턴스들 만들기

var prefab : GameObject;
var gridX = 5;
var gridY = 5;
var spacing = 2.0;

function Start () {
    for (var y = 0; y < gridY; y++) {
        for (var x=0;x<gridX;x++) {
            var pos = Vector3 (x, 0, y) * spacing;
            Instantiate(prefab, pos, Quaternion.identity);
        }
    }
} 



반응형

'Unity3D' 카테고리의 다른 글

빌보드 관련  (0) 2012.11.02
Unity3D로 만드는 초간단 2D 게임 (1)  (0) 2012.11.02
안드로이드 빌드 셋팅하기  (22) 2012.10.25
MonoDevelop에서 디버깅하기  (0) 2012.10.25
Inspector에 다차원 배열 값 셋팅하기(for C#)  (1) 2012.10.24
Posted by blueasa
, |
반응형
Posted by blueasa
, |

NGUI: HUD Text

Unity3D/NGUI / 2012. 10. 26. 13:03


간단한 사용법 동영상..


※ HUD (Heads-Up Display) 1
    머리 높이 표시판, (전투기에서) 조종사석의 앞유리에 비행과 전투 정보들을 표시하여 바깥 실제 환경도 함께 볼 수 있도록 한 판


반응형
Posted by blueasa
, |

NGUI: HUD Text 버전 : 1.3

새로 받은 NGUI 버전 2.2.3


NGUI는 이미 프로젝트에서 쓰고 있는 상태에서 HUD Text를 쓰기 위해 에셋 스토어에서 구입을 하고, 임포트 시켰더니


클래스 간 충돌(동일한 클래스가 2개이상 있어서 모호하다고 함) 에러가 났다.


아래는 같은 경험을 한 분의 글이다.

링크 : http://smilejsu.tistory.com/397


그래서 NGUI: HUD Text의 ReadMe.txt 파일을 열어보니 아래와 같은 임포팅 방법이 써있었다.

----------------------------------------------

Importing the full (or free) version of NGUI

----------------------------------------------

The steps are the same as upgrading NGUI:


1. Start a new scene.

2. Delete the NGUI folder.

3. Import the new NGUI package.

----------------------------------------------


설명대로 따라 해봤다.

1. 씬하나 만들고,

2. HUD 임포트 하고,

3. NGUI(산 거)를 삭제했다.

4. NGUI 새 버전을 새로 받아서 임포트 했다.

5. 에러 -_-


그래서 이리저리 구글링을 해보니 같은 문제로 난리 치는 사람들이 참 많았다.

참조 링크 : http://www.tasharen.com/forum/index.php?topic=1013.0


근데 위 링크에서도 제작자는 readme에 있는 설명밖에 안하고 있었다.


그래서 새로 프로젝트를 생성해서 HUD만 넣고 실행해보니 잘되는걸 봤는데..


HUD만 있을 때 NGUI의 워터마크가 화면에 나왔다. 프리버전인가보다..


난 상용 NGUI를 써야되는데.. 라고 생각해보니 저 프리버전이 없어져야 되겠다고 생각..


그렇게 생각하고 readme에 있는 임포팅 방법을 보니 테스트 해봐야 될 게 생각났다.

----------------------------------------------

1. Start a new scene.

2. Delete the NGUI folder. <- 이 NGUI가 HUD Text-NGUI 를 가리키는 것 같아서 테스트..

3. Import the new NGUI package.

----------------------------------------------



1. 씬하나 만들고,

2. NGUI 넣고

2. HUD 임포트 하고,(충돌 에러)

3. HUD Text 하위 NGUI 삭제(또다른 에러)

4. NGUI 새 버전을 그대로(덮어서) 임포트

5. 잘된다!!!!



결론 : 서양인이라 그런지..지극히 주관적인 생각으로 메뉴얼을 쓰는 건가.. 라는 생각을 했다. 제작자는 NGUI를 지우라고 하면 자신의 HUD 아래 NGUI를 생각하면서 쓴걸까.. 타인이 보면 그냥 원 프로젝트인 NGUI로 착각하는데..나처럼..

반응형

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

NGUI - Sticky Floating Text  (0) 2012.10.28
NGUI: HUD Text  (0) 2012.10.26
NGUI health bar, vital bar  (0) 2012.10.25
Button Cooldown effect  (0) 2012.10.16
NGUI 링크 모음  (0) 2012.10.16
Posted by blueasa
, |

http://www.youtube.com/watch?v=h0x5196mWlk


using UnityEngine;

using System.Collections;


public class VitalBar : MonoBehaviour {

private UISlider _slider;

private float _maxWidth;

public float health = 1f;

void Awake() {

_slider = GetComponent<UISlider>();

if(_slider==null)

{

Debug.LogError("Could not find the UISlider Component!");

return;

}

_maxWidth = _slider.foreground.localScale.x;

Debug.Log(_maxWidth);

}

void Update(){

UpdateDisplay(health);

}

public void UpdateDisplay(float x){

_slider.foreground.localScale = new Vector3(_maxWidth*x,_slider.foreground.localScale.y, _slider.foreground.localScale.z);

}

}




출처 : http://smilejsu.tistory.com/394

반응형

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

NGUI - Sticky Floating Text  (0) 2012.10.28
NGUI: HUD Text  (0) 2012.10.26
NGUI와 NGUI: HUD Text 패키지 임포트 시 에러 문제..  (0) 2012.10.25
Button Cooldown effect  (0) 2012.10.16
NGUI 링크 모음  (0) 2012.10.16
Posted by blueasa
, |

유니티를 안드로이드 버전으로 빌드하기 위해서 테스트를 해봤다.


내 폰은 아이폰이라 넣으면서 하진 못하고, 우선 apk 파일 만들기까지 해 봄..


아래는 안드로이드 빌드하기 위해 준비한 것 들.. 생각외로 간단하다..


1) 아래 링크로 가서 안드로이드 SDK를 설치한다.

    (http://developer.android.com/sdk/index.html)


2) JDK가 없으면 1) 설치 중에 JDK 설치하라고 뜬다. 아래 링크로 가서 Java SE를 받아서 설치해 주자..

    참고로 V7 버전이 빌드가 잘 안된다는 글이 있어서 V6으로 깔았다. 아래 링크에 두 버전 다 있음.. 선택..

    그리고, 윈도가 64bit(x64)라고 해서 64bit(x64)를 깔면 안됨.. 32bit(x86)로 깔라고 한다..

    (http://www.oracle.com/technetwork/java/javase/downloads/index.html)


3) 위 두 파일이 모두 설치되고 나면, 유니티의 'Edit-Preferences.-External Tools-Android SDK Location'으로 가서 폴더를 지정해 준다.(폴더 선택하러 들어가면 해당 폴더는 알아서 찾는 것 같다. 우측의 블럭된 폴더명을 삭제하고 그냥 '폴더 선택'을 누르면 된다.)


4) 'Android SDK Location' 셋팅을 하고 나서 'File-Build Settings-Platform'을 Android로 맞춘다.


5) 'File-Build Settings' 아래 Player 'Settings..' 를 누르면 Inspector 창에 이런저런 정보가 나오는데 아래와 같이 셋팅한다.

   (셋팅 설명은 있는데 정확히 무슨 옵션이고 뭘 위한건지 체크는 하지 못했다. 디폴트로 해보기도 해야될 것 같다.)

OtherSetting을 누르고

Identification 에서 Bundle Identifier 가 있는데 com.회사이름.플젝이름 이런식으로 고쳐서 써줌니다.

예) com.ABC.Project1

그리고 Minimum Api Level 에 현재 빌드할 폰의 안드로이드 버전에 맞게 설정합니다.

현재 폰의 버전보다 적은 버전해도 상관없음

Configuration 에서 Devices Level 을 ARMv6 with VFP 로 바꾸시고(Unity 4.x  버전에서는 ARMv7밖에 없으니 ARMv7로 하세요)

Graphics Level 을 OpenGL ES 1.x 로 바꿉니다.

그리고 Resolution and Presentation 을 누르고

Default Orientation 으로 어플의 뭐 가로세로 방향 을 고정시킬수있습니다.

Status Bar에 Status Bar Hidden은 핸드폰의 상단 바를 보이느냐 마느냐를 설정하는 것입니다.


6) 다하고나서 'File-Build Settings-Build' 를 하면 apk 파일이 생성된다.


7) 알아서 폰에 넣고 설치를..



참조 : http://cookzy.tistory.com/698

참조 : http://blog.naver.com/nameisljk/110136124090

반응형
Posted by blueasa
, |

모노에서 아무리 F9 브레이크 포인트를 걸어도 걸리지않는다.. 

 

왜일까...

 

이유는 mono한테 프로젝트가 어떤건지 알려주지않아서 이다.

 

자 mono의 메뉴에서 Run -> Attach to Process 를 클릭해서

 

현재 사용하고있는 프로젝트를 붙여주면 된다~



[출처] [ Unity3D ] mono에서 디버깅하기|작성자 호랑낚시

반응형
Posted by blueasa
, |

우선 그냥 임의로 한 방법이라..

더 좋은 방법이 있을진 나중에 알아보기로 하고..


1) 아래와 같은 다차원 배열에 사용 될 클래스를 하나 만든다.

  1. using UnityEngine;  
  2. using System.Collections;  
  3.   
  4. [System.Serializable] //<== MonoBehaviour가 아닌 클래스에 대해 Inspector에 나타납니다.  
  5. public class Testitem  
  6. {  
  7.     public int[] variable;    // 하위에 넣어질 배열 변수  
  8. }  

※ Serializable 참조 : http://docs.unity3d.com/Documentation/ScriptReference/Serializable.html

※ Inspector 구조체 배열 참조 : http://answers.unity3d.com/questions/175835/array-of-structures-not-viewable-in-inspector.html

※ Inspector 구조체 배열 참조 : http://korea.unity3d.com/board/index.php?db=qnalist&no=780&mari_mode=view%40view&cate=&page=1&listURL=http%3A%2F%2Fkorea.unity3d.com%2Fboard%2F%3Fdb%3Dqnalist%26cate%3D%26stat%3D%26search%3Dtitle%26search_str%3D%25B9%25E8%25BF%25AD%26x%3D0%26y%3D0&search=title&search_str=%B9%E8%BF%AD&temp=


2) GameObject에 링크 된 스크립트에 아래와 같이 변수 선언을 한다.

  1. public Testitem[] arrayTestItem;  


3) 그리고 해당 GameObject의 Inspector를 보면 'Array Test Item'이 보인다.


4) Size에 1이상의 숫자를 넣어보면 Element가 생기면서 화살표(▶)가 있는게 보인다.


5) 화살표(▶)를 눌러보면 1)에서 만든 Testitem의 변수인 variable이 추가돼 있는게 보인다.


6) 원하는 사이즈 넣고 입력..


7) 결과는 아래 스샷과 같음..


반응형

'Unity3D' 카테고리의 다른 글

안드로이드 빌드 셋팅하기  (22) 2012.10.25
MonoDevelop에서 디버깅하기  (0) 2012.10.25
Unity3D Scripting Overview  (0) 2012.10.24
text 파일 Read/Write 하는 소스 몇가지  (0) 2012.10.22
에셋 서버 Scene Merge 관련..  (0) 2012.10.19
Posted by blueasa
, |