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

카테고리

분류 전체보기 (2738)
Unity3D (817)
Programming (475)
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
05-07 05:17

LightMapSize 조절

Unity3D/LightMap / 2014. 3. 18. 09:44
using UnityEditor; 

public class LightMapSize_512 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_512")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 512; 
        LightmapEditorSettings.maxAtlasWidth = 512; 
    } 
} 

public class LightMapSize_1024 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_1024")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 1024; 
        LightmapEditorSettings.maxAtlasWidth = 1024; 
    } 
} 

public class LightMapSize_2048 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_2048")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 2048; 
        LightmapEditorSettings.maxAtlasWidth = 2048; 
    } 
} 

public class LightMapSize_4096 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_4096")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 4096; 
        LightmapEditorSettings.maxAtlasWidth = 4096; 
    } 
} 
출처 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=43889&page=0&sca=&sfl=&stx=&spt=0&page=0&currentId=44#c_43910


반응형
Posted by blueasa
, |


Install "Lightmapping Extended":

Step 1 is to pick up "Lightmapping Extended" on the Unity Asset Store! and commit it into the project!https://www.assetstore.unity3d.com/#/content/6071

While most of the settings are a bit beyond pick up and play, the ability to save and load xml configurations is a life saver and if you are working with a team it can really speed up the workflow. There are great tool tips for the rest of the settings. Without a formal lighting background I make do with what I have and search for what I don't know.

Document Changes:

Despite knowing and saving your production settings with Lightmapping Extended, when dialing in a light setup I take screenshots of the editor and the light map settings panel. This lets me get good before and after images documented when I make subtle changes to the overall settings. It also lets me show others how the system works and how the scene has evolved.

UV scale / ratio fine tuning:

After I get my main light sources in and where I want them I run a high quality bake so I can see where major shadows fall. Armed with this I can manually select all prefabs that are 100% within shadow and set their "Scale in Lightmap" setting down to .1 - .05. Once you have done this to all relevant objects you can do the reverse for 'hero' objects. Unfortunately you often want to increase the light map resolution on large objects such as the ground, and depending on how the geometry is split up the UV block might be too big and bulky to do too much with. (Currently Unity 4.1 does a terrible job auto laying out UV's - according to this thread that should be resolved in 4.2)

Maximize your resolution within your output targets:

Once I have all the manual light map scaling in place I then nuke my settings back down to a 10-20 second render time and start inching the resolution up or down to get everything at my desired output target. We often want to get everything onto 1 1024 map (which we can still cut down later). I want the scene to look as good as it can be - even if it means spending an hour bumping up the resolution by .01!

Editing the light map .exr file:

While my options are limited I from time to time do bring in the final .exr image into Photoshop for some slight level adjustments Note that doing this will probably hose you if you need to do dual light map realtime lighting. Photoshop is pretty limited in what you can do to a 32 channel image however I do have a work around for solidifying unity's output if I feel the image will benefit form it. since you can't use the magic wand with a tolerance of 1 to select out and delete the black I save off a version with 16 channels, save a selection of what I want to delete and load it back into the 32 bit file, delete out the black and run Solidify A on it to blend in the image. I am 100% sure there is an easier way to do this - I just have no experience editing HDR files, let alone 16bit in photoshop.

Wishes:

I would LOVE to be able to set what I want my output to be and have Unity fill in the rest. I usually have to spend an hour or two over the course of a scene setup fine tuning the atlas resolution trying to get it all onto 1 1024 map for instance. This changes and needs to be re-optimized every time you manually set a scale override on something in your scene (which I have the tendency to do quite often!)

Additionally I would LOVE to have some sort of automated workflow occur where I could set up a stationary camera that takes the same screenshot after every bake and splices in the settings data as well!

That's all for now, hope this saves somebody some time!




출처 http://mkingery.com/blog/unity-lightmapping-tips-tricks-and-thoughts

반응형

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

[펌] Unity 5 lightmapped scene assetbundle problem  (0) 2017.04.19
유니티5 라이트 맵 팁  (0) 2015.06.19
LightMapSize 조절  (0) 2014.03.18
Posted by blueasa
, |

Platform Dependent Compilation

Unity includes a feature named "Platform Dependent Compilation". This consists of some preprocessor directives that let you partition your scripts to compile and execute a section of code exclusively for one of the supported platforms.

Furthermore, you can run this code within the Editor, so you can compile the code specifically for your mobile/console and test it in the Editor!

Platform Defines

The platform defines that Unity supports for your scripts are:

UNITY_EDITORDefine for calling Unity Editor scripts from your game code.
UNITY_STANDALONE_OSXPlatform define for compiling/executing code specifically for Mac OS (This includes Universal, PPC and Intel architectures).
UNITY_DASHBOARD_WIDGETPlatform define when creating code for Mac OS dashboard widgets.
UNITY_STANDALONE_WINUse this when you want to compile/execute code for Windows stand alone applications.
UNITY_STANDALONE_LINUXUse this when you want to compile/execute code for Linux stand alone applications.
UNITY_STANDALONEUse this to compile/execute code for any standalone platform (Mac, Windows or Linux).
UNITY_WEBPLAYERPlatform define for web player content (this includes Windows and Mac Web player executables).
UNITY_WIIPlatform define for compiling/executing code for the Wii console.
UNITY_IPHONEPlatform define for compiling/executing code for the iPhone platform.
UNITY_ANDROIDPlatform define for the Android platform.
UNITY_PS3Platform define for running PlayStation 3 code.
UNITY_XBOX360Platform define for executing Xbox 360 code.
UNITY_NACLPlatform define when compiling code for Google native client (this will be set additionally to UNITY_WEBPLAYER).
UNITY_FLASHPlatform define when compiling code for Adobe Flash.
UNITY_BLACKBERRYPlatform define for a Blackberry10 device.
UNITY_WP8Platform define for Windows Phone 8.
UNITY_METROPlatform define for Windows Store Apps (additionally NETFX_CORE is defined when compiling C# files against .NET Core).
UNITY_WINRTEquivalent to UNITY_WP8 | UNITY_METRO

Also you can compile code selectively depending on the version of the engine you are working on. Currently the supported ones are:

UNITY_2_6Platform define for the major version of Unity 2.6.
UNITY_2_6_1Platform define for specific version 1 from the major release 2.6.
UNITY_3_0Platform define for the major version of Unity 3.0.
UNITY_3_0_0Platform define for the specific version 0 of Unity 3.0.
UNITY_3_1Platform define for major version of Unity 3.1.
UNITY_3_2Platform define for major version of Unity 3.2.
UNITY_3_3Platform define for major version of Unity 3.3.
UNITY_3_4Platform define for major version of Unity 3.4.
UNITY_3_5Platform define for major version of Unity 3.5.
UNITY_4_0Platform define for major version of Unity 4.0.
UNITY_4_0_1Platform define for major version of Unity 4.0.1.
UNITY_4_1Platform define for major version of Unity 4.1.
UNITY_4_2Platform define for major version of Unity 4.2.

Note: For versions before 2.6.0 there are no platform defines as this feature was first introduced in that version.

Testing precompiled code.

We are going to show a small example of how to use the precompiled code. This will simply print a message that depends on the platform you have selected to build your target.

First of all, select the platform you want to test your code against by clicking on File -> Build Settings. This will bring the build settings window to select your target platform.


Build Settings window with the WebPlayer Selected as Target platform.

Select the platform you want to test your precompiled code against and press the Switch Editor button to tell Unity which platform you are targeting.

Create a script and copy/paste this code:-

// JS
function Awake() {
  #if UNITY_EDITOR
    Debug.Log("Unity Editor");
  #endif

  #if UNITY_IPHONE
    Debug.Log("Iphone");
  #endif

  #if UNITY_STANDALONE_OSX
    Debug.Log("Stand Alone OSX");
  #endif

  #if UNITY_STANDALONE_WIN
    Debug.Log("Stand Alone Windows");
  #endif	
}


// C#
using UnityEngine;
using System.Collections;

public class PlatformDefines : MonoBehaviour {
  void Start () {

    #if UNITY_EDITOR
      Debug.Log("Unity Editor");
    #endif

    #if UNITY_IPHONE
      Debug.Log("Iphone");
    #endif

    #if UNITY_STANDALONE_OSX
	Debug.Log("Stand Alone OSX");
    #endif

    #if UNITY_STANDALONE_WIN
      Debug.Log("Stand Alone Windows");
    #endif

  }			   
}


// Boo
import UnityEngine

class PlatformDefines (MonoBehaviour): 

	def Start ():
		ifdef UNITY_EDITOR:
			Debug.Log("Unity Editor")

		ifdef UNITY_IPHONE:
			Debug.Log("IPhone")

		ifdef UNITY_STANDALONE_OSX:
			Debug.Log("Stand Alone OSX")

		ifdef not UNITY_IPHONE:
			Debug.Log("not an iPhone")

Then, depending on which platform you selected, one of the messages will get printed on the Unity console when you press play.

Note that in c# you can use a CONDITIONAL attribute which is a more clean, less error-prone way of stripping out functions, see http://msdn.microsoft.com/en-us/library/4xssyw96.aspx.

In addition to the basic #if compiler directive, you can also use a multiway test in C# and JavaScript:-

#if UNITY_EDITOR
    Debug.Log("Unity Editor");
#elif UNITY_IPHONE
    Debug.Log("Unity iPhone");
#else
    Debug.Log("Any other platform");
#endif

However, Boo currently supports only the ifdef directive.

Platform Custom Defines

It is also possible to add to the built-in selection of defines by supplying your own. In the Other Settings panel of the Player Settings, you will see the Scripting Define Symbols textbox.

Here, you can enter the names of the symbols you want to define for that particular platform, separated by semicolons. These symbols can then be used as the conditions for #if directives just like the built-in ones.

Global Custom Defines

You can define your own preprocessor directives to control which code gets included when compiling. To do this you must add a text file with the extra directives to the "Assets/" folder. The name of the file depends on the language you are using, and the extension is .rsp:

C#<Project Path>/Assets/smcs.rsp
C# - Editor Scripts<Project Path>/Assets/gmcs.rsp
UnityScript<Project Path>/Assets/us.rsp
Boo<Project Path>/Assets/boo.rsp

As an example, if you include the single line "-define:UNITY_DEBUG" in your smcs.rsp file the define UNITY_DEBUG will exist as a global define for C# scripts, except for Editor scripts.

Every time you make changes to .rsp files you will need to recompile for them to be effective. You can do this by updating or reimporting a single script (.js, .cs or .boo) file.

If you want to modify only global defines, you should use Scripting Define Symbols in Player Settings, because this will cover all the compilers. If you choose the .rsp files instead, you'll have to provide one file for every compiler Unity uses, and you won't know when one or another compiler is used.

The use of the .rsp files is described in the help section of the smcs application which is included in the Editor installation folder. You can get more information by running "smcs -help". Also, bear in mind the .rsp file needs to match the compiler being invoked. For example, when targeting the web player, smcs is used with smcs.rsp; when targeting standalone players, gmcs is used with gmcs.rsp; when targeting MS compiler, csc is used with csc.rsp; and so on.


출처 : https://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html

반응형

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

어플을 내렸을때, 어플을 종료할때의 처리  (3) 2014.04.04
Unity Singleton  (0) 2014.03.24
Generic Based Singleton for MonoBehaviours完全版(?)  (0) 2014.03.05
Singleton  (0) 2014.03.05
Serializable, NonSerialized  (0) 2013.07.30
Posted by blueasa
, |

Unity AssetBundle Dependencies

In the last few weeks I’ve spent quite a lot of time with Unity’s Asset Bundle system. Understanding how dependencies were tracked. What determines GC cleanup of assets and understanding why the editor profiler produces particular results has been a bit of a struggle. I’m lucky enough to work for a group that allows me to have access to the Unity source code however so this has probably been slightly less painful than it has been for others going down this same path.

First, I’d like to acknowledge what appears to be the most useful piece of Unity Answers information that I’ve come across, located here. This seems to explain the general mechanics of how to include dependencies using the push and then pop method in an editor script.

For my purposes, I created a test project that contained several prefabs all containing simple GUI elements. These elements all used the same fonts and referenced the same textures. This was to verify that, in the editor profiler and in instruments, assets were in fact being shared.

I’ve included my example editor script below to demonstrate some of the methods I used for packing the bundles. In my case, I am traversing all assets in my prefab folder and treating elements with the word “Global” in their name as shared. If I were to have many dependency bundles instead of the one that I have in this example I would have to sort the order in which I am packing these bundles.

using UnityEngine;
using UnityEditor;

using System.IO;
using System.Collections.Generic;

public class AssetBundleBuild : MonoBehaviour
{
    [MenuItem("AssetBundle/Build Bundles")]
    private static void BuildBundles()
    {
        DirectoryInfo directory = new DirectoryInfo(Application.dataPath + "/Prefabs");
        FileInfo[] files = directory.GetFiles("*.prefab", SearchOption.AllDirectories);

        bool shouldPush;

        BuildPipeline.PushAssetDependencies();
        foreach (FileInfo f in files)
        {
            shouldPush = !f.Name.Contains("Global");
            if (shouldPush)
            {
                BuildPipeline.PushAssetDependencies();
            }

            // Get each asset path
            string path = Application.dataPath + "/Bundles/" + f.Name.Substring(0, f.Name.LastIndexOf(".")) + ".bundle";
            string assetPath = f.FullName.Substring(f.FullName.IndexOf("Assets", f.FullName.Length - f.FullName.IndexOf("Assets")));

            Object asset = AssetDatabase.LoadMainAssetAtPath(assetPath);
            //Debug.Log("Asset to pack " + asset + " , " + asset.name);

            BuildAssetBundleOptions options = 
                BuildAssetBundleOptions.DisableWriteTypeTree | 
                BuildAssetBundleOptions.CollectDependencies | 
                BuildAssetBundleOptions.CompleteAssets | 
                BuildAssetBundleOptions.DeterministicAssetBundle;

            if (!shouldPush)
            {
                Object[] d = EditorUtility.CollectDependencies(new Object[] { asset });

                List<Object> dSource = new List<Object>();
                List<string> dNames = new List<string>();

                // In this case I'm attempting to manually collect dependencies for tracking purposes
                // however this does not always seem to be necessary unless you have complex prefab heirarchies
                foreach (Object o in d)
                {
                    if (o != null && !dSource.Contains(o))
                    {
                        Debug.Log(" -- d " + o + " , " + o.name + " , " + o.GetType());

                        dSource.Add(o);
                        dNames.Add(o.name);
                    }
                }

                Debug.Log("::BUILDING DEPENDENCY BUNDLE:: " + asset.name + " , " + dSource.Count);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    dSource.ToArray(), 
                    dNames.ToArray(), 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);
            }
            else
            {
                Debug.Log("::NON DEPENDENCY:: " + asset.name);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    new Object[] { asset }, 
                    new string[] { asset.name }, 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);

                if (shouldPush)
                {
                    BuildPipeline.PopAssetDependencies();
                }
            }
        }

        BuildPipeline.PopAssetDependencies();

        Debug.Log("[AssetBundleBuild] Complete.");
    }
}

Now, from the standpoint of packing shared dependencies, this seemed to work with most asset types such as textures or prefabs but when I included fonts, while they wouldn’t be duplicated across multiple bundles, I would always see two copies of my fonts. One set would be flagged as being ‘used by scripts and native code’ and the other would only be flagged as ‘used by native code’. After performing numerous tests, I discovered that upon opening the dependency bundle containing the font I was interested in, if there was a copy of the font in the project directory as well, both versions would be loaded into Resources. I haven’t been able to verify whether this happens on device as well but my inclination is that it only occurs in the editor.

The Problem of the Decompression Buffer

Another problem that became visible when working with large quantities of bundles that (based off of conversations with Unity technical representatives and the 4.2.0b3 beta client) may have changed in such a way as to render the problem less dire is that Unity, as of 4.1.5, allocates an 8mb decompression buffer per each asset bundle being opened. If there is an attempt to parallelize these requests, each request will allocate it’s own decompression buffer. This can be rather disconcerting as one can see how the allocation amount (especially on restricted memory devices) can really get a guy down.

Although 4.2.0b3 seems to be reducing the decompression buffer size down to 0.5mb per bundle the problem of parallelization still persists. The only immediate solution for individuals loading any quantity of bundles seems to be amortizing the requests in such a way as to prevent too much overlap. If someone out there has a suggestion to mitigate this problem otherwise please drop me a line mcelroy.jon[at]gmail.com


출처 : http://blog.jonmcelroy.com/post/55526714506/unity-assetbundle-dependencies

반응형
Posted by blueasa
, |

실시간 그림자

Unity3D/Shadow / 2014. 3. 7. 01:00

배경이 평면이어야 된다는 제약이 있긴하지만 좋은 방법인 듯..


링크 : http://blog.naver.com/zeodtr/70186005934





반응형
Posted by blueasa
, |
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
using UnityEngine;
 
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
    static T m_Instance = null;
 
    public static T instance
    {
        get
        {
            if( m_Instance != null )
            {
                return m_Instance;
            }
 
            System.Type type = typeof(T);
 
            T instance = GameObject.FindObjectOfType(type) as T;
 
            if( instance == null )
            {
                string typeName = type.ToString();
 
                GameObject gameObject = new GameObject( typeName, type );
                instance = gameObject.GetComponent<T>();
 
                if( instance == null )
                {
                    Debug.LogError("Problem during the creation of " + typeName,gameObject );
                }
            }
            else
            {
                Initialize(instance);
            }
            return m_Instance;
        }
    }
 
    static void Initialize(T instance)
    {
        if( m_Instance == null )
        {
            m_Instance = instance;
 
            m_Instance.OnInitialize();
        }
        else if( m_Instance != instance )
        {
            DestroyImmediate( instance.gameObject );
        }
    }
 
    static void Destroyed(T instance)
    {
        if( m_Instance == instance )
        {
            m_Instance.OnFinalize();
 
            m_Instance = null;
        }
    }
 
    public virtual void OnInitialize() {}
    public virtual void OnFinalize() {}
 
    void Awake()
    {
        Initialize( this as T );
    }
 
    void OnDestroy()
    {
        Destroyed( this as T );
    }
 
    void OnApplicationQuit()
    {
        Destroyed( this as T );
    }
}

使い方は

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using UnityEngine;
using System.Collections;
 
public class TestSingleton : MonoSingleton<TestSingleton>
{
    public override void OnInitialize()
    {
        Debug.Log ( "TestSingleton#OnInitialize" );
    }
 
    public override void OnFinalize()
    {
        Debug.Log ( "TestSingleton#OnFinalize" );
    }
}


출처 : http://caitsithware.com/wordpress/?p=118

반응형

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

Unity Singleton  (0) 2014.03.24
Platform Dependent Compilation  (0) 2014.03.11
Singleton  (0) 2014.03.05
Serializable, NonSerialized  (0) 2013.07.30
Get MAC address on Android device  (0) 2013.07.24
Posted by blueasa
, |

Singleton

Unity3D/Script / 2014. 3. 5. 10:41

일반형 Singleton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class MySingleton
{
    private static MySingleton instance;
 
    //
    private MySingleton()
    {
 
    }
 
    static MySingleton()
    {
        instance = new MySingleton();
    }
 
    public static MySingleton Instance
    {
        get
        {
            return instance;
        }
    }
};

Component용 Singleton

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
using UnityEngine;
using System.Collections;
 
public class MySingleton : MonoBehaviour {
 
    private static MySingleton instance;
     
    //
    private MySingleton()
    {
    }
     
    //
    public static MySingleton Instance
    {
        get
        {
            if (instance == null)
            {
                instance =  FindObjectOfType(typeof (MySingleton)) as MySingleton;
             
                if (instance == null)
                {
                    GameObject obj = new GameObject("MySingleton");
                    instance = obj.AddComponent(typeof (MySingleton)) as MySingleton;
                    Debug.Log ("Could not locate an MySingleton object. MySingleton was Generated Automaticly.");
                }
            }
  
            return instance;
        }
    }
     
    void Awake()
    {
        DontDestroyOnLoad(this);
    }
     
    void OnApplicationQuit()
    {
        instance = null;
    }
}

제네릭 버전

일반형 Singleton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class  Singleton<T> where T : class, new()
{
    private static T instance;
         
    static Singleton()
    {
        instance = new T();
    }
     
    public static T Instance
    {
        get
        {
            return instance;
        }
    }
};

Component용 Singleton

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
using UnityEngine;
using System.Collections;
  
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
    private static T instance;
     
    //
    public static T Instance
    {
        get
        {
            if (instance == null)
            {
                instance =  FindObjectOfType(typeof(T)) as T;
             
                if (instance == null)
                {
                    GameObject obj = new GameObject(typeof (T).ToString());
                    instance = obj.AddComponent(typeof (T)) as T;
                    instance.Init();
         
                    Debug.Log ("Could not locate an " + typeof (T).ToString() +" object. " + typeof (T).ToString() + " was Generated Automaticly.");
                }
            }
         
            return instance;
        }
    }
      
    void Awake()
    {
        if (instance == null)
        {
            instance = this as T;
            instance.Init();
        }
         
        DontDestroyOnLoad(this);
    }
      
    void OnApplicationQuit()
    {
        instance = null;
    }
     
    public virtual void Init()
    {
         
    }
}



반응형
Posted by blueasa
, |

링크 : http://unitystudy.net/bbs/board.php?bo_table=newwriting&wr_id=357&sca=&sfl=wr_subject&stx=%EC%97%90%EC%85%8B&sop=and

반응형
Posted by blueasa
, |

유니티에서 보통 간단하게 값들을 저장하려면 PlayerPrefs를 많이 씁니다.

물론 로컬에 저장되기 때문에 값이 유저들에게 손쉽게 노출이 되어 변경되기 쉽다는 단점이 있습니다.

 

<PlayerPrefs에 간단한 소개 및 저장위치>

http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html

 

이를 막기 위해서는 서버에도 값을 저장해서 대조해 본다거나 하는 방법이 필요하겠지만,

간단하게 암호화해서 값이 조작될 경우를 알아내도록 하는 방법이 있습니다.

C#에서 제공하는 라이브러리가 있어 이를 활용해서 만들어 보려고 하다가,

유니티 포럼에 Mudloop란 분이 깔끔하게 클라스로 구현해주셔서 공유하려고 합니다.

저도 덕분에 수고를 많이 줄였거든요 ^^


원리는 secret key 와 private key를 이용해 MD5로 해쉬값을 만들어서,

이를 playerprefs에 저장된 값과 비교하여 일치하는지를 체크하는 방식입니다. 

 

<원본 위치>

http://forum.unity3d.com/threads/26437-PlayerPrefs-Encryption

 

사용법은 간단합니다.

 

우선, https://gist.github.com/ftvs/5299600 에 있는 EncryptedPlayerPrefs.cs를 복붙으로 만듭니다.

 

그리고 아래 키 값을 playerprefs 암호화가 필요한 곳 앞에 넣습니다. (키값은 적당히 바꾸시구요)

아마 start() 같은 곳이 적당하겠죠?

 

  1.         EncryptedPlayerPrefs.keys=new string[5];
  2.         EncryptedPlayerPrefs.keys[0]="23Wrudre";
  3.         EncryptedPlayerPrefs.keys[1]="SP9DupHa";
  4.         EncryptedPlayerPrefs.keys[2]="frA5rAS3";
  5.         EncryptedPlayerPrefs.keys[3]="tHat2epr";
  6.         EncryptedPlayerPrefs.keys[4]="jaw3eDAs"

 

EncryptedPlayerPrefs.cs의 private key 값도 적당히 바꿉니다.


그리고 사용하실 때는 EncryptedPlayerPrefs.SetInt("someKey",value); 와 같이 PlayerPrefs와 동일하게 사용해주시면 됩니다.




출처 : http://ideapot.tistory.com/15


참조 : http://wiki.unity3d.com/index.php/MD5

반응형
Posted by blueasa
, |

유니티는 Profiler라는 기능을 지원하여 현재 사용중인 플랫폼의 어플 동작상태를 알수가있는데

폰과 연결이 되지않아 사용을 못하고있었는데 오늘 해결책을 알게되어 공유합니다.

 

1. 빌드시 Development Build 체크

2. Autoconnect Profiler 체크

 

빌드후 어플실행시 Profiler 가 실행되고, Active Profiler 에 AndroidPlayer가 보이게된다.

이때 AndroidPlayer 선택이 되지 않는다면

윈도우 커맨드창에(Console)

안드로이드SDK/platform-tools/ 폴더로 가서

 

adb forward tcp:54999 localabstract:Unity-패키지명(Product Name)

 

와 같이 입력후 다시 선택하면 됩니다.

(명령어 입력시 콘솔창에는 아무것도 어떠한 출력도 하지않고 다시 입력대기상태가됩니다.)

Profiler 를 이용하면 기기에서 어플 동작중 어떤 스크립트에서 CPU 를 얼마나 쓰다던지의 좋은 정보를 많이알수있기때문에 메모리와 퍼포먼스관련 문제를 해결하는데

큰 도움이 될꺼라 생각합니다.


* 회사메일로 공유한내용을 혹시나 도움이 되실까 올립니다 ㅎ



출처 ; http://www.gamecodi.com/board/zboard-id-GAMECODI_Talkdev-no-1919-z-2.htm 쿠하님



참조 : http://lab.gamecodi.com/board/zboard.php?id=GAMECODILAB_QnA_etc&page=1&sn1&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=2364

반응형
Posted by blueasa
, |