2017. 10. 30. 15:23

안녕하세요. 게임 개발자 놀이터입니다.


이번 포스팅은 구글 플레이 게임 서비스(Google Play Game Services)(이하 GPG)를 유니티를 이용해 연동하는 방법을 적어보려고합니다.


감사합니다.




구글 플레이 서비스 ( Google Play Services ) Unity 연동


구글 플레이 서비스 for Unity 는 아래와 같은 기능을 제공합니다.

  • 플러그인이 Google Play Games API 중 지원하는 기능
  • 로그인
  • 업적 잠금 해제, 발견, 증가
  • 리더보드에 점수 등록
  • 클라우드 세이브 읽기/쓰기
  • 내장 업적/리더보드 UI
  • 이벤트 및 퀘스트
  • 턴제 멀티플레이
  • 실시간 멀티플레이


1. SDK 다운로드

SDK 다운로드 : https://github.com/playgameservices/play-games-plugin-for-unity


Current-build 안에 있는 Unity Packages 를 프로젝트에 추가 합니다.




다음과 같이 프로젝트에 추가 되었다면 성공입니다!



 

2. 어플리케이션 등록 & 안드로이드 셋업


구글 플레이 서비스를 이용하려면 구글 개발자 등록이 되어있어야합니다.

그럼 구글 개발자 등록이 되어있다고 가정하에 아래 개발자 사이트를 들어갑니다.


https://play.google.com/apps/publish/


오른쪽 애플리케이션 만들기를 선택해, 애플리케이션을 만들어줍니다

(유니티에서 기본으로 빌드한 APK를 넣어주면 됩니다. )



설정을 끝낸후, 게임 서비스 탭으로 이동하여, 마찬가지로 새 게임 추가를 눌러서 추가해줍니다.



추가가 완료되었다면, 클릭해서 들어가 봅시다.




연결된 앱을 클릭해서 들어가줍니다!




패키지 이름을 클릭해 만든 게임과 연동시키고, 턴방식 멀티플레이나 실시간 멀티 플레이라면 알맞게 사용을 체크해줍니다!



그리고 돌아와 오른쪽 메뉴에서 업적이나 리더보드등 여러가지 추가하고 싶은것들을 알맞게 추가해줍니다~




그후 밑에 보이는 리소스 받기 버튼을 눌러서 나오는 XML 내용을 복사해둡시다!




자, 이제 다시 유니티로 돌아갑시다.


Window - Google Play Games - Setup - Android setup... 을 눌러줍시다.




그럼 아래와 같은 창이 뜰겁니다. 먼저 가운데 Resources Definition 에 아까 복사한 XML리소스를 붙어넣어 줍니다.

그리고 Constants class name은 이걸로 생성될 클래스의 위치를 잡아줍니다. 저같은 경우 GPGTest.Test 라고 해줬었습니다.


그후 중요한건 맨밑에 ClinetID인데, 이건 다시 구글 개발자 콘솔로 돌아갑니다.




게임 서비스 - 연결된 앱  으로 들어가 연결한 앱을 누르면 맨밑에 정보가 나옵니다.




이중 OAuth2 클라이언트 ID를 복사해서 위 Client ID에 붙어 넣어주고 Setup을 누릅니다.


그럼 확인창 2개가 뜰텐데, 그 중



와 같이 뜬다면 완벽합니다!



3. 구글 로그인 및 업적, 리더보드 올리기




초기화

구글 플레이게임 서비스를 초기화합니다.

//Activate the Google Play gaems platform

PlayGamesPlatform.Activate();


로그인

구글 서비스에 로그인합니다.

Social.localUser.Authenticate((bool success) => {

//handle success or failure

});


업적 달성

업적은 0~100까지 달성도로 나타냅니다.

// unlock achievement (achievement ID "Cfjewijawiu_QA")

Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => {

//handle success or failure

});


리더보드에 점수 게시

리더보드에 점수를 게시합니다.

//post score 12345 to leaderboard ID "Cfji293fjsie_QA")

social.ReportScore(12345, "Cfji293fjsie_QA", (bool success) =>{

//handle success or failure

});


업적 UI 보여주기

모든 업적이 보이는 UI창을 띄웁니다.

//show achievements UI

Social.ShowAchievementsUI();


리더보드 UI 보여주기

리더보드 UI창을 띄웁니다.

        // show leaderboard UI

Social.ShowLeaderboardUI();


게임 상태를 클라우드에 저장하기

클라우드의 게임을 저장합니다.

         public class MyClass : OnStateLoadedListener {

void SaveState() {

// serialize your game state to a byte array:

byte[] mySaveState = ...;

int slot = 0; // slot number to use

((PlayGamesPlatform) Social.Active).UpdateState(slot,

mySaveState, this);

}

public void OnStateSaved(bool success, int slot) {

// handle success or failure

}

}


게임 상태를 클라우드로부터 불러오기

클라우드에서 게임을 불러옵니다.

        public class MyClass : OnStateLoadedListener {

void LoadState() {

int slot = 0; // slot number to use

((PlayGamesPlatform) Social.Active).LoadState(slot, this);

}

public void OnStateLoaded(bool success, int slot, byte[] data) {

if(success) {

//do something with data[]

} else {

//handle failure

}

}

}


클라우드 충돌 해결

2개 이상의 기기에서 클라우드를 나눠쓴다면 충돌이 날 수 있습니다. 

public class MyClass : OnStateLoadedListener {

public byte[] OnStateConflict(int slot, byte[] local, byte[] server){

//resolve conflict and return a byte[] representing the

//resolved state.

}

}



4. 실시간 & 턴기반 멀티플레이 구현하기

실시간 멀티 플레이 – 빠른 게임 만들기

특정수의 자동 상대와 빠른 매칭을 시도합니다.

const int MinOpponents = 1 MaxOpponents = 3;

const int GameVariant = 0;

PlayGamesPlatform.Instance.RealTime.CreateQuickGame (MinOpponents, MaxOpponents,

GameVariant, listener);


실시간 멀티 플레이 – 초대 화면

원하는 친구를 선택할수있는 초대화면을 표시합니다.

const int MinOpponents = 1 MaxOpponents = 3;

const int GameVariant = 0;

PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen (MinOpponents, MaxOpponents,

GameVariant, listener);


실시간 멀티 플레이 – 초대장 표시하기

사용자가 받은 초대를 표시합니다.

PlayGamesPlatform.Instance.RealTime.AcceptFromInbox (listener);


실시간 멀티 플레이 – 초대 엑세스

초대 수락후 초대장에 엑세스합니다

PlayGamesPlatform.Instance.RealTime.GetInvitation ();


실시간 멀티 플레이 – 초대 수락

초대를 수락합니다.

Invitation invitation = ....;  // (obtained via delegate)

    PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitationId, invitation.InvitationId);


실시간 멀티 플레이 – 모든 초대장 표시하기

받은 모든 초대장을 표시합니다.

PlayGamesPlatform.Instance.RealTime.GetAllInvitations(

        (invites) =>

        {

            Debug.Log("Got " + invites.Length + " invites");

            string logMessage = "";

            foreach(Invitation invite in invites)

            {

                logMessage += " " + invite.InvitationId + " (" +

                    invite.InvitationType + ") from " +

                    invite.Inviter + "\n";

                if (mFirstInvite == null) {

                    mFirstInvite = invite;

                }

            }

            Debug.Log(logMessage);

    });


실시간 멀티 플레이 – 연결 대기

연결 상황에 따라 대기실을 표시해줍니다.

private bool showingWaitingRoom = false;

    public void OnRoomSetupProgress(float progress) {

        // show the default waiting room.

        if (!showingWaitingRoom) {

            showingWaitingRoom = true;

            PlayGamesPlatform.Instance.RealTime.ShowWaitingRoomUI();

        }

    }


실시간 멀티 플레이 – 매칭 완료

매칭이 완료되었을때 불리는 함수입니다.

public void OnRoomConnected(bool success) {

        if (success) {

            // Successfully connected to room!

            // ...start playing game...

        } else {

            // Error!

            // ...show error message to user...

        }

    }



실시간 멀티 플레이 – 참가자 인덱스

멀티에 참가한 플레이어들은 index로 구분됩니다.

Participant myself = PlayGamesPlatform.Instance.RealTime.GetSelf();

    Debug.Log("My participant ID is " + myself.ParticipantId);



실시간 멀티 플레이 – 참가자 목록

다른 참가자들을 인덱스로 받아옵니다.

List<Participant> participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();



실시간 멀티 플레이 – 메세지 보내기

다른 모든 참가자들에게 메세지를 보낼수있습니다.

Reliable은 신뢰성의 여부를 따집니다.

byte [] message = ....; // 메시지를 작성하십시오. 

    bool  reliable = true ;

    PlayGamesPlatform.Instance.RealTime.SendMessageToAll (reliable, message);



실시간 멀티 플레이 – 메세지 받기

메세지가 도착했을때 불리는 함수입니다.

public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data) {

        // handle message! (e.g. update player's avatar)

    }



실시간 멀티 플레이 – 연결 이벤트 처리

유저가 게임을 나갔을때

public  void  OnLeftRoom () {

         // 오류 메시지를 표시하고 메뉴 화면으로 돌아갑니다.

        

        // (PlayGamesPlatform.Instance.RealTime.LeaveRoom ()을 여기에서 호출하지 마십시오.) 

        // 이미 방을 나왔습니다 !) 

    }


다른 유저가 방에 들어오거나 나갔을때

public  void  OnPeersConnected ( string [] participantIds ) {

         // 적절하게 반응합니다 (예 : 새 아바타를 게임에 추가).

    }

    

    public  void  OnPeersDisconnected ( string [] participantIds ) {

         // 적절하게 반응 (예 : 게임에서 아바타 제거) 

    }


실시간 멀티 플레이 – 방 나가기

방에서 나옵니다.

PlayGamesPlatform.Instance.RealTime.LeaveRoom ();




턴 멀티 플레이 – 빠른 게임

퀵 매치를 시작합니다.

PlayGamesPlatform.Instance.TurnBased.CreateQuickMatch(MinOpponents, MaxOpponents,

        Variant, OnMatchStarted);


    // Callback:

    void OnMatchStarted(bool success, TurnBasedMatch match) {

        if (success) {

            // go to the game screen and play!

        } else {

            // show error message

        }

    }


턴 멀티 플레이 – 초대 화면

초대가 가능한 화면으로 만듭니다.

PlayGamesPlatform.Instance.TurnBased.CreateWithInvitationScreen(MinOpponents, MaxOpponents,

        Variant, OnMatchStarted);


턴 멀티 플레이 – 초대보기

받은 초대를 봅니다.

PlayGamesPlatform.Instance.TurnBased.AcceptFromInbox(OnMatchStarted);


턴 멀티 플레이 – 초대 수락

받은 초대를 수락합니다.

PlayGamesPlatform.Instance.TurnBased.AcceptFromInbox(OnMatchStarted);


턴 멀티 플레이 – 모든 초대장 보기

받은 모든 초대장을 표시합니다.

PlayGamesPlatform.Instance.TurnBased.GetAllInvitations(

        (invites) =>

        {

            Debug.Log("Got " + invites.Length + " invites");

            string logMessage = "";

            foreach(Invitation invite in invites)

            {

                logMessage += " " + invite.InvitationId + " (" +

                    invite.InvitationType + ") from " +

                    invite.Inviter + "\n";

                if (mFirstInvite == null) {

                    mFirstInvite = invite;

                }

            }

            Debug.Log(logMessage);

    });


턴 멀티 플레이 – 매치 완료

매치가 완료되었다는 콜백을 받습니다.

void OnMatchStarted(bool success, TurnBasedMatch match) {

        if (success) {

            // get the match data

            byte[] myData = match.Data;

            

            // I can only make a move if the match is active and it's my turn!

            bool canPlay = (match.Status == TurnBasedMatch.MatchStatus.Active &&

                match.TurnStatus == TurnBasedMatch.MatchTurnStatus.MyTurn);

            

            // Deserialize game state from myData into scene and

            // go to gameplay screen. If canPlay == true, let user play a move; 

            // if not, they can only see the current state of the game but can't play.

        } else {

            // show error message, return to main menu

        }

    }


턴 멀티 플레이 – 내 차례 알림

내 차례를 알려주는 콜백을 받습니다.

TurnBasedMatch match = ....; // received in OnMatchStarted

    

    // your representation of the new state of the game after the player

    // has taken their turn:

    byte[] myData = .....;

    

    // this indicates whose turn is next (a participant ID)

    string whoIsNext = .....;

    

    PlayGamesPlatform.Instance.TurnBased.TakeTurn(match.MatchId, myData, whoIsNext, (bool success) => {

        if (success) {

            // turn successfully submitted!

        } else {

            // show error

        }

    });


턴 멀티 플레이 – 턴 넘기기

자동으로 다음 플레이어에게 넘기거나, 특정 플레이어에게 턴을 넘깁니다.

string DecideWhoIsNext(TurnBasedMatch match) {

        if (match.AvailableAutomatchSlots > 0) {

            // hand over to an automatch player

            return null;

        } else {

            // pick a player among match.Participants,

            // according to the game's logic

        }

    }


턴 멀티 플레이 – 경기 끝

경기가 끝낫을떄 받는 함수입니다.

TurnBasedMatch match = .....;  // our current match

    byte[] finalData = .....; // match data representing the final state of the match

    

    // define the match's outcome

    MatchOutcome outcome = new MatchOutcome();

    foreach (Participant p in match.Participants) {

        // decide if participant p has won, lost or tied, and

        // their ranking (1st, 2nd, 3rd, ...):

        MatchOutcome.ParticipantResult result = .....;

        int placement = ......;

        

        outcome.SetParticipantResult(p.ParticipantId, result, placement);

    }

   

    // finish the match

    PlayGamesPlatform.Instance.TurnBased.Finish(match.MatchId, finalData, outcome, (bool success) => {

        if (success) {

            // sent successfully

        } else {

            // an error occurred

        }

    });


턴 멀티 플레이 – 게임 나가기

필요하다면 아래 함수로 게임을 나갈수 있습니다.

PlayGamesPlatform.Instance.TurnBased.Leave(match.MatchId, (bool success) => {

        if (success) {

            // successfully left

        } else {

            // error leaving match

    });




감사합니다!!

Posted by 시리시안
2017. 10. 25. 11:04

안녕하세요. 게임 개발자 놀이터입니다.


이번 포스팅은 릴리즈모드로 APK를 빌드하는 방법을 적어보려고합니다.


감사합니다.




릴리즈로 APK를 뽑기 위해서 안드로이드 플레이어 세팅으로 들어갑니다


Publishing Settings에서 Keystore 에 Create a new keystore를 체크 해준후, 기본 경로에 save 한 다음에 비밀번호를 입력해줍니다




Contirm keystore password 까지 입력이 끝나면, 밑에 Key 부분에 Alias를 눌러보시면 Create a new key 가 생겨서 누를수 있게 됩니다.




Create a new key를 누르면, 아래와 같은 창이 뜹니다.

내용은 입력이 안되어 있거나, 일부만 입력이 되어있는데, 지금은 릴리즈모드로 APK를 뽑기위한 key니까 대충 입력해줍시다.





Key를 생성 한후, 새로 생성된 키를 선택합니다.



비밀번호를 입력해주면!! 끝입니다.





이제부터 빌드하면 릴리즈 APK로 빌드 될것입니다.


감사합니다

Posted by 시리시안
2017. 10. 19. 12:22


안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.






네이버 플러그 IOS 추가 세팅





네이버 앱으로 로그인 가능하게 하기


네이버 앱으로 로그인 기능을 사용하기 위해선

NCSDKUnityManager.mm 을 열어서  

[[NCSDKLoginManager getSharedInstance] setIsNaverAppOauthEnable:YES];

을 추가 해줍니다.


 





또한, 네이버 앱으로 나갔다 들어오며 로그인이 완료 됬다는 델리 게이트를 받기 위해 

openURL 델리게이트를 오버라이드 받습니다.

유니티에서 한번에 처리 하기 위해 Plugin/IOS 에 AppDelegate을 서브클래스로 받는 클래스를 mm파일로 구현합니다

 



마지막으로 URL Schemes 세팅을 위해 유니티 – PlayerSetting – ios 에서 Supported URL schemes에 네이버 제휴 카페 ios 서비스에 등록한 URL schemes 값을 입력합니다.

 


이제 네이버 앱으로 로그인이 될것입니다.



PostBuild를 이용하여 XCode 추가 세팅 안하기.


네이버 SDK는 추가해야하는 라이브러리(프레임워크)나 세팅해줘야 하는 값들이 많습니다. 이를 한번에 처리 하기위해 아래와 같은 코드를 클래스를 만들어 Plugin에 추가 해줍니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System.IO;
using System.Collections.Generic;
 
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
 
#if UNITY_IOS 
using UnityEditor.iOS.Xcode;
 
public static class IOSPostBuild
{
    [PostProcessBuild]
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
        #region Project.pbxproj
        {
            string pbxprojPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
            
            PBXProject proj = new PBXProject();
            
            proj.ReadFromString(File.ReadAllText(pbxprojPath));
            
            string buildTarget = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
            string destSdkDir = "Libraries/NCSDK";
            
            proj.AddFrameworkToProject(buildTarget, "ReplayKit.framework"false);
            proj.AddFrameworkToProject(buildTarget, "MobileCoreServices.framework"false);
            proj.AddFrameworkToProject(buildTarget, "SystemConfiguration.framework"false);
            proj.AddFrameworkToProject(buildTarget, "MediaPlayer.framework"false);
            proj.AddFrameworkToProject(buildTarget, "AVFoundation.framework"false);
            proj.AddFrameworkToProject(buildTarget, "CoreMedia.framework"false);
            proj.AddFrameworkToProject(buildTarget, "AssetsLibrary.framework"false);
            proj.AddFrameworkToProject(buildTarget, "Security.framework"false);
            proj.AddFrameworkToProject(buildTarget, "ImageIO.framework"false);
            proj.AddFrameworkToProject(buildTarget, "QuartzCore.framework"false);
            proj.AddFrameworkToProject(buildTarget, "WebKit.framework"false);
            proj.AddFrameworkToProject(buildTarget, "MediaToolBox.framework"false);
            
            
            proj.AddBuildProperty(buildTarget, "FRAMEWORK_SEARCH_PATHS""$(inherited)");
            proj.AddBuildProperty(buildTarget, "FRAMEWORK_SEARCH_PATHS""$(SRCROOT)/" + destSdkDir);
            proj.AddBuildProperty(buildTarget, "LIBRARY_SEARCH_PATHS""$(inherited)");
            proj.AddBuildProperty(buildTarget, "LIBRARY_SEARCH_PATHS""$(SRCROOT)/" + destSdkDir + "/NaverAuth");
            
            proj.AddBuildProperty(buildTarget, "OTHER_LDFLAGS""-ObjC");
            proj.AddBuildProperty(buildTarget, "OTHER_LDFLAGS""-all_load");
            
            File.WriteAllText(pbxprojPath, proj.WriteToString());
        }
        #endregion
 
        // Read plist
        var plistPath = Path.Combine(path, "Info.plist");
        var plist = new PlistDocument();
        plist.ReadFromFile(plistPath);
 
        // Update value
        PlistElementDict rootDict = plist.root;
        rootDict.SetString("Localization native development region""Korea");
        rootDict.SetString("Privacy - Photo Library Usage Description""게시글을 작성하기 위해 사용자의 사진에 접근합니다");
 
 
        // Write plist
        File.WriteAllText(plistPath, plist.WriteToString());
        //
 
    }
 
    private static void DirectoryCopy (string sourceDirName, string destDirName)
    {
        DirectoryInfo dir = new DirectoryInfo (sourceDirName);
        DirectoryInfo[] dirs = dir.GetDirectories ();
 
        if (!dir.Exists) {
            return;
        }
 
        if (!Directory.Exists (destDirName)) {
            Directory.CreateDirectory (destDirName);
        }
 
        FileInfo[] files = dir.GetFiles ();
 
        foreach (FileInfo file in files) {
            if(!file.Extension.ToLower().EndsWith("meta")) {
                string temppath = Path.Combine (destDirName, file.Name);
                file.CopyTo (temppath, false);
            }
        }
 
        foreach (DirectoryInfo subdir in dirs) {
            string temppath = Path.Combine (destDirName, subdir.Name);
            DirectoryCopy (subdir.FullName, temppath);
        }
    }
 
    public static void ClearDirectory (string path, bool deleteParent)
    {
        if (path != null) {
            string[] folders = Directory.GetDirectories (path);
 
            foreach (string folder in folders) {
                ClearDirectory (folder, true);
            }
 
            string[] files = Directory.GetFiles (path);
 
            foreach (string file in files) {
                File.Delete (file);
            }
 
            if (deleteParent) {
                Directory.Delete (path);
            }
        }
    }
 
    public static string PathWithPlatformDirSeparators (string path)
    {
        if (Path.DirectorySeparatorChar == '/') {
            return path.Replace ("\\", Path.DirectorySeparatorChar.ToString ());
        } else if (Path.DirectorySeparatorChar == '\\') {
            return path.Replace ("/", Path.DirectorySeparatorChar.ToString ());
        }
 
        return path;
    }
 
    public static string MacPath (string path)
    {
        return path.Replace (@"\", "/");
    }
}
#endif
#endif
cs







Posted by 시리시안
2017. 10. 18. 10:45

안녕하세요. 게임개발자 놀이터 입니다.


게임에 빠질수없는 필수 요소인 광고!


유니티 애드 포스팅입니다 ㅎㅎ



Unity 2017 Unity Ads 연동


1. 유니티에서 Window -> Services 를 누릅니다.




2. Services 에서 Ads의 OFF 된 부분을 ON으로 변경합니다.

 



3. 이젠 플랫폼을 선택할 필요 없이, 바로 우측 상단에 보이는 인터렉션 버튼을 눌러서 활성화 시킵니다.

 



4. 게임이 13세 미만의 어린이들을 대상으로 한다면 체크한 후 Continue를 누릅니다.

 



5. 설정이 완료 됬습니다. Test Mode는 말그대로 테스트 할때만 체크해주시면 됩니다.

이제 Go to Dashboard 를 눌러서 창을 열어 줍니다.

 




6. 만든 프로젝트를 클릭해 들어갑니다.

 





7. Apple App Store용 광고 Game ID와 Google Play Store 용 광고 Game ID를 기억합니다.

(7자리)

 



8. 플랫폼을 클릭해서 들어오면 이렇게 광고에 대한 사항을 수정할 수 있습니다.

스플래시 이미지로 할지, 광고로 할지, 광고가 스킵이 되는지 안되는지.. 여러가지 설정이 가능합니다.

여기서 나오는 PLACEMENT ID 또한 필요하니 기억해둡니다.

 


이제 코드로 돌아옵니다.



9. 저는 2개의 클래스로 Unity Ads를 연동 시켰습니다.

UnityAdsConfig.cs 

 


이곳엔 아까 기억한 Game ID(7자리)와 사용할 PLACEMENT ID를 적어줍니다.


UnityAdsManager.cs

 



using UnityEngine.Advertisements; 를 찾을 수 없다면, 유니티 프로젝트에서 타겟 플랫폼을 Android나 IOS로 변경해줍니다.

(저는 PC로 두고.. 왜 안나오나 한참 찾았었네요. 애꿎은 using UnityEditor.AdvertisementsSettings; 에서 열심히 삽질했습니다..)




10. 이제 간단한 버튼을 만들어서 UnityAdsManager의 OnRewardVideoClick()을 호출해줍니다.

유니티 에디터에서 아래와 같은 창이 뜬다면 성공입니다!

 








Posted by 시리시안
2017. 10. 16. 18:27


안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.



리소스 이미지 변경

네이버 카페 플러그 라이브러리에 포함된 리소스 이미지를 변경할 수 있습니다.


[Android]

Android 환경에서 네이버 카페 플러그 라이브러리에 포함된 리소스 이미지는 다음과 같이 변경할 수 있습니다.


네이버 카페 플러그 라이브러리 파일(.aar 파일)의 압축을 해제합니다.

압축을 해제한 폴더의 /res/drawable-xhdpi 폴더에 있는 이미지를 원하는 이미지로 바꿉니다.

압축을 해제한 폴더를 다시 라이브러리 파일(.aar 파일)로 압축합니다.

새로 압축한 네이버 카페 플러그 라이브러리를 적용해 프로젝트를 빌드합니다.


주의 ) 교체할 이미지는 원본 이미지와 사이즈가 같아야 합니다.


[IOS]

iOS 환경에서 네이버 카페 플러그 라이브러리에 포함된 리소스 이미지는 다음과 같이 변경할 수 있습니다.


NaverCafeSDK.bundle 패키지에 있는 이미지를 원하는 이미지로 바꿉니다.

수정한 패키지를 네이버 카페 플러그 라이브러리에 적용한 다음 프로젝트를 빌드합니다.

 






네이버 로그인

애플리케이션에서 네이버 아이디로 로그인 기능을 사용합니다

네이버 로그인은 GLinkNaverId.cs를 사용합니다.


init() 메서드


다음 초기화 정보로 네이버 로그인 기능을 초기화합니다.


네이버 아이디로 로그인 개발자 센터에 애플리케이션을 등록하고 받은 클라이언트 아이디

네이버 아이디로 로그인 개발자 센터에 애플리케이션을 등록하고 받은 클라이언트 시크릿


 


login() 메서드


네이버 아이디로 로그인합니다.

 



로그인이 완료 되면 리스너가 호출됩니다


[Android]

 



[IOS]

 




logout() 메서드


로그아웃합니다

 



isLogin() 메서드


로그인한 상태인지 확인한다.

 



getProfile() 메서드


로그인한 사용자의 기본 정보(메일 주소, 별명, 프로필 사진, 생일, 연령대)를 조회한다.

 



조회할 정보는 리스너를 등록해 설정합니다.


[Android]

 



[IOS]




감사합니다.




Posted by 시리시안
2017. 10. 16. 17:58

안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.






게임 아이디 연동


사용자의 게임 아이디와 카페 아이디를 연동해 관리할 수 있다. 연동된 게임 아이디와 카페 아이디 목록은 카페 관리 메뉴에서 확인할 수 있다.

 



테마 색상 변경

플러그의 테마 색상을 변경할 수 있습니다.

주의) CSS 색상 값에 알파값을 넣으면 안됩니다.

 






감사합니다

Posted by 시리시안
2017. 10. 16. 17:42

안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.




App Scheme 처리

게임에서 플러그의 홈 화면에 나오는 배너 이미지를 누르면 App Scheme으로 이동해 게임 기능을 실행하게 할 수 있습니다.

App Scheme으로 이동할 배너 이미지는 카페 관리 메뉴에서 등록 할 수 있습니다.


[Android]

Android 환경에서 App Scheme으로 이동하는 배너 이미지에 터치 이벤트가 일어났을 때 App Scheme을 처리하는 기능을 구현하려면 Android용 스크립트 파일인 GlinkAndroid.cs 파일에 다음과 같이 리스너를 설정합니다

 


또한 콜백 리스너도 등록해줍니다.

 




[IOS]

iOS 환경에서 App Scheme으로 이동하는 배너 이미지에 터치 이벤트가 일어났을 때 App Scheme을 처리하는 기능을 구현하려면 iOS용 스크립트 파일인 GLinkiOS.cs 파일에 다음과 같이 리스너를 설정한다.



감사합니다.


Posted by 시리시안
2017. 10. 16. 17:32

안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.




동영상 녹화


동영상 녹화 버튼을 누르면 게임중에 게임 화면을 녹화 할 수 있습니다.


녹화 시작과 종료

 


녹화 콜백 리스너

동영상 녹화시 발생하는 이벤트 처리는 콜백 리스너를 등록해 구현합니다.


녹화 기능은 GLinkRecord.cs 에 구현 되어 있습니다.


[Android]

 



[IOS]

 



녹화 완료 콜백 리스너

녹화가 완료 되었을때 처리할 작업은 콜백 리스너를 등록해 구현합니다.


[Android]

기본적으로 GLinkAndroid.cs 에 설정 되어 있지만, 그래도 코드를 본다면

에 있는 setOnRecordFinishListener 를 이용해 콜백 리스너를 등록합니다.


그후 등록한 리스너에 녹화 완료 기능을 구현 합니다.

 



[IOS]

IOS도 기본적으로 완성되어 있지만, 그래도 코드를 보자면

NCSDK / Plugins / IOS / NCSDKUnityManager.mm 을 열어서 보면

 





 


되어있는것을 화인 할 수 있다.


감사합니다



Posted by 시리시안
2017. 10. 16. 17:08

안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.




위젯



위젯 관련 기본 설정 함수들 입니다.


 

위젯 ) 화면 캡쳐

위젯의 화면 캡처 버튼을 누르면 게임 화면을 캡처할 수 있다.

화면 캡쳐 기능은 버튼 클릭 리스너를 등록해서 구현합니다.


화면 캡쳐 사용 여부 

 





[Android]

기본적으로 GLinkAndroid.cs 에 설정 되어 있지만, 그래도 코드를 본다면


먼저 리스너를 등록합니다.

 



그후 등록한 리스너에 스크린 캡쳐 기능을 구현 합니다.

 



[IOS]

IOS는 화면 캡쳐 리스너를 따로 구현해서 처리합니다.





감사합니다

 


Posted by 시리시안
2017. 10. 16. 16:46

안녕하세요. 게임개발자 놀이터 입니다.


네이버 플러그 분석 포스팅입니다.


분석 내용은 Plug Unity 을 보고 만들었습니다.


감사합니다.




플러그 투명도


플러그 좌 상단의 투명도 조절 바를 조절하면 게임과 카페를 동시에 사용 할 수 있습니다.

알파값 100% = 플러그로 터치 이벤트 전달

알파값 99% 이하 = 게임으로 터치 이벤트 전달


접기 버튼과 닫기 버튼

 



플러그 화면 우 상단에 버튼 2개가 있는데, 그중 왼쪽 1번 버튼이 접기 버튼입니다.

접기 버튼을 누르면 플러그 창이 내려가며, 위젯이 나타합니다. 다시 플러그를 실행하면, 마지막으로 보고 있던 화면이 나타 납니다.


오른쪽 2번 버튼은 닫기 버튼입니다.

닫기 버튼을 누르면 플러그가 종료됩니다. 접기와 달리 위젯이 나타나지 않으며, 다시 플러그를 실행하면 플러그의 첫 화면이 나타납니다.



Posted by 시리시안