2016๋…„ 12์›” 11์ผ ์ผ์š”์ผ

๋ธ”๋กœ๊ทธ ์ด์ „.

2015๋…„ 7์›” 23์ผ ๋ชฉ์š”์ผ

์ข‹์€ ๊ธ€



๊ทธ๋Œ€๊ฐ€ ์„œ ์žˆ๋Š” ๊ณณ์—์„œ,
๊ทธ๋Œ€๊ฐ€ ๊ฐ€์ง„ ๊ฒƒ์œผ๋กœ,
๊ทธ๋Œ€๊ฐ€ ํ•  ์ˆ˜ ์žˆ๋Š”
์ตœ์„ ์˜ ์ผ์„ ํ•˜๋ผ.
-๋ฃจ์ฆˆ๋ฒจํŠธ

2015๋…„ 7์›” 16์ผ ๋ชฉ์š”์ผ

Visual Studio Extensions_Code Maid

Explain.
Visual Sutdio Extensions ํ”„๋กœ๊ทธ๋žจ์ค‘
Code Maid์— ๋Œ€ํ•ด ์ •๋ฆฌ.
Join Line, Sort Line ,Code CleanUp, Code space ๋“ฑ์˜ ๊ธฐ๋Šฅ ์ œ๊ณต.
์„ค์น˜๋ฐฉ๋ฒ• ๋ฐ ๋Œ€ํ‘œ์ ์ธ ๊ธฐ๋Šฅ ์ •๋ฆฌ ์˜ˆ์ •...

Visual Studio_Hot key


Explain.
Visual Studio Hot key list
์ž์ฃผ์“ฐ๋Š” ๋‚ด์šฉ Bold


Rename : Ctrl + R, R
Extract Method : Ctrl + R , M
Extract Interface : Ctrl + R, I

Quick Resolve : Ctrl + .
Navigator : Ctrl + ,
Find All Reference : Shift + F12
Class View : Ctrl + Shift + C
Auto Document : Ctrl + K + D

Comment Selection : Ctrl + K + C
UnComment Selection : Ctrl + K + U

Go to : Ctrl + G

2015๋…„ 6์›” 21์ผ ์ผ์š”์ผ

C#_Naver Search API ํ™œ์šฉ ์†Œ์Šค


AnalysisEngine.
class AnalysisEngine
{
    public enum Step
    {
        WEB,
        IN,
        CAFE,
        BLOG
    }

    const string NAVER_OPENAPI_KEY = "InputYourNaverAPIKey";
    const string NAVER_OPENAPI_URL = "http://openapi.naver.com/search?";
    const int NAVER_SEARCH_COUNT = 100;

    string keyword;
    string url;
    string blog;
    string cafe;

    public AnalysisEngine(string keyword, string url, string blog, string cafe)
    {
        this.keyword = keyword;
        this.url = url;
        this.blog = blog;
        this.cafe = cafe;
    }

    public void Analysis()
    {
        AnalysisResult result = new AnalysisResult();
        

        result.webRank = AnalysisProccess(Step.WEB, url);
        result.blogRank = AnalysisProccess(Step.BLOG, blog);
        result.cafeRank = AnalysisProccess(Step.CAFE, cafe);

        Console.WriteLine("0 = 100์œ„์•ˆ์— ์—†์Œ.");
        Console.WriteLine("๋„ค์ด๋ฒ„ ์›น๋ฌธ์„œ ๋ถ„์„ ๊ฒฐ๊ณผ : " + result.webRank);
        Console.WriteLine("๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ ๋ถ„์„ ๊ฒฐ๊ณผ : " + result.blogRank);
        Console.WriteLine("๋„ค์ด๋ฒ„ ์นดํŽ˜ ๋ถ„์„ ๊ฒฐ๊ณผ : " + result.cafeRank);

        Console.ReadLine();
    }

    int AnalysisProccess(Step step, string target)
    {
        string html = AnalysisTools.GetHTML(CreateURL(step));

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(html);

        int rank = 0;

        foreach (XmlNode node in doc.SelectNodes("rss/channel/item/link"))
        {
            string realURL = GetRealURL(node.InnerText);

            if (realURL.Length > target.Length)
                realURL = realURL.Substring(0, target.Length);

            Console.WriteLine(realURL);

            ++rank;
            if (target == realURL)
            {
                return rank;
            }
        }

        return 0;
    }

    string CreateURL(Step step)
    {
        string target = "";
        switch (step)
        {
            case Step.WEB: target = "webkr";
                break;
            case Step.IN: target = "in";
                break;
            case Step.CAFE: target = "cafearticle";
                break;
            case Step.BLOG: target = "blog";
                break;
            default:
                break;
        }

        return string.Format("{0}key={1}&query={2}&display={4}&start=1&target={3}", NAVER_OPENAPI_URL, NAVER_OPENAPI_KEY, keyword, target, NAVER_SEARCH_COUNT);

    }

    /*
    Naver API๋ฅผ ํ™œ์šฉํ•˜์—ฌ url์ฃผ์†Œ๋ฅผ ํš๋“ ํ•  ์‹œ
    ์‹ค์ฃผ์†Œ๊ฐ€ ์•„๋‹Œ API ๋กœ ๋งตํ•‘๋œ ๊ฐ€์ƒ์ฃผ์†Œ๋ฅผ ์ œ๊ณต ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์—
    ์ง์ ‘ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ์ฃผ์†Œ๋ฅผ ํš๋“ํ•˜์—ฌ ๋ฐ˜์˜ ํ•˜๊ธฐ์œ„ํ•œ ํ•จ์ˆ˜.
    */

    string GetRealURL(string url) 
    {
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
        webRequest.AllowAutoRedirect = false;

        webRequest.Timeout = 10000;           
        webRequest.Method = "HEAD";

        HttpWebResponse webResponse;
        string uriString = string.Empty;

        using (webResponse = (HttpWebResponse)webRequest.GetResponse())
        {
            if ((int)webResponse.StatusCode >= 300 && (int)webResponse.StatusCode <= 399)
            {
                uriString = webResponse.Headers["Location"];
                webResponse.Close();
            }
        }

        return uriString;
    }
}

AnalysisResult
class AnalysisResult
{
    public int webRank;
    public int cafeRank;
    public int blogRank;
}

AnalysisTool
class AnalysisTools
{
    public static string GetHTML(string url)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        if (response.StatusCode == HttpStatusCode.OK)
        {
            Stream receiveStream = response.GetResponseStream();
            StreamReader readStream = null;

            if (response.CharacterSet == null)
            {
                readStream = new StreamReader(receiveStream);
            }
            else
            {
                readStream = new StreamReader(receiveStream, Encoding.UTF8);
            }

            string data = readStream.ReadToEnd();

            response.Close();
            readStream.Close();

            return data;
        }

        return string.Empty;
    }
    
}

Main
class Program
{
    static string keyword = ""; //ํ‚ค์›Œ๋“œ
    static string homepage = ""; //ํ™ˆํŽ˜์ด์ง€ ์ฃผ์†Œ
    static string blog = ""; //๋ธ”๋กœ๊ทธ ์ฃผ์†Œ
    static string cafe = ""; //์นดํŽ˜ ์ฃผ์†Œ


    static void Main(string[] args)
    {

        AnalysisEngine engine = new AnalysisEngine(
            keyword , 
            homepage, 
            blog,
            cafe);

        engine.Analysis();

        
    }
}

2015๋…„ 6์›” 2์ผ ํ™”์š”์ผ

Unity_์ฝ”๋ฃจํ‹ด ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•œ Lerpํ•จ์ˆ˜ ํ™œ์šฉ using IEnumerator with Lerp

Explain.

Unity Coroutine ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•œ Object์˜ Lerp(์„ ํ˜•๋ณด๊ฐ„)์šด๋™ ๊ตฌํ˜„๊ตฌํ˜„
๊ฐ€์žฅ ์‹ฌํ”Œํ•˜๊ฒŒ ๊ตฌํ˜„ํ•œ ์˜ˆ์ œ.
C#์˜ Generic , Reflection์„ ํ™œ์šฉํ•˜์—ฌ ๊ธฐ๋Šฅ ํ™•์žฅ ๊ฐ€๋Šฅ.

Code.
IEnumerator moveCoroutine(float duration, Vector3 end)
{
 WaitEndOfFrame wait = new WaitEndOfFrame();

 Vector3 start = transform.position;
 float elapsed = 0.0f;

 while(elapsed < duration){
  elapsed += Time.deltatime;
  transform.position = Vector3.Lerp(start,end elapsed / duration);
  yield return wait;
 }

 transform.position = end;
}

IEnumerator colorCoroutine(float duration, Color start, Color end)
{
 WaitEndOfFrame wait += new WaitEndOfFrame();

 float elapsed = 0.0f;

 while(elapsed < duration){
  elapsed = Time.deltaTime;
  renderer.material.color  = Color.Lerp(start,end elapsed / duration);
  yield return wait;
 }

 renderer.material.color = end;
}

2015๋…„ 5์›” 14์ผ ๋ชฉ์š”์ผ

Game Open Source_3-Match Puzzle ํ˜•์‹์˜ ๊ฒŒ์ž„ ์†Œ์Šค



์˜ˆ์ „์— ๋งŒ๋“ค์–ด๋‘” 3-Matchํ˜•์‹(์• ๋‹ˆํŒก) ์†Œ์Šค๋ฅผ Github์— ์˜ฌ๋ ค๋‘”๊ฒŒ ์žˆ์–ด์„œ ํฌ์ŠคํŒ….


References.
Github.
PlayStore.

C#_Naver Search API ํ™œ์šฉ ์˜ˆ์ œ


Explain.
C#ํ™˜๊ฒฝ ์—์„œ ๋„ค์ด๋ฒ„ ์˜คํ”ˆ ๊ฒ€์ƒ‰ API ๋ฅผ ํ™œ์šฉํ•˜๋Š” ์˜ˆ์ œ.

Input - ํ‚ค์›Œ๋“œ(๊ฒ€์ƒ‰๊ฐ’), ํŽ˜์ด์ง€(URL)
Output - ๋„ค์ด๋ฒ„ ๋…ธ์ถœ ์ˆœ์œ„

Environment.
Visual Studio 2015 Comunity.
Naver Search API KEY


Logic flow.
1. Input / Keyword, Home Page URL
2. WebRequest๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋„ค์ด๋ฒ„ ์˜คํ”ˆ API์— request ์š”์ฒญ ํ›„ respawn ๋ฐ์ดํ„ฐ ์ €์žฅ.
3. 2.์˜ respawn ๋ฐ์ดํ„ฐ ๋„ค์ด๋ฒ„ ๋…ธ์ถœ ์ˆœ์œ„ ๊ฒ€์ƒ‰.

์†Œ์Šค ์ฝ”๋“œ

Result.














์†Œ์Šค ์ฝ”๋“œ

2015๋…„ 4์›” 15์ผ ์ˆ˜์š”์ผ

Finite State Machine for CSharp_Step2. ํ™œ์šฉ ์˜ˆ์ œ

Explain.
๊ฒŒ์ž„ ์ œ์ž‘์‹œ MainFrame(MainManager, GameManager ๋“ฑ)์—์„œ FSM์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ• ์ •๋ฆฌ


MainFrame.cs
class MainFrame
{
    public enum State
    {
        Game,
        Lobby
    }

    FiniteStateMachine<MainFrame, State> FSM;
    
    LobbyState stateLobby = new LobbyState();
    GameState stateGame = new GameState();

    void Awake()
    {
        FSM = new FiniteStateMachine<MainFrame, State>(this);
        FSM.AddState(stateLobby);
        FSM.AddState(stateGame);

        FSM.ChangeState(stateLobby); // ์‹œ์ž‘์‹œ stateLobby State
    }
}
LobbyState.cs
class LobbyState : FiniteState<MainFrame, MainFrame.State>
{
    public override void SetEntity(MainFrame entity)
    {
        base.SetEntity(entity);
    }
    public override void Enter()
    {
        base.Enter();
        //๊ฒŒ์ž„ ์ž…์žฅ์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }
    public override void Excute()
    {
        base.Excute();
        //๊ฒŒ์ž„ ์‹คํ–‰์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }
    public override void Exit()
    {
        base.Exit();
        //๊ฒŒ์ž„ ํ‡ด์žฅ์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }

    public override MainFrame.State _StateID
    {
        get
        {
            return MainFrame.State.Game;
        }
    }
}
GameState.cs
class GameState : FiniteState<MainFrame, MainFrame.State>
{
    public override void SetEntity(MainFrame entity)
    {
        base.SetEntity(entity);
    }
    public override void Enter()
    {
        base.Enter();
        //๊ฒŒ์ž„ ์ž…์žฅ์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }
    public override void Excute()
    {
        base.Excute();
        //๊ฒŒ์ž„ ์‹คํ–‰์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }
    public override void Exit()
    {
        base.Exit();
        //๊ฒŒ์ž„ ํ‡ด์žฅ์‹œ ์ด๋ฒคํŠธ ๊ตฌํ˜„๋ถ€
    }

    public override MainFrame.State _StateID
    {
        get
        {
            return MainFrame.State.Game;
        }
    }
}

Finite State Machine for CSharp_Step1. FSM ๊ตฌํ˜„

Explain. 
์œ ํ•œ ์ƒํƒœ ๊ธฐ๊ณ„๋ผ๊ณ  ํ•˜๋ฉฐ, ํŠน์ •ํ•œ Input(event) ์— ๋”ฐ๋ผ ํ•ด๋‹นํ•˜๋Š” state(output)์œผ๋กœ ๋ณ€ํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•๋ก . ๋‹ค์–‘ํ•œ ๋ถ„์•ผ(ํŠนํžˆ ๊ฒŒ์ž„)์— ์‚ฌ์šฉ๋˜์–ด ์ง€๊ณ ์žˆ์œผ๋ฉฐ ์ƒํƒœ์— ๋ณ€ํ™”์— ๋”ฐ๋ฅธ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ์ˆ˜์žˆ์œผ๋ฏ€๋กœ ์ข€๋” ์œ ์—ฐํ•œ ๋กœ์ง์„ ๊ตฌ์„ฑํ• ์ˆ˜์žˆ๋‹ค. ์ด์ „์— ๊ฒŒ์ž„ ์ œ์ž‘์‹œ ์‚ฌ์šฉํ–ˆ๋˜ ํ˜„์žฌ๋„ ์‚ฌ์šฉํ•˜๊ณ ์žˆ๋Š” FSM์— ๋Œ€ํ•ด ์ •๋ฆฌ. ์Šคํฌ๋ฆฝํŠธ ์„ค๋ช…์˜๊ฒฝ์šฐ ์ฃผ์„์œผ๋กœ ์ง„ํ–‰.

Step. 
1. FiniteStateMachine ๊ตฌํ˜„
2. ๊ฐ„๋‹จํ•œ ์‚ฌ์šฉ๋ฒ•

FSM ๊ตฌํ˜„

Summary.
 IState ( FiniteState์˜ ๋ช…์„ธ๋ฅผ ๋‹ด์€ Interface )
 FiniteState ( State ํด๋ž˜์Šค )
 FiniteStateMachine ( FSM ํด๋ž˜์Šค )

IState.cs

interface IState<T>
{
    
    void Enter();
    void Excute();
    void Exit();

    T _StateID
    {
        get;
    }
}

FiniteState.cs
class FiniteState<T, U> : IState<U>
{
    protected T entity;

    public virtual void SetEntity(T entity)
    {
        this.entity = entity;
    }

    public virtual void Enter()
    {
        Console.WriteLine(typeof(T).ToString() + "Enter");
    }

    public virtual void Excute()
    {
        Console.WriteLine(typeof(T).ToString() + "Excute");
    }

    public virtual void Exit()
    {
        Console.WriteLine(typeof(T).ToString() + "Exite");
    }

    public virtual U _StateID
    {
        get
        {
            throw new ArgumentException("Exception");
        }
    }

}

FiniteStateMachine.cs
class FiniteStateMachine<T, U>
{
    private T entity; // State์˜ ์ฃผ์ฒด๊ฐ€ ๋˜๋Š” class

    private Dictionary<U, FiniteState<T, U>> stateDic; // ์ „์ฒด State

    private FiniteState<T, U> currentState; // ํ˜„์žฌ ์ƒํƒœ
    private FiniteState<T, U> previousState; // ์ด์ „ ์ƒํƒœ

    /// <summary>
    /// ์ƒ์„ฑ์ž
    /// </summary>
    /// <param name="entity">์ฃผ์ฒด class</param>
    public FiniteStateMachine(T entity)
    {
        this.entity = entity;
        stateDic = new Dictionary<U, FiniteState<T, U>>();
    }

    public void ExcuteState()
    {
        if (currentState != null) currentState.Excute();
    }

    public void ChangeState(FiniteState<T, U> nextState)
    {
        if (currentState == nextState) return;

        if(currentState != null)
        {
            currentState.Exit();
            previousState = currentState;
        }

        currentState = nextState;

        currentState.Enter();
    }

    public void ChangeState(U stateID)
    {
        try
        {
            FiniteState<T, U> state = stateDic[stateID];
            ChangeState(state);
        }
        catch(KeyNotFoundException)
        {
            // exception ์ฒ˜๋ฆฌ
        }
    }

    //์ด์ „ state๋กœ ์ƒํƒœ ๋˜๋Œ๋ฆฌ๊ธฐ
    public void RevertState()
    {
        if (previousState != null)
            ChangeState(previousState);
    }

    public void AddState(FiniteState<T, U> state)
    {
        if (state == null) return;
        state.SetEntity(entity);
        stateDic.Add(state._StateID, state);
    }

    public void RemoveState(FiniteState<T, U> state)
    {
        stateDic.Remove(state._StateID);
    }
}

2015๋…„ 4์›” 8์ผ ์ˆ˜์š”์ผ

Visual Stduio2013์— Boost Library ์„ค์น˜ํ•˜๊ธฐ.



Summary.
 - Boost Library๋ž€? C++ STL์— ํฌํ•จ๋˜๊ธฐ์ „ ์ฒ ์ €ํ•œ ๋ฆฌ๋ทฐ๋ฅผ ๊ฑฐ์ณ ์‹คํ—˜์ ์ธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ. ๋งค์šฐ ๊ด‘๋Œ€ํ•œ ์˜์—ญ์„ ํ’ˆ๊ณ ์žˆ์œผ๋ฉฐ ์‹ค์ œ๋กœ C++ STL ํ‘œ์ค€์— ๋งŽ์€ ๋ถ€๋ถ„์ด ํฌํ•จ๋˜์–ด์ง€๊ธฐ๋„ํ•œ๋‹ค.
๋•Œ๋ฌธ์—, C++ ํ‘œ์ค€์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๊ธฐ๋„ ํ•œ๋‹ค.

Environment.
 - Visual Studio 2013 Ultimate.
 - Window 7 professional 64bit.

Step.
 - 1. boost Library ๋‹ค์šด๋กœ๋“œ , ์••์ถ•ํ•ด์ œ
 - 2. Boost Lib ๋นŒ๋“œ
 - 3. VS2013 property์— lib ์ถ”๊ฐ€.


How to used?.
1. boost Library ๋‹ค์šด๋กœ๋“œ , ์••์ถ•ํ•ด์ œ
  boost ํ™ˆํŽ˜์ด์ง€์— ์ ‘์†ํ•˜์—ฌ boost lib ์••์ถ•ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ํ•œ๋’ค
์•„๋ฌด๊ณณ์—๋‚˜ ์••์ถ•ํ•ด์ œํ•˜์—ฌ ์œ„์น˜์‹œํ‚จ๋‹ค.

2.Boost Lib ๋นŒ๋“œ

  • ์••์ถ• ํ•ด์ œ๋œ ํด๋”๋‚ด์˜ bootstrap.bat ๋ฐฐ์น˜ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ๋‹ค.
  • ๊ทธํ›„ cmd๋ฅผ ์‹คํ–‰ํ•œ๋’ค ํ•ด๋‹น ํด๋”๋กœ ์ด๋™ํ•˜๊ณ  b2ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์—ฌ ์ปดํŒŒ์ผ ํ•œ๋‹ค.
    • b2 toolset=msvc-12.0 --build-type=complete --abbreviate-paths architecture=x86 address-model=32 install -j4
      • b2 : build boost
      • msvs-12.0 : vs version
      • j4 : 4 cores for parallel compilation ์‚ฌ์šฉ
  • ์ดํ›„ 20~30๋ถ„ ์ •๋„์˜ ๋นŒ๋“œ ์‹œ๊ฐ„์„ ๊ฑฐ์นœ ๋’ค header ํŒŒ์ผ ๋ฐ lib ํŒŒ์ผ์ด ์ƒ์„ฑ ๋œ๋‹ค.
    • ๊ฒฝ๋กœ : C:\Boost
3. VS2013 property์— lib ์ถ”๊ฐ€.

Project Properties ์ฐฝ์„ ์„ ํƒํ•œ๋’ค.

Include Directories ์— C:\Boost\include ํด๋”๋ฅผ ํฌํ•จ์‹œํ‚จ๋‹ค.




Reference.
 - How to use boost in visual studio

More.
 - ์ดํ›„ boost ํ—ค๋”ํŒŒ์ผ์„ ํฌํ•จ์‹œํ‚ค๋ฉด์„œ ์ฝ”๋”ฉ์„ ์ง„ํ–‰ํ•˜๋ฉด ๋œ๋‹ค. ๋‹ค๋งŒ link ๋‹จ๊ณ„์—์„œ์˜ ์ข…์†์„ฑ์ด ์š”๊ตฌ๋˜๋Š” ๋ถ€๋ถ„์„ ์‚ฌ์šฉํ• ๊ฒฝ์šฐ ๋”ฐ๋กœ ์„ค์ •ํ•ด์•ผํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ์œผ๋‹ˆ ๊ธฐ์–ตํ•ด๋‘๊ณ  ์ง„ํ–‰ํ•œ๋‹ค.(๋ ˆํผ๋Ÿฐ์Šค ์ฐธ๊ณ ) 

2015๋…„ 2์›” 11์ผ ์ˆ˜์š”์ผ

Android Push Server_ Step1.AWS ๊ณ„์ •์ƒ์„ฑ ๋ฐ AWS EC2 Instance ์ƒ์„ฑ.


Explain.
 - ์ด๋ฒˆ์— ํ‘ธ์‰ฌ์„œ๋ฒ„ ๊ตฌํ˜„ ์ง„ํ–‰์ค‘ AWS ํšŒ์›๊ฐ€์ž…์‹œ FreeTier ๊ถŒํ•œ์œผ๋กœ 1๋…„๊ฐ„ ๋ฌด๋ฃŒ๋กœ AWS๋ฅผ ์‚ฌ์šฉํ• ์ˆ˜์žˆ๋Š”์ ์„ ๋ฐœ๊ฒฌํ•ด์„œ ์ง„ํ–‰. ์ž์„ธํ•œ๋‚ด์šฉ์€ AWS ํ™ˆํŽ˜์ด์ง€ ์ฐธ๊ณ . ํ•œ๊ธ€์–ด๋„ ์ผ๋ถ€ ์ง€์›ํ•˜๋Š”๊ฒƒ์œผ๋กœ ๋ณด์ด๊ณ  ๊ณ„์† ๋ฒˆ์—ญ ์ง„ํ–‰์ค‘์ธ๊ฒƒ์œผ๋กœ ๋ณด์—ฌ์ง.(๊ตฟ)
 - ํšŒ์›๊ฐ€์ž…์˜๊ฒฝ์šฐ ํ•œ๊ธ€์–ด๋กœ ํผ์„ ์ง€์›ํ•˜๊ธฐ๋•Œ๋ฌธ์— ๋”ฐ๋กœ ์ •๋ฆฌํ•˜์ง€๋Š” ์•Š์•˜์Šต๋‹ˆ๋‹ค.


1.ํšŒ์›๊ฐ€์ž…ํ›„ ๋กœ๊ทธ์ธ์‹œ ๋ณผ์ˆ˜์žˆ๋Š” AWS์„œ๋น„์Šค ํ™”๋ฉด
EC2๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์„œ๋ฒ„๊ตฌํ˜„์„ ์ง„ํ–‰ํ• ๊ฒƒ์ด๋ฏ€๋กœ EC2๋ฅผ ์„ ํƒํ•œ๋‹ค.

2. ๊ทธํ›„ ์ธ์Šคํ„ด์Šค๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ๋˜๊ธฐ๋•Œ๋ฌธ์— ์ขŒ์ธก์— ์ธ์Šคํ„ด์Šค ํด๋ฆญ.

3. ํ˜„์žฌ ์‹คํ–‰์ค‘์ธ ์ธ์Šคํ„ด์Šค๋“ค์„ ๋ณด์—ฌ์ฃผ๋Š” ์ฐฝ์ด๋‚˜์˜ค๋Š”๋ฐ
์ƒ๋‹จ์˜ Launch Instance๋ฅผ ์„ ํƒ

4. OS ์„ ํƒ. Amazon Linux๋ฅผ ์„ ํƒํ•˜์—ฌ ์ง„ํ–‰.(๋‹ค๋ฅธ์šด์˜์ฒด์ œ๋ฅผ ์„ ํƒํ•˜์…”๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.)

5. Instance type์„ ์„ ํƒํ•˜๋Š” ๋ถ€๋ถ„์ธ๋ฐ free tier์šฉ ํƒ€์ž…(t2.micro) ์„ ํƒ
ํ›„ Next

6. ์ดํ›„ ์„œ๋ฒ„๊ด€๋ จ ์…‹ํŒ…(๊ณผ๊ธˆ๊ณผ ๊ด€๋ จ๋œ ๋ถ€๋ถ„์€ ์•ˆ๊ฑด๋“œ์‹œ๋Š”๊ฒŒ ์ข‹์Šต๋‹ˆ๋‹ค.^^;)
๋”ฑํžˆ ๋”ฐ๋กœ ์…‹ํŒ…์ด ํ•„์š”์—†์œผ์‹ ๋ถ„์€
๋””ํดํŠธ๋กœ ๋†”๋‘์‹œ๊ณ  Launch ํ•˜์…”๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ๊นŒ์ง€ ์ง„ํ–‰ํ•˜์‹ ๊ฒฝ์šฐ 3๋ฒˆ์˜ ํ™”๋ฉด์—์„œ ์ƒ์„ฑ๋œ ์ธ์Šคํ„ด์Šค์˜ ์ƒํƒœ์™€ ์ •๋ณด๋ฅผ ๋ณผ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค.
๋‹ค์Œํฌ์ŠคํŒ…์—์„œ๋Š” AWS์— LAMP ํ™˜๊ฒฝ ๊ตฌ์ถ•ํ•˜๋Š”๊ฒƒ์„ ์ง„ํ–‰.

Android Push Server_ AWS ๋ฅผ ํ™œ์šฉํ•œ ์•ˆ๋“œ๋กœ์ด๋“œ ํ‘ธ์‰ฌ ์„œ๋ฒ„ ๊ตฌํ˜„.



Summary.
 -AWS(Amazon Web Services) EC2๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์•ˆ๋“œ๋กœ์ด๋“œ ํ‘ธ์‰ฌ์„œ๋ฒ„ ๊ตฌํ˜„ ๋‚ด์šฉ ์ •๋ฆฌ.

Server.
 -EC2(Amazon Linux) + Apche + php + mysql ๋กœ ๊ตฌ์„ฑ.(LAMP)

Step.
 1. AWS ๊ณ„์ •์ƒ์„ฑ ๋ฐ AWS EC2 Instance ์ƒ์„ฑ.
 2. EC2 Instance ์…‹ํŒ… ๋ฐ LAMP ํ™˜๊ฒฝ ์…‹ํŒ….
 3. ์•ˆ๋“œ๋กœ์ด๋“œ ํ‘ธ์‰ฌ ์„œ๋ฒ„ ๊ตฌํ˜„.
 4. ์•ˆ๋“œ๋กœ์ด๋“œ ํ‘ธ์‰ฌ ํด๋ผ์ด์–ธํŠธ(apk) ์ƒ์„ฑ ๋ฐ ํ…Œ์ŠคํŠธ.

Environment.
 - Window 7
 - Eclips
 - Sublime Text 3 SFTP
 - Filezlia
 - Putty

2015๋…„ 1์›” 29์ผ ๋ชฉ์š”์ผ

C#.HtmlLoader_HtmlAgilityPack์„ํ™œ์šฉํ•˜์—ฌ Web์—์„œ Html ๋ฐ์ดํ„ฐ ๋ฐ›์•„์˜ค๋Š”๋ฒ•.

Summary.
  -C#ํ™˜๊ฒฝ(.net)์—์„œ ์‚ฌ์šฉํ• ์ˆ˜์žˆ๋Š” HtmlAgilityPack์„ ํ™œ์šฉํ•˜์—ฌ Web์—์„œ Html๋ฐ์ดํ„ฐ ๋ฐ›์•„์˜ค๋Š” ์ฝ”๋“œ.

Requirements.
 -HtmlAgilityPack Library
   : VS ๋‚ด์˜ NuGet Pakage Manager๋ฅผ ํ†ตํ•ด ์„ค์น˜ํ• ์ˆ˜ ์žˆ๋‹ค.


Code.
class HtmlLoader
{
    public enum State
    {
        Working,
        End
    }

    string mURL;
    HtmlDocument mDocument;
    State mState;
    Action mCallback;
    Encoding mEncoding;

    public HtmlLoader(string url, Encoding enc , Action callback)
    {
        this.mURL = url;
        this.mState = State.End;
        this.mCallback = callback;
        this.mEncoding = enc;
    }

    //์ƒˆ๋กœ์šด ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์‹คํ–‰.
    public void LoadWithThread()
    {
        if (mState == State.Working) return;

        Thread thraed = new Thread(new ThreadStart(LoadHtml));
        thraed.Start();

    }
    
    //ํ˜ธ์ถœํ•œ ์Šค๋ ˆ๋“œ์ƒ์—์„œ ๋ฐ”๋กœ ์‹คํ–‰.
    public void Load()
    {
        if (mState == State.Working) return;
        LoadHtml();
        
    }

    void LoadHtml()
    {
        mState = State.Working;

        mDocument = new HtmlDocument();
        HtmlWeb website = new HtmlWeb();
        StreamReader reader = new StreamReader(WebRequest.Create(mURL).GetResponse().GetResponseStream(), mEncoding);   

        mDocument.Load(reader);

        mCallback();
        mState = State.End;
    }
    
    public HtmlDocument _Document
    {
        get { return mDocument; }
    }
}
Use.
string url = textBox1.Text;

loader = new HtmlLoader(url,
    Encoding.GetEncoding("euc-kr"),
    new Action(() => 
        System.IO.File.WriteAllText("web.txt", loader._Document.DocumentNode.InnerText)
));
loader.LoadWithThread();
์ดํ›„ ์ƒ์„ฑ๋˜๋Š” web.txtํŒŒ์ผ์„ ํ™•์ธํ• ์ˆ˜์žˆ๋‹ค.

2014๋…„ 11์›” 6์ผ ๋ชฉ์š”์ผ

Unity_IOS ์—์„œ Screen Captureํ•œ ์ด๋ฏธ์ง€๋ฅผ Social.framework๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ณต์œ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ •๋ฆฌ.

Explain.


IOS ์—์„œ Screen Captureํ•œ ์ด๋ฏธ์ง€๋ฅผ Social.framework๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ณต์œ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ •๋ฆฌ.


Sequence.


1. Application.CaptureScreenShot() ์œผ๋กœ ์บก์ณ์ง„ํ–‰.

2. ์œ„์˜ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ง€๊ณ  IOS์˜ social.framwork๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์‰์–ด์ง„ํ–‰.


In Xcode

์•„๋ž˜ 2ํŒŒ์ผ[SocialHelper.h , mm]์„ ํ˜„์žฌ ํ”„๋กœ์ ํŠธ์˜ Plugin/IOS ์œ„์น˜ ์‹œํ‚จ๋‹ค.

SocialHelper.h
#import &ltFoundation/Foundation.h>

@interface SocialHelper : NSObject
{
    
}

+(void)ImageToTwitter:(NSString*)filePath;

+(void)ImageToFaceBook:(NSString*)filePath;

@end

SocialHelper.mm
#import "SocialHelper.h"

#import &ltSocial/Social.h>
#import &ltUIKit/UIKit.h>
#import &ltUnityAppController.h>

#pragma mark - Unity methods

@implementation SocialHelper


+ (void) ImageToTwitter:(NSString *) filePath
{
    UIViewController *rootViewController = [GetAppController() rootViewController];
    UIImage *image = [UIImage imageWithContentsOfFile:filePath];
    
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]){
        SLComposeViewController *mySLComposeSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        
        [mySLComposeSheet setInitialText:@"Let's Play Together!"];
        [mySLComposeSheet addImage:image];
        [mySLComposeSheet addURL:[NSURL URLWithString:@"https://myurl.com"]];
        [mySLComposeSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    NSLog(@"Twtitter - POST Cancel");
                    break;
                    
                case SLComposeViewControllerResultDone :
                    NSLog(@"Twitter - Post Success");
                    break;
                    
                default:
                    break;
            }
        }];
        [rootViewController presentViewController:mySLComposeSheet animated:YES completion:nil];
    }
}

+ (void) ImageToFaceBook:(NSString *) filePath
{
    UIViewController *rootViewController = [GetAppController() rootViewController];
    UIImage *image = [UIImage imageWithContentsOfFile:filePath];
    
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){
        SLComposeViewController *mySLComposeSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        
        [mySLComposeSheet setInitialText:@"Let's Play Together!"];
        [mySLComposeSheet addImage:image];
        [mySLComposeSheet addURL:[NSURL URLWithString:@"https://myurl.com"]];
        [mySLComposeSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    NSLog(@"Facebook - POST Cancel");
                    break;
                    
                case SLComposeViewControllerResultDone :
                    NSLog(@"Facebook - Post Success");
                    break;
                    
                default:
                    break;
            }
        }];
        [rootViewController presentViewController:mySLComposeSheet animated:YES completion:nil];
    }
}

extern "C" {
    void PostImageToTwitter(const char * filePath)
    {
        NSLog(@"Share Iamge Path : %@", [NSString stringWithUTF8String:filePath]);
        [SocialHelper ImageToTwitter:[NSString stringWithUTF8String:filePath]];
    }
    
    void PostImageToFacebook(const char * filePath)
    {
        NSLog(@"Share Iamge Path : %@", [NSString stringWithUTF8String:filePath]);
        [SocialHelper ImageToFaceBook:[NSString stringWithUTF8String:filePath]];
    }
}

@end



In Unity

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;


public enum SocialType : int
{
    Twitter,
    Facebook
}

public class SocialHelper : MonoBehaviour
{

    public static IEnumerator PostImage(SocialType type)
    {
        string fileName = getCaptureFileName();

        Application.CaptureScreenshot(fileName);

        yield return new WaitForSeconds(1.0f);

        if (type == SocialType.Facebook)
            PostImageToFacebook(string.Format("{0}/{1}", Application.persistentDataPath, fileName));

        if (type == SocialType.Twitter)
            PostImageToTwitter(string.Format("{0}/{1}", Application.persistentDataPath, fileName));
    }

    static string getCaptureFileName()
    {
        return string.Format("capture_{0}.png", System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
    }



    [DllImport("__Internal")]
    static extern void PostImageToTwitter(string filePath);

    [DllImport("__Internal")]
    static extern void PostImageToFacebook(string filePath);

}

SocialHelper.PostImage(SocialType.Facebook); // ์ดํ›„ ์ด๋Ÿฐ์‹์œผ๋กœ ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœ์‹œ ๊ณต์œ ๊ฐ€ ์ง„ํ–‰.



Reference.


IOS ์—์„œ Screen Captureํ•œ ์ด๋ฏธ์ง€ Camera Roll์— ๋“ฑ๋กํ•˜๊ธฐ.

Social.Framework


2014๋…„ 10์›” 31์ผ ๊ธˆ์š”์ผ

Unity for IOS_Screen Captureํ•œ ์ด๋ฏธ์ง€ ์นด๋ฉ”๋ผ๋กค ์— ๋“ฑ๋กํ•˜๊ธฐ.


Explan.

IOS์—์„œ Application.CaptureScreenShot(path) ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ• ๊ฒฝ์šฐ
์บก์ฒ˜๋Š” ์ง„ํ–‰๋˜๋‚˜ ํ•ด๋‹น app ์˜ documentํด๋”๋กœ ๋“ค์–ด๊ฐ€์„œ ์นด๋ฉ”๋ผ ๋กค์—์„œ ํ™•์ธํ• ์ˆ˜๊ฐ€ ์—†๋‹ค.
์ด๋ฅผ ๋“ฑ๋กํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ• ํฌ์ŠคํŒ….


CaptureHelper.h
#import <Foundation/Foundation.h>

@interface CaptureHelper : NSObject

+(CaptureHelper *)sharedInstancs;

@end
CaptureHelper.mm
#import "CaptureHelper.h"

static CaptureHelper * captureHelper = [CaptureHelper sharedInstancs];

@implementation CaptureHelper : NSObject

+ (void)initialize{
    if(captureHelper == nil)
        captureHelper = [[CaptureHelper alloc] init];
}

+ (CaptureHelper *)sharedInstancs{
    return captureHelper;
}

- (id)init{
    if(captureHelper != nil){
        return  captureHelper;
    }
    
    self = [super init];
    if(self){
        captureHelper = self;
    }
    
    return self;
}


- (NSString *)getDocumentDirectory {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
    return [paths objectAtIndex:0];
}

@end

extern "C"{
    void CaptureToCameraRoll(const char *fileName)
    {
        NSString *file = [NSString stringWithUTF8String:(fileName)];
        NSString *filePath = [[captureHelper getDocumentDirectory] stringByAppendingString:file];
        UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath];
        
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    }
}

์œ„ 2๊ฐœ์˜ ํŒŒ์ผ์„ ์ƒ์„ฑํ›„ Plugin/IOS ํด๋”์— ์œ„์น˜ ๊ทธํ›„

how to used.
[DllImport("__Internal")]
public static extern void CaptureToCameraRoll(String fileName);

// ๊ทธ์ดํ›„ ์Šคํฌ๋ฆฐ ์บก์ฒ˜ ์ง„ํ–‰์‹œ.

Application.CaptureScreenShot(path);
CaptureToCameraRoll(string.Format("/{0}",path));


์ดํ›„ ์นด๋ฉ”๋ผ๋กค์—์„œ ์บก์ณ๋œ ์ด๋ฏธ์ง€๋ฅผ ํ™•์ธํ•˜์‹ค์ˆ˜ ์žˆ๋‹ค.

2014๋…„ 10์›” 1์ผ ์ˆ˜์š”์ผ

CSharp_Visual Studio Custom Snippet ์ ์šฉ ์‹œํ‚ค๊ธฐ. in Visual Studio & Unity

Explain.
Visual Studio๋ฅผ ์‚ฌ์šฉํ• ๊ฒฝ์šฐ snippetํŒŒ์ผ์„ ์ง์ ‘ ๋งŒ๋“ค์–ด์„œ ์ ์šฉ.
Snippet์„ ์ ์šฉํ•˜์—ฌ ์ž‘์—…ํ•˜๋Š” ์ด์œ ๋Š” ๋ชจ๋“  ์Šคํฌ๋ฆฝํŠธ์˜ ์ „์ฒด์ ์œผ๋กœ ํ†ต์ผ๋œ ๋””์ž์ธ์„ ์ ์šฉํ•˜๊ณ  ๋ฐ˜๋ณต๋˜์–ด์ง€๋Š” ์ž‘์—…์„ ์ตœ์†Œํ™” ์‹œ์ผœ์คŒ.

How to use.
์•„๋ž˜์ฒ˜๋Ÿผ xmlํ˜•์‹์œผ๋กœ snippet ํŒŒ์ผ์„ ์ƒ์„ฑํ›„ ์ €์žฅ(*.snippet)์œผ๋กœ ์ €์žฅ ํ•˜์—ฌ์•ผ ํ•œ๋‹ค.
(์•„๋ž˜ ํ˜•์‹์€ ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š”(unity)์—์„œ ํ˜•์‹์ด๊ณ  ๋‚ด์šฉ์€ ํ•„์š”ํ•œ๋Œ€๋กœ ํŽธ์ง‘ํ•˜์—ฌ ์‚ฌ์šฉํ•˜์‹œ๋ฉด๋ฉ๋‹ˆ๋‹ค.)
์ €์žฅ๊ฒฝ๋กœ : Users\User\Documents\Visual Studio XXXX\Code Snippets\Visual C#\My Code Snippets

๊ทธ ์ดํ›„
ํ”„๋กœ์ ํŠธ์—์„œ ์šฐํด๋ฆญ-> Insert Code Snippet -> My Code Snippet -> ํ•ด๋‹น Snippet ์„ ํƒ
ํ•ด์ฃผ์‹œ๋ฉด snippet์ด ์ง  ํ•˜๊ณ  ๋‚˜ํƒ€๋‚˜๋Š”๊ฒƒ์„ ๋ณด์‹ค์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
ctrl + K + X๊ฐ€ Hotkey์ด๋‹ˆ ์• ์šฉํ•˜์‹œ๋ฉด ๋ ๋“ฏํ•ฉ๋‹ˆ๋‹ค. -End.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>#Classregion</Title>
      <Shortcut>#Classregion</Shortcut>
      <Description>Code snippet for #Classregion</Description>
      <Author>Author Name</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>name</ID>
          <ToolTip>Region name</ToolTip>
          <Default>MyRegion</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
        #region -------Public Field-------
        $selected$ $end$
        #endregion
    
        #region -------Private Field-------
        $selected$ $end$
        #endregion
    
        #region -------Default Method-------
        $selected$ $end$
        #endregion

        #region -------Public Method-------
        $selected$ $end$
        #endregion
    
        #region -------Private Method-------
        $selected$ $end$
        #endregion
    
        #region -------Property-------
        $selected$ $end$
        #endregion
    ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

2014๋…„ 9์›” 24์ผ ์ˆ˜์š”์ผ

Google Play Game Service for Unity In Android_Step2. GPGS Plugin ํ™œ์šฉ์„ ์œ„ํ•œ Manager Class ์ƒ์„ฑ & ์‚ฌ์šฉ in Unity


 Explain.
์•ž์„œ GPGSํ™œ์šฉ์„์œ„ํ•œ ์…‹ํŒ…๊นŒ์ง€ ์™„๋ฃŒํ•œ๊ฒฝ์šฐ
Unity Project์—์„œ GPGS์˜ ๊ธฐ๋ณธ์ ์€ ๊ธฐ๋Šฅ(์—…์  , ๋ฆฌ๋”๋ณด๋“œ)๋ฅผ ํ™œ์šฉํ•˜๊ธฐ์œ„ํ•œ Class ์ƒ์„ฑ.
์•„๋ž˜ ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ค‘ ํ•˜๋‚˜์ด๋ฏ€๋กœ ํ”„๋กœ์ ํŠธ ์ƒํ™ฉ์— ๋งž๊ฒŒ๋” ๊ตฌํ˜„ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.


1. Google Game service์˜ ๋ฆฌ๋”๋ณด๋“œ,์—…์ ์˜ ๊ฒฝ์šฐ Id๊ฐ’์„ ๊ธฐ์ค€์œผ๋กœ
์‹คํ–‰์ด ์ด๋ค„์ง€๋ฏ€๋กœ Developer Console์˜ ์—…์ ,๋ฆฌ๋”๋ณด๋“œ์—์„œ
Get Resources๋ฅผ ํด๋ฆญํ•˜์—ฌ ID๊ฐ’์„ ๋ณต์‚ฌ

2.์œ„ ์ฒ˜๋Ÿผ ํ…์ŠคํŠธ ํ˜•์‹์œผ๋กœ Exportํ•˜์—ฌ ๋ณต์‚ฌํ•˜์—ฌ ๋‘ก๋‹ˆ๋‹ค.

์ดํ›„ ์•„๋ž˜์ฒ˜๋Ÿผ GPGS Manager Class๋ฅผ ์ƒ์„ฑํ•œ ๋’ค Scene์— ๋ฐฐ์น˜ํ›„
์ด๋ฒคํŠธ ๊ด€๋ จ ๋™์ž‘์‹œ(๊ฒŒ์ž„์ข…๋ฃŒ)
์—…์ ,๋ฆฌ๋”๋ณด๋“œ๊ด€๋ จ ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋™์ž‘์„ ํ™•์ธํ•ด ๋ณด์‹ค์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค.
๋ฆฌ๋”๋ณด๋“œ , ์—…์  ํ™•์ธ ๊ด€๋ จ UIํ˜ธ์ถœ์€
ShowLeaderBoard, ShowArchievement
๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ํ™•์ธ๊ฐ€๋Šฅ.
์ด์ƒ์œผ๋กœ GPGS์˜ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋Šฅ๋“ค ํ™œ์šฉ๋ฐฉ๋ฒ• ํฌ์ŠคํŒ… ๋งˆ์น˜๊ฒ ์Šต๋‹ˆ๋‹ค.


GPGSManager.cs
using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;

public class GPGSManager : MonoBehaviour {

    private static GPGSManager sInstance;

    public static GPGSManager GetInstance
    {
        get
        {
            if(sInstance == null) sInstance = this;

            return sInstance;
        }
    }

    void Start()
    {
        init();
    }

    void init()
    {
        PlayGamesPlatform.DebugLogEnabled = true;

        PlayGamesPlatform.Activate();

        Social.localUser.Authenticate((bool success) =>
        {
            if (success) Debug.Log("Sign in Success");
            else Debug.Log("Sign in Fail");
        });
    }

    public void PostScore(float time)
    {
        Social.ReportScore((long)(time * 1000), IDs.LB, (bool success) => {
            if (success) Debug.Log("Post Success");
            else Debug.Log("Post Fail");
        });
    }

    public void ProgessiveAchievement(AchievementType type, int value)
    {
        if (type == AchievementType.PlayCount)
        {
            //TODO : ์—…์  ์ƒํ™ฉ ๋‹ฌ์„ฑ์‹œ postAchievement(์—…์ ID);
        }

        if(type == AchievementType.PlayTime)
        {
            //TODO : ์—…์  ์ƒํ™ฉ ๋‹ฌ์„ฑ์‹œ postAchievement(์—…์ ID);
        }
    }

    public void ShowLeaderboard()
    {
        Social.ShowLeaderboardUI();
    }

    public void ShowAchievement()
    {
        Social.ShowAchievementsUI();
    }


    private void postAchievement(string key)
    {
        if (PlayerPrefs.GetInt(key) == (int)AchievementState.UNLOCK) return;
        Social.ReportProgress(key, 100, (bool success) => {
            if (success)
            {
                PlayerPrefs.SetInt(key, (int)AchievementState.UNLOCK);
            }
        });
    }
}

// ์—…์  , ๋ฆฌ๋”๋ณด๋“œ ID Class
public class IDs
{
    public const string LB = ""; // ๋ฆฌ๋”๋ณด๋“œ ID
    //TODO : ์—…์  ID ์ถ”๊ฐ€.
}

public enum AchievementType
{
    PlayCount,
    PlayTime
}

public enum AchievementState
{
    LOCK,
    UNLOCK
}

2014๋…„ 9์›” 23์ผ ํ™”์š”์ผ

Google Play Game Service for Unity In Android_Step1. GPGS Plugin ์„ค์น˜ํ›„ ๊ธฐ๋ณธ์ ์ธ ์…‹ํŒ…


Notice.
 - ์ด์ „์˜ ํฌ์ŠคํŒ…์—์„œ์˜ ์ค€๋น„์‚ฌํ•ญ์ด ๋ชจ๋‘ ์ค€๋น„๋œ ์ƒํƒœ์—์„œ ์ง„ํ–‰. (์ค€๋น„์‚ฌํ•ญ)
 - Developer console์‚ฌ์šฉ๋ฒ•๋“ฑ์˜ ๊ธฐํƒ€ ๋ฐฉ๋ฒ•์€ ์ž์„ธํ•˜๊ฒŒ ์ •๋ฆฌX


1. GPGS์™€ ์—ฐ๋™ํ•  application ๋“ฑ๋ก.
2.Game Service ๋˜ํ•œ ๋“ฑ๋ก.
3.Game Service ๋“ฑ๋ก์‹œ ์ถœ๋ ฅ๋˜๋Š” Application ID๊ฐ’ ๋ณต์‚ฌ.
4.Unity ํ”„๋กœ์ ํŠธ์— Google Play Service Plugin Importํ›„
๋ฉ”๋‰ด๋ฐ”์˜ Google Play Services -> Android Setup ์‹คํ–‰
์œ„์—์„œ ๋ณต์‚ฌํ•ด๋‘” ID๊ฐ’ ์ž…๋ ฅ -> Setup ๋ฒ„ํŠผ ํด๋ฆญ

5. ์ดํ›„ ๋‹ค์‹œ Developer Conlose๋กœ ๋Œ์•„์™€์„œ
Game Service ๋ฉ”๋‰ด์˜ ์—…์  ์ถ”๊ฐ€
๊ธฐ๋ณธ์ ์œผ๋กœ ์ตœ์†Œ 5๊ฐœ ์ด์ƒ์œผ๋กœ ๋“ฑ๋ก
e.g) ์ ์ˆ˜ xxx ์ด์ƒ ๋‹ฌ์„ฑ
ํ”Œ๋ ˆ์ด ํšŸ์ˆ˜ x ํšŒ ์ด์ƒ ๋‹ฌ์„ฑ ๋“ฑ.

6. ๊ฒŒ์ž„์—์„œ ์‚ฌ์šฉํ•  ๋ฆฌ๋”๋ณด๋“œ ๋˜ํ•œ ๋“ฑ๋ก.
์ตœ์†Œ 1๊ฐœ ์ด์ƒ.

์—ฌ๊ธฐ๊นŒ์ง€ ์ง„ํ–‰ํ–ˆ์„๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์œผ๋กœ GPGS Plugin์„ ํ™œ์šฉํ•˜์—ฌ
์—…์ ,๋ฆฌ๋”๋ณด๋“œ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ• ์ˆ˜ ์žˆ๊ฒŒ๋” ์…‹ํŒ…์ด ์™„๋ฃŒ๋œ ์ƒํƒœ์ด๋‹ค.
Very Easy..
์ดํ›„ ๋ฆฌ๋”๋ณด๋“œ,์—…์  ํ™œ์šฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

2014๋…„ 9์›” 3์ผ ์ˆ˜์š”์ผ

Google Play Game Service for Unity In Android_Step0. Index & ์ค€๋น„ ์‚ฌํ•ญ.



Summary.
 - Anroid & IOS App ์ž‘์—…์ง„ํ–‰์‹œ ๊ฐ์ข… ๊ฒŒ์ž„ ๊ด€๋ จ ๊ธฐ๋Šฅ๋“ค์„ ์ œ๊ณตํ•ด์ฃผ๋Š” ํ”Œ๋žซํผ์ค‘ 
๊ฐ€์žฅ ๋„๋ฆฌ ์•Œ๋ ค์ง„ Google play game service๋ฅผ Unity์—์„œ ํ™œ์šฉํ•˜๋Š” ๊ธฐ๋ณธ๋ฐฉ๋ฒ• ํฌ์ŠคํŒ….
 - GPGS์˜๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์€ ๋ฆฌ๋”๋ณด๋“œ , ์—…์ ๋“ฑ์˜ ๊ธฐ๋Šฅ ์™ธ์—๋„ Multiplay, cloud game save ๋“ฑ์˜ ๊ธฐ๋Šฅ๊นŒ์ง€ ์ œ๊ณตํ•ด์ฃผ๋ฏ€๋กœ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฉด์œผ๋กœ ์œ ์šฉํ•œ ํ”Œ๋žซํผ.

Requirements.
 - Unity 4.3 ์ด์ƒ(only Pro)
 - Android SDK
 - Google Play Services library 4.2.42 ์ด์ƒ (SDK Manager์—์„œ ์„ค์น˜ ๊ฐ€๋Šฅ)
 - Google Developer ๊ณ„์ •(ํ…Œ์ŠคํŠธ์šฉ์œผ๋กœ ์ง„ํ–‰ํ•  App ๋“ฑ๋ก)
 - GPGS Plugin ์ตœ์‹ ๋ฒ„์ „ - ๋‹ค์šด๋กœ๋“œ 

Index
 -step 0 : ์ค€๋น„ ์‚ฌํ•ญ
 -step 1 : GPGS Plugin ์„ค์น˜ํ›„ ๊ธฐ๋ณธ์ ์ธ ์š”๊ตฌ์‚ฌํ•ญ ์…‹ํŒ…
 -step 2 : GPGS Plugin ํ™œ์šฉ์„ ์œ„ํ•œ Manager Class ์ƒ์„ฑ ํ›„ ์‚ฌ์šฉ



์ด๋ฒˆ ํฌ์ŠคํŒ…์€ ์—ฌ๊ธฐ๊นŒ์ง€ ์•„์ฃผ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋Šฅ๋“ค๋ฉด ์ •๋ฆฌํ•  ์ƒ๊ฐ ์ถ”ํ›„ ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด , ํด๋ผ์šฐ๋“œ ๊ฒŒ์ž„ ์„ธ์ด๋ธŒ ๋“ฑ์˜ ๊ธฐ๋Šฅ๋„ ์ •๋ฆฌ ํ•  ์˜ˆ์ •.