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. 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 시리시안
2016. 3. 3. 14:25


안녕하세요.


xml데이터를 만들어야하는데, 손으로 일일히 메모장에 전체를 적을수는 없으니..


제일 간단한 엑셀로 만드는법을 적어보겠습니다.


제일 먼저 엑셀로 만들기 위하면 스키마를 작성해주어야 하는데요


스키마 작성은 노트패드(메모장 또는 기타등등)을 열어서 다음과 같이 적습니다.


한국어, 영어, 중국어 3개로 로컬라이징을 하기위한 언어 스키마입니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<root>
             <texts>                           
                           <index/>
                           <menu/>
                           <kor/>
                           <eng/>
                           <chi/>
             </texts>
             <texts>                           
                           <index/>
                           <menu/>
                           <kor/>
                           <eng/>
                           <chi/>
             </texts>
</root>
cs

꼭 texts는 마음대로 변경하셔도 되지만, 스키마에 한글을 적으시면 안됩니다.

그리고 반복된다는것을 알리기위해 꼭 2번 적어야합니다.


자 이렇게 작성했다면, 이를 저장합니다.


단, 저장시 확장자명을 .xml로 저장해주셔야합니다.


자 이제 엑셀을 켜봅시다.


먼저 엑셀의 개발도구를 열어야하는데요.


개발도구를 왼쪽 리본의서 메뉴에서 설정가능합니다..


모르면 구글링하면 친절한 블로그들이 있을꺼애요



개발도구에서 원본을 클릭합시다.



그러면 우측에  XML원본이라는 창이 뜰텐데요.

 그밑에 XML맵을 누르면 다음과 같은 창이 뜹니다.



그러면 밑에 추가를 누르신후 아까 저장한 xml파일을 눌러 줍시다.

그럼 다음과 같은 경고창이 하나 뜰텐데. 바로 확인 눌러줍니다.



그러면 아까 만든 맵이 이곳에 이렇게 뜰꺼애요! 아까 적은 글자 대로 뜰껍니다. 그럼 확인을 누릅시다.



그럼 우측에 다음과 같이 생성된걸 볼수있습니다.


그럼 위에 데이터를 넣기위해 간단하게 엑셀에 데이터를 적어봅시다.


첫줄은 아무상관없으니, 적기 편하게 구분을 지어주시고, 그다음부터 데이터를 적어나가면 됩니다.



자 저는 이렇게 적었어요. 정말 간단하죠?


그다음 첫열 즉 A열을 전부 드래그 한후 우측의 인덱스를 더블클릭합니다.


그러면 값들이 알아서 매핑됩니다.


이처럼 말이죠.


그럼 남은 값들도 전부 매핑 해봅시다.



자 이제 저장만 하면 됩니다.


주의할점은 엑셀로 저장하는것이 아닌 xml로 저장하는겁니다.


역시 저장할때 경고창이 뜰텐데 무시하고 저장합시다.


(나중에 수정을 하려면 엑셀파일로도 저장해두는게 좋아요, 어차피 스키마는 유지됩니다.)


그리고 저장한 파일을 열어보면

짜잔, 다음과같이 값이 알맞게 매핑되어 저장된것을 볼수있습니다.

Posted by 시리시안