Explain.
Unity 2D Sprite Renderer
+
2D Physics
+
Animator
를 활용하여 오브젝트를 제작시 사용.
AutoDepth, ColorFade 기능구현
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(BoxCollider2D))]
[RequireComponent(typeof(SpriteRenderer))]
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Rigidbody2D))]
public class MyObject : MonoBehaviour
{
private SpriteRenderer mSpriteRenderer;
private BoxCollider2D mBoxCollider2D;
private Animator mAnimator;
private Transform mTransform;
public void FadeOut()
{
...
2014년 5월 30일 금요일
2014년 5월 15일 목요일
Posted by ColaLib on 오전 4:05 with 2 comments
Explan.
NGUI이용시
Script상에서 UIPannel 의 alpha scale을 조정하면서
페이드 인,아웃 효과를 주는 스크립트.
Tween Alpha를 활용하여 줄수도 있으나
개인적으로 직접 코딩하여 진행하는것이 더편하기에...
UIPannel뿐만아니라 그외의 컴포넌트라도
Alpha 속성이 구현되어있는 놈이라면
동일하게 이용할수있다.
Timescale값은 원하는값으로 수정하면된다.
FadeInOut.cs
using UnityEngine;
using System.Collections;
public class PannelFadeInOut : MonoBehaviour {
private UIPanel mPannel;
private float mFadeTime = 1f;
private float mWaitTime = 1f;
private bool on = false;
void Start()
{
mPannel = GetComponent<UIPanel>();
...
2014년 5월 13일 화요일
Posted by ColaLib on 오전 2:52 with No comments

Explanation.
NGUI를 사용하여 게임제작시
자동으로 Depth를 조정해주는 스크립트
depth의 범위를 지정안하고 그냥
포지션의 y값을 가지고와서 depth로 적용.
Todo.
정해진 depth 범위내에서 적용되도록 변경.
기본
Auto Depth 적용전
Auto Depth 적용후
using UnityEngine;
using System.Collections;
public class AutoDepth : MonoBehaviour {
private UISprite mSprite;
private Transform mTransform;
private int waitFrameCount = 15;
void Start () {
mSprite = GetComponent();
mTransform...
Posted by ColaLib on 오전 2:37 with No comments
Explanation.
NGUI로 게임제작시
UI Root
└Camera
└Pannel
└2d Object(Sprite)
의 구조로 게임제작을 진행할때 사용하는 Movement
제목처럼 화면클릭시 목표좌표를 계산(NGUI에 맞게)한뒤
움직이는 방법.(Click to Move)
Movement2D.cs
using UnityEngine;
using System.Collections;
//click to move with NGUI
public class Movement2D : MonoBehaviour {
private int mUIWidth = 720; // UI Root width size
private int mUIHeight = 1280; // UI Root height size
private int mScreenWidth = Screen.width;
private int mScreenHeight = Screen.height;
...
2014년 5월 1일 목요일
Posted by ColaLib on 오전 1:50 with 2 comments
Explanation.
현재 게임 화면 캡쳐기능.
현재 스크린 그대로를 readpixel하는 방식이라
OnGUI로 그려지는 UI는 캡쳐X
스크린 사이즈 그대로 RGB24 포멧으로 저장.
ScreenCapture.cs
using UnityEngine;
using System.Collections;
using System.IO;
public class ScreenCapture : MonoBehaviour
{
int height = Screen.height;
int width = Screen.width;
Texture2D captureTexture;
float startTime;
string saveDir = "ScreenShot"; // 저장 폴더 이름.
bool draw = false;
void OnGUI()
{
if (GUI.Button(new Rect(10, 50, 100, 50), "Capture"))
{
StartCoroutine(screenCapture());
...
Posted by ColaLib on 오전 1:22 with No comments

Explanation.
이전에 프로젝트에서 사용했던 Effect Manager 저장용
Effect 전용 카메라 생성후
카메라 내부에 Effect Manager Script Add
카메라기준 이펙트 스폰 위치의 local position값을 기준으로
이펙트 생성.
TODO.
Wolrd position값을 기준으로 effect생성?
PlayType별로 effect play
EffectManager.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class EffectManager : MonoBehaviour
{
#region Singleton
private static EffectManager sInstance;
...
Posted by ColaLib on 오전 12:41 with No comments

Explanation.
현재 화면을 capture한뒤 mosaic처리.
잠깐 시간이나서 구현.
최적화 X(개선필요)
모자이크 처리방식 매우 비효율적.(개선필요)
어디 쓰일지도 의문.
정리해두고 추후 필요시 사용.
CaptureAndMosaic.cs
using UnityEngine;
using System.Collections;
public class CaptureAndMosaic : MonoBehaviour
{
int height = Screen.height;
int width = Screen.width;
Texture2D captureTexture;
float startTime;
bool draw = false;
void Start()
{
startTime = Time.realtimeSinceStartup;
...
피드 구독하기:
글 (Atom)