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

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-23 22:23
좋은 확장 프로그램인 것 같아서 본문 채로..



Visual Studio 2012, 2013 으로 Unity3d 스크립팅 하시는 분들에게 유용할만한 글


안녕하세요~ 얼마전에 퇴직하고, 내일부터 새회사에 출근하는 만2년 된 게임 플머 뎡형입니다.
전 회사에서도 1년 6개월정도 유니티를 썼었고, 새 회사에서도 유니티를 쓰게 될 예정입니다.
퇴직과 이직 사이... 여행이나 방콕은 취향에 맞지않아 전혀 안해본 분야에 심취해봤습니다.

그것은 바로! 'Visual Studio Extension'!!!

이것을 시작한 계기는, 개인적으로 Visual Studio를 많이 사용하고 특히 Unity3d C# Script하는게
대부분입니다. 이때 많이 하는 것중의 하나가 코딩하다가 모르거나 아리까리 한 것을 google 검색 한뒤
구글 검색에 나온 docs.unity3d.com/ScriptReference/[검색어] 링크로 이동 하거나 누군가의
블로깅 내용으로 이동하는 것입니다.

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

주로 했던 행동을 요약하면,

코딩 한다 => 검색할게 생겼다 => 웹브라우져를 켠다 => 구글로 이동한다 => 검색어를 친다 => 결과를 확인한다

이렇게 6단계의 과정을 거칩니다.

그래서 생각한것이 예전에 Visual studio에 Macro라는게 있었던것 같아 찾아보니 Visual studio 2010 까지만 있고
이후 버전에는 없어졌다고 하더라구요. 그래서 그와 비슷한 기능을 하는것이 확장(Extension)이라는 시스템이 있더라구요.
확장에 대해서 좀 검색하니 Visual Studio 2012 or 2013 SDK를 설치하고 Visual Studio Package 형식의 프로젝트를 통해
만들 수 있다는걸 알아냈습니다. 바로 받아서 새프로젝트 만드니 이건 왠걸...

파일이 한두개도 아니고 여러개에 C#코드만 있는게 아니라 XML파일이 있는데 그게 중요한 역할을 하더라는...
그나마 C#은 콘솔, Winform, WPF는 익숙해서 분석하거나 만드는데 무리가 없는데 XML의 문법에 대해서는
MSDN에 의존할 수 밖에 없어 쉽지가 않았습니다. 일단 이 분야에 예제가 많지 않고, 있는 것도 꽤나 복잡한
프로젝트 예제 밖에 없었습니다. 예제 분석하다가 이걸로 의욕잃고 시간 잃을것 같아 그냥 새프로젝트에 나온
템플릿 파일 내용을 시작으로 작업에 들어갔습니다.

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

이쯤에서부터는 작업의 상세 과정보단 목적과 기능에 대해서 말하는게 좋을듯합니다.

위 과정을 아래와 같이 단축시키고 싶었습니다.

코딩 한다 => 검색할게 생겼다 => 검색어를 검색하는 웹페이지로 연결한다 => 결과를 확인한다

이것이죠. 그래서 여차저차해서 이 기능을 구현했습니다! Visual Studio의 텍스트 에디터에서 검색을
원하는 단어를 선택(영역 드래그나 그냥 단어 근처에 앵커(대문자 I 모양)를 두면 됨)하고 원하는 기능의 
메뉴 단축키를 누르면 끝!

--- 메뉴 기능 ---
유니티 설치 폴더 문서에서 검색 - Unity3d Local Document (Ctrl+F1, Ctrl+F1)
 유니티 문서 웹사이트에서 검색  - Unity3d Web Document (Ctrl+F2) 
 접두어와 함께 구글에서 검색    - Google Search (Shift+F1) 
 접두어와 함께 네이버에서 검색  - Naver Search (Shift+F2)

--- Visual Studio Gallary ---

Visual Studio 2012 지원
Visual Studio 2013 지원

여기다가 올려놓고 사용법도 적어놨습니다. 그리고 Github에 프로젝트 소스를 올려놨고 License는 MIT로 했으니
마음대로 하셔도 됩니다. 저도 이런거 많이 올려본건 아니지만 뭐 괜찮겠죠ㅎ
영어로 적긴 했는데 어려운 내용은 없을 듯(저도 영어 그렇게 잘하는건 아님...ㅎㅎ)

많이들 활용해주세용! 피드백은 뭐... 업데이트는 음... 해야죠ㅎ 제가 이 분야에는 초보라 빠른 처리까지는 못해도
저도 쓸 예정인 물건이라 치명적인 버그나 자주 느껴지는 불편사항등은 업데이트 할겁니다. 아마도...ㅎ




반응형
Posted by blueasa
, |

실행할 때, 문제는 없는 데 유니티(에디터)를 종료할 때 아래와 같은 에러메시지를 확인..


CompareBaseObjectsInternal can only be called from the main thread.

Constructors and field initializers will be executed from the loading thread when loading a scene.

Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.


어디가 문젠지 헤메다가 알게 된 건

MonoBehaviour를 상속받아 쓰는데도 생성자/소멸자를 사용한 부분이 있었다.
이 번 문제는 종료할 때 나면서 소멸자쪽의 문제였던 것 같은데..
아무튼 생성자/소멸자를 Awake/OnDestroy 등으로 모두 교체했다.

그리고 아래는 같은 에러 관련 참조할만한 포스팅..



반응형
Posted by blueasa
, |


Link : http://blog.naver.com/rapkuma/220150432332

반응형
Posted by blueasa
, |


출처 : http://www.lionheart.pe.kr/board_uFoa63/913



현재 UDID라 불리는 Unique Device ID는 기기마다 가지고 있는 고유의  아이디입니다.

 

주로 폰에서 아이디를 만들떄 자동으로 만들어 줄려고 사용하는 거지만 안드로이드는 아무 문제가 없습니다

 

 

문제는 애플인데 저걸 사용하면 리젝사유가 된다고 하네요

 

iPhoneSettings.uniqueIdentifier 이 함수를 사용해 UDID라는 것을 생성을 할수가 있는데 이제는 쓰면 안되겠죠

 

(특히 일본쪽은 UDID나 Mac어드레스등 유저 해킹에 대한 정보를 가져다 쓰는 어플은 무조건 안된다고 합니다)

 

 

 

그래서 나온게 UUID라 불리는 Universally Unique ID 입니다

 

유니티 최신버젼을 쓰시면 SystemInfo.deviceUniqueIdentifier 값이 자동으로 생성된다고 합니다

 

앱을 깔고나서 지우면 값이 바뀌기는 하지만 여전히 고유값이라고 하네요


But,


UUID 분석을 통해 앱을 다시 지웠다가 설치 해도 바뀌지 않는 방법이 있습니다.

IOS 기기 국가정보 및 기기 UIDI 대체 UUID 키체인에 저장하여 사용하기(앱 다시 깔아도 그대로 기기값유지)


// 기기 국가정보가져오기

NSLocale *locale =[NSLocale currentLocale];

NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];

//유니티 메세지 보내기

UnitySendMessage("GetDeviceID""SetContry", [countryCode UTF8String]);

    

// 기기 아이디 생성해서 키체인에 저장

NSString *result_uuid = [[LUKeychainAccess standardKeychainAccess] stringForKey:@"uuid"];

   

 if(result_uuid == nil)

 {

       NSString *uuid;

        NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"6.0" options: NSNumericSearch];

        if (order == NSOrderedSame || order == NSOrderedDescending) {

            uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

        }

       else

       {

            uuid = [[NSUUID UUID] UUIDString];

        }

        [[LUKeychainAccess standardKeychainAccess] setString:uuid forKey:@"uuid"];

        result_uuid = [[LUKeychainAccess standardKeychainAccess] stringForKey:@"uuid"];

   }


 //기기아이디 유니티로 전송

 UnitySendMessage("GetDeviceID""SetDeviceID", [result_uuid UTF8String]);


* 기기 아이디 생성해서 키체인에 저장해서 쓰는 것은 첨부파일이 필요하다.



반응형
Posted by blueasa
, |

바하무트

유니티 인거죠?

UnityEngine 에 LightmapData 라고 있고,
LightmapSettings 라고 있습니다.

라이트맵을 구으면 텍스쳐가 나올거고 

씬 생성시에 
·미리보기 | 소스복사·
  1. LightmapData[] lightMapArray = new LightmapData[LIGHTMAP_COUNT];  
  2.   
  3. for (int i = 0; i < LIGHTMAP_COUNT; i++)  
  4. {  
  5.     LightmapData data = new LightmapData();  
  6.     data.lightmapFar = Resources.Load("텍스쳐 경로"as Texture2D;  
  7.   
  8.     lightMapArray[i] = data;  
  9. }  
  10.   
  11. LightmapSettings.lightmaps = lightMapArray;  
이런식으로 적용했었는데...

일단 제가 말한 키워드들로 검색해보세요.

저도 이게 테스트때 해본거라...-_-;; 장담을 못드리겠네요 ㅋ



출처 : http://www.gamecodi.com/board/zboard-id-GAMECODI_Talkdev-no-2903-z-1.htm

반응형

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

Load Textrue with WWW  (0) 2014.12.02
OnGUI() 상에서 마우스 더블 클릭 구현  (0) 2014.11.20
좀 더 복잡한 데이터 저장하기  (6) 2014.09.25
Unity Serializer  (0) 2014.09.25
Simple C# Unity Serializer  (0) 2014.09.25
Posted by blueasa
, |

    // 원하는 Type을 Object로 넘겨서 시리얼라이즈 한 후, string으로 받아옴.

    // 이 값을 PlayerPrefs에 저장.

    private string ObjectToString(System.Object _cObject)

    {

        if (_cObject == null)

            return null;

        var binaryFormatter = new BinaryFormatter();

        var memoryStream = new MemoryStream();

        binaryFormatter.Serialize(memoryStream, _cObject);

        

        return Convert.ToBase64String(memoryStream.GetBuffer());

    }


    // PlayerPrefs에 저장된 값을 string에 받아와서 Object로 변환 후, 맞는 Type으로 형변환. Collection도 가능.

    // 예) List<MyClass> listValues = StringToObject(strValue) as List<MyClass>;

    private System.Object StringToObject(string _strValue)

    {

        if (true == string.IsNullOrEmpty(_strValue))

            return null;


        var binaryFormatter = new BinaryFormatter();

        var memoryStream = new MemoryStream(Convert.FromBase64String(_strValue));

        

        System.Object obj = binaryFormatter.Deserialize(memoryStream);


        return obj;

    }






출처 : http://kookiandkiki.blogspot.kr/2014/01/unity3d_432.html



이전 포스팅에서 간단한 데이터를 저장하는 법을 봤는데요,

만약에 저장할 데이터가 간단하지 않고 좀 복잡하다...라고 한다면 아래처럼 테이블을 만들어서 저장합니다.

==============================================================================

using UnityEngine;
using System.Collections;
using System.Collections.Generic;   // 리스트를 쓰기 위해 추가합니다.

public class csTest : MonoBehaviour 
{
    // 이렇게 클래스를 만들고
    [Serializable]           // 저장하기 위해서 있어야 합니다.
    public class ScoreEntry
    {
        public string name;
        public int score;
    }

    string currentPlayerName;
    int score;

    // 만든 클래스를 리스트에 담아서 관리하면 마치 테이블처럼 사용할 수 있습니다. 
    public List<ScoreEntry> highScore = new List<ScoreEntry>();

    void AddData()
    {
        // 이렇게 새로운 데이터를 추가해주고
        highScore.Add(new ScoreEntry { name = currentPlayerName, score = score });
    }

    void OnGUI()
    {
        // 이렇게 화면에 랭킹 정보를 보여주면 됩니다. 
        foreach (ScoreEntry nowScore in highScore)
        {
            GUILayout.Label(string.Format("{0} : {1:#, 0}", nowScore.name, nowScore.score));
        }
    }
}

==============================================================================

이렇게 정보를 테이블처럼 만든 후에는 BinaryFormatter를 사용해서 저장할 수 있습니다. 

BinaryFormatter는 '파라미터를 갖지 않는 생성자'를 갖는 클래스라면 어떤 클래스도 바이트 배열로 변환하고, 그것을 다시 문자열 값으로 변환할 수 있습니다. 

문자열 값으로 변환이 가능하다면 이전 포스팅에서 설명한 PlayerPrefs에 저장할 수 있게 되겠죠.

==============================================================================

using UnityEngine;
using System.Collections;
using System.Collections.Generic;   // 리스트를 쓰기 위해 추가합니다.

// BinaryFormatter를 사용하기 위해서는 반드시 아래의 네임스페이스를 추가해줘야 해요.
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public class csTest : MonoBehaviour 
{
    // 이렇게 클래스를 만들고
    [Serializable]           // 저장하기 위해서 있어야 합니다.
    public class ScoreEntry
    {
        public string name;
        public int score;
    }

    // 만든 클래스를 리스트에 담아서 관리하면 마치 테이블처럼 사용할 수 있습니다. 
    public List<ScoreEntry> highScore = new List<ScoreEntry>();

    void SaveScores()
    {
        var binaryFormatter     = new BinaryFormatter();
        var memoryStream        = new MemoryStream();

        // score를 바이트 배열로 변환해서 저장합니다.
        binaryFormatter.Serialize(memoryStream, highScore);

        // 그것을 다시 한번 문자열 값으로 변환해서 
        // 'HighScore'라는 스트링 키값으로 PlayerPrefs에 저장합니다.
        PlayerPrefs.SetString("HighScore", Convert.ToBase64String(memoryStream.GetBuffer()));
    }

    void Start()
    {
        // 'HighScore' 스트링 키값으로 데이터를 가져옵니다.
        var data = PlayerPrefs.GetString("HighScore");

        if (!string.IsNullOrEmpty(data))
        {
            var binaryFormatter     = new BinaryFormatter();
            var memoryStream        = new MemoryStream(Convert.FromBase64String(data)));

            // 가져온 데이터를 바이트 배열로 변환하고
            // 사용하기 위해 다시 리스트로 캐스팅해줍니다.
            highScore       = (List<ScoreEntry>)binaryFormatter.Deserialize(memoryStream);
        }
    }
}

==============================================================================


반응형

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

OnGUI() 상에서 마우스 더블 클릭 구현  (0) 2014.11.20
LightMap 동적 로딩.  (0) 2014.10.01
Unity Serializer  (0) 2014.09.25
Simple C# Unity Serializer  (0) 2014.09.25
ClipboardHelper  (0) 2014.05.15
Posted by blueasa
, |

Unity Serializer

Unity3D/Script / 2014. 9. 25. 16:30


Link : http://whydoidoit.com/unityserializer/

반응형

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

LightMap 동적 로딩.  (0) 2014.10.01
좀 더 복잡한 데이터 저장하기  (6) 2014.09.25
Simple C# Unity Serializer  (0) 2014.09.25
ClipboardHelper  (0) 2014.05.15
유니티 코루틴 깊이 알고 재미있게 쓰기.  (0) 2014.05.09
Posted by blueasa
, |

I wrote this class to serializes common unity types into and out of a byte array. Its nothing fancy, but its handy for networking player state.

     //--- Serialize ---  
     UnitySerializer srlzr = new UnitySerializer();  
     srlzr.Serialize(new Vector3(4, 8, 6));  
     byte[] byteArray = srlzr.ByteArray;  
   
     // send byte array somewhere..  
   
     //--- Deserialize ---  
     UnitySerializer dsrlzr = new UnitySerializer(byteArray);  
     Vector3 point3 = dsrlzr.DeserializeVector3();  


It supports Vector3, Vector2 and Quaternions, as well as the common primitives and its easy enough to extend to extra types. Just be sure to deserialize the data in the same order it was serialized. Check out the Example() function at the bottom to see how it works.


 // Author: Richard Pieterse, April 2013  
   
 using UnityEngine;  
 using System.Collections.Generic;  
 using System;  
   
 public class UnitySerializer {  
   
   private List<byte> byteStream = new List<byte>();  
   private byte[] byteArray;  
   private int index = 0;  
   
   /// <summary>  
   /// Returns the stream as a Byte Array  
   /// </summary>  
   public byte[] ByteArray  
   {  
     get  
     {  
       if ( byteArray == null || byteStream.Count != byteArray.Length)  
         byteArray = byteStream.ToArray();  
   
       return byteArray;  
     }  
   }  
   
   /// <summary>  
   /// Create a new empty stream  
   /// </summary>  
   public UnitySerializer()  
   {  
   
   }  
   
   /// <summary>  
   /// Initialiaze a stream from a byte array.  
   /// Used for deserilaizing a byte array  
   /// </summary>  
   /// <param name="ByteArray"></param>  
   public UnitySerializer(byte[] ByteArray)  
   {  
     byteArray = ByteArray;  
     byteStream = new List<byte>(ByteArray);  
   }  
   
     
   
   // --- double ---  
   public void Serialize(double d)  
   {  
     byteStream.AddRange( BitConverter.GetBytes(d));  
   
   }  
   
   public double DeserializeDouble()  
   {  
     double d = BitConverter.ToDouble(ByteArray, index); index += 8;  
     return d;  
   }  
   //  
   
   // --- bool ---  
   public void Serialize(bool b)  
   {  
     byteStream.AddRange(BitConverter.GetBytes(b));  
   }  
   
   public bool DeserializeBool()  
   {  
     bool b = BitConverter.ToBoolean(ByteArray, index); index += 1;  
     return b;  
   }  
   //  
   
   // --- Vector2 ---  
   public void Serialize(Vector2 v)  
   {  
     byteStream.AddRange(GetBytes(v));  
   }  
   
   public Vector2 DeserializeVector2()  
   {  
     Vector2 vector2 = new Vector2();  
     vector2.x = BitConverter.ToSingle(ByteArray, index); index += 4;  
     vector2.y = BitConverter.ToSingle(ByteArray, index); index += 4;  
     return vector2;  
   }  
   //  
   
   // --- Vector3 ---  
   public void Serialize(Vector3 v)  
   {  
     byteStream.AddRange(GetBytes(v));  
   }  
   
   public Vector3 DeserializeVector3()  
   {  
     Vector3 vector3 = new Vector3();  
     vector3.x = BitConverter.ToSingle(ByteArray, index); index += 4;  
     vector3.y = BitConverter.ToSingle(ByteArray, index); index += 4;  
     vector3.z = BitConverter.ToSingle(ByteArray, index); index += 4;  
     return vector3;  
   }  
   //  
   
   // --- Type ---  
   public void Serialize(System.Type t)  
   {  
     // serialize type as string  
     string typeStr = t.ToString();  
     Serialize(typeStr);  
   }  
   
   public Type DeserializeType()  
   {  
     // type stored as string  
     string typeStr = DeserializeString();  
     return Type.GetType(typeStr); ;  
   }  
   //  
   
   // --- String ---  
   public void Serialize(string s)  
   {  
     // add the length as a header  
     byteStream.AddRange(BitConverter.GetBytes(s.Length));  
     foreach (char c in s)  
       byteStream.Add((byte)c);  
   }  
   
   public string DeserializeString()  
   {  
     int length = BitConverter.ToInt32(ByteArray, index); index += 4;  
     string s = "";  
     for (int i = 0; i < length; i++)  
     {  
       s += (char)ByteArray[index];  
       index++;  
     }  
   
     return s;  
   }  
   //  
   
   // --- byte[] ---  
   public void Serialize(byte[] b)  
   {  
     // add the length as a header  
     byteStream.AddRange(BitConverter.GetBytes(b.Length));  
     byteStream.AddRange(b);  
   }  
   
   public byte[] DeserializeByteArray()  
   {  
     int length = BitConverter.ToInt32(ByteArray, index); index += 4;  
     byte[] bytes = new byte[length];  
     for (int i = 0; i < length; i++)  
     {  
       bytes[i] = ByteArray[index];  
       index++;  
     }  
      
     return bytes;  
   }  
   //  
   
   // --- Quaternion ---  
   public void Serialize(Quaternion q)  
   {  
     byteStream.AddRange(GetBytes(q));  
   }  
   
   public Quaternion DeserializeQuaternion()  
   {  
     Quaternion quat = new Quaternion();  
     quat.x = BitConverter.ToSingle(ByteArray, index); index += 4;  
     quat.y = BitConverter.ToSingle(ByteArray, index); index += 4;  
     quat.z = BitConverter.ToSingle(ByteArray, index); index += 4;  
     quat.w = BitConverter.ToSingle(ByteArray, index); index += 4;  
     return quat;  
   }  
   //  
   
   // --- float ---  
   public void Serialize(float f)  
   {  
     byteStream.AddRange(BitConverter.GetBytes(f));  
   }  
   
   public float DeserializeFloat()  
   {  
     float f = BitConverter.ToSingle(ByteArray, index); index += 4;  
     return f;  
   }  
   //  
   
   // --- int ---  
   public void Serialize(int i)  
   {  
     byteStream.AddRange(BitConverter.GetBytes(i));  
   }  
   
   public int DeserializeInt()  
   {  
     int i = BitConverter.ToInt32(ByteArray, index); index += 4;  
     return i;  
   }  
   //  
   
   // --- internal ----  
   Vector3 DeserializeVector3(byte[] bytes, ref int index)  
   {  
     Vector3 vector3 = new Vector3();  
     vector3.x = BitConverter.ToSingle(bytes, index); index += 4;  
     vector3.y = BitConverter.ToSingle(bytes, index); index += 4;  
     vector3.z = BitConverter.ToSingle(bytes, index); index += 4;  
   
     return vector3;  
   }  
   
   Quaternion DeserializeQuaternion(byte[] bytes, ref int index)  
   {  
     Quaternion quat = new Quaternion();  
     quat.x = BitConverter.ToSingle(bytes, index); index += 4;  
     quat.y = BitConverter.ToSingle(bytes, index); index += 4;  
     quat.z = BitConverter.ToSingle(bytes, index); index += 4;  
     quat.w = BitConverter.ToSingle(bytes, index); index += 4;  
     return quat;  
   }  
   
   byte[] GetBytes(Vector2 v)  
   {  
     List<byte> bytes = new List<byte>(8);  
     bytes.AddRange(BitConverter.GetBytes(v.x));  
     bytes.AddRange(BitConverter.GetBytes(v.y));  
     return bytes.ToArray();  
   }  
   
   byte[] GetBytes(Vector3 v)  
   {  
     List<byte> bytes = new List<byte>(12);  
     bytes.AddRange(BitConverter.GetBytes(v.x));  
     bytes.AddRange(BitConverter.GetBytes(v.y));  
     bytes.AddRange(BitConverter.GetBytes(v.z));  
     return bytes.ToArray();  
   }  
   
   byte[] GetBytes(Quaternion q)  
   {  
     List<byte> bytes = new List<byte>(16);  
     bytes.AddRange(BitConverter.GetBytes(q.x));  
     bytes.AddRange(BitConverter.GetBytes(q.y));  
     bytes.AddRange(BitConverter.GetBytes(q.z));  
     bytes.AddRange(BitConverter.GetBytes(q.w));  
     return bytes.ToArray();  
   }  
   
   public static void Example()  
   {  
     //  
     Debug.Log("--- UnitySerializer Example ---");  
     Vector2 point      = UnityEngine.Random.insideUnitCircle;  
     Vector3 position    = UnityEngine.Random.onUnitSphere;  
     Quaternion quaternion  = UnityEngine.Random.rotation;  
     float f         = UnityEngine.Random.value;  
     int i          = UnityEngine.Random.Range(0, 10000);  
     double d        = (double)UnityEngine.Random.Range(0, 10000);  
     string s        = "Brundle Fly";  
     bool b         = UnityEngine.Random.value < 0.5f ? true : false;  
     System.Type type    = typeof(UnitySerializer);  
   
     //  
     Debug.Log("--- Before ---");  
     Debug.Log(point + " " + position + " " + quaternion + " " + f + " " + d + " " + s + " " + b + " " + type);  
   
     //  
     Debug.Log("--- Serialize ---");  
     UnitySerializer us = new UnitySerializer();  
     us.Serialize(point);  
     us.Serialize(position);  
     us.Serialize(quaternion);  
     us.Serialize(f);  
     us.Serialize(i);  
     us.Serialize(d);  
     us.Serialize(s);  
     us.Serialize(b);  
     us.Serialize(type);  
     byte[] byteArray = us.ByteArray;  
       
     // the array must be deserialized in the same order as it was serialized  
     Debug.Log("--- Deserialize ---");  
     UnitySerializer uds   = new UnitySerializer(byteArray);  
     Vector2 point2     = uds.DeserializeVector2();  
     Vector3 position2    = uds.DeserializeVector3();  
     Quaternion quaternion2 = uds.DeserializeQuaternion();  
     float f2        = uds.DeserializeFloat();  
     int i2         = uds.DeserializeInt();  
     double d2        = uds.DeserializeDouble();  
     string s2        = uds.DeserializeString();  
     bool b2         = uds.DeserializeBool();  
     System.Type type2    = uds.DeserializeType();  
   
     //  
     Debug.Log("--- After ---");  
     Debug.Log(point2 + " " + position2 + " " + quaternion2 + " " + f2 + " " + d2 + " " + s2 + " " + b2 + " " + type2);  
   }  
 }  
   



출처 : http://deciduousgames.blogspot.kr/2013/04/unity-serializer.html

반응형

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

좀 더 복잡한 데이터 저장하기  (6) 2014.09.25
Unity Serializer  (0) 2014.09.25
ClipboardHelper  (0) 2014.05.15
유니티 코루틴 깊이 알고 재미있게 쓰기.  (0) 2014.05.09
ScreenWipe CrossFade with C#  (0) 2014.04.22
Posted by blueasa
, |


Link : http://westwoodforever.blogspot.kr/2013/10/unity3d-ios-binaryformatter.html

반응형
Posted by blueasa
, |


안드로이드 네이티브 크래쉬 덤프 (ARM cpu)


반응형
Posted by blueasa
, |