블로그 이미지
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-06 11:21

Easy Way

I think this easier approach applies if your Unity project is being built with gradle. If it isn't, here is one more reason to upgrade.

Also, a big shout-out to an article called, Hey, Where Did These Permissions Come From?)

  1. Build Your Project
  2. Open the file /path/to/my/project/Temp/gradleOut/build/outputs/logs/manifest-merger-release-report.txt
  3. Profit!
  4. Search the file for the name of your permission, and it'll show you where it came from.

Here is part of the file, where I'm looking for the WRITE_EXTERNAL_STORAGE permission.

uses-permission#android.permission.WRITE_EXTERNAL_STORAGE ADDED from /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/src/main/AndroidManifest.xml:7:3-79 MERGED from [gradleOut:IronSource:unspecified] /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/IronSource/build/intermediates/bundles/default/AndroidManifest.xml:13:5-81 android:name ADDED from /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/src/main/AndroidManifest.xml:7:20-76

Hard Way

There are three ways permissions get added to your project.

  1. They are specified in an Android Manifest file.
  2. They are specified in library (a .aar file).
  3. Unity adds the permission when you use a certain feature. (Added)

My examples use command-line tools on a Mac. I don't know Windows equivalents, but it is possible to find and run unix tools there (using the linux subsystem for windows 10, cygwin, custom binaries, etc.)

1. Find all permissions used in (uncompressed) Android Manifests.

cd /path/to/my/project/Assets grep -r "uses-permission" --include "AndroidManifest.xml" .

This will find all files named AndroidManifest in the current folder (.) or any of its subfolders (-rtells it to search recursively) and spit out any line with the words 'uses-permission'.

In my current project, I get output something like this:

./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission ./Plugins/Android/IronSource/AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> ./Plugins/Android/IronSource/AndroidManifest.xml: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

2. Find the permissions required in Android Libraries

Your project likely contains android libraries (.aar files) and java archives (.jar files). Some android libraries contain an android manifest and specify permissions needed to use the library. (I don't think .jar files actually do this, but .aar files absolutely do). Both .aar and .jar files are .zip files, with a different extension and with specific metadata in specific places.

Find them by running:

find . -iname "*.?ar" -print -exec zipgrep "uses-permission" "{}" "AndroidManifest.xml" ";" 2> /dev/null

Here's what this does. It finds any file (in the current folder (.) and its subfolders) has an extension of (something) a r, thus .jar, or .aar (-name "*.?ar"). It outputs the archive's file name (-print). It then runs zipgrep (-exec). Zipgrep is told to search through any files in the archive ({}) named "AndroidManifest.xml", and output any line with the words "uses-permission". We then pipe the errors to the bit bucket (2> /dev/null) so we don't see lots of errors about archives that don't have android manifests in them.

An example output looks like this:

./OneSignal/Platforms/Android/onesignal-unity.aar AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.WAKE_LOCK" /> AndroidManifest.xml: <uses-permission android:name="android.permission.VIBRATE" /> ... ./Plugins/Android/android.arch.core.common-1.1.0.jar ./Plugins/Android/android.arch.core.runtime-1.1.0.aar ./Plugins/Android/android.arch.lifecycle.common-1.1.0.jar ... ./Plugins/Android/com.google.android.gms.play-services-gcm-11.8.0.aar AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/com.google.android.gms.play-services-gcm-license-11.8.0.aar ./Plugins/Android/com.google.android.gms.play-services-iid-11.8.0.aar AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/com.google.android.gms.play-services-iid-license-11.8.0.aar ...

The filenames all start with periods. I can thus see, for example, that the onesignal-unity.aar sets several permissions, several .jar files were searched with no permissions inside them, and some of the play services libraries specify permissions.

If I needed to change a library, I could rename the .aar to .zip, extract it, edit it, compress it, and rename it back. (It isn't necessarily wise to change the permissions inside a library, but possible.)

3. Unity Adds the Permission

I didn't have anything to add on this; as said above, if you use the Microphone API, Unity will add a permission for you so your app will work.

However, I've since realized that you can do the following:

  • bring up the Build Settings for Android
  • tick the 'Export Project' box
  • Export the project, noting the location
  • go to /my/project/export/src/main/AndroidManifest.xml. This is what Unity emits for the android manifest (before google's tools do all the merging).
  • compare it (using your favourite diff tool) to Assets/plugins/Android/AndroidManifest.xml; the differences come from Unity.

 

[출처]

https://stackoverflow.com/questions/40931058/how-to-find-source-of-a-permission-in-unity-android

 

How to find source of a permission in Unity Android

Note: This question is specific to Unity3D I have a very clean android manifest file in Unity project under Plugins/Android/ folder with no tag at all. I believe that some

stackoverflow.com

 

반응형
Posted by blueasa
, |

[링크]

https://mentum.tistory.com/150

 

유니티 퍼미션 체크 적용기. (Unity Permission Check)

2019.02.12 다른방식으로 포스트 재 작성 [주의] OBB를 사용하는 Split 빌드의 경우 반드시 저장소 권한을 획득해야함. [주의] 유니티 2018.3 부터 퍼미션체크가 내장되었습니다. 2018.3부터는 플러그인 필요없습..

mentum.tistory.com

 

반응형
Posted by blueasa
, |

Firebase를 앱에 추가 및 Firebase Console에서 설정을 다 하고나서


Android는 FA에서 제대로 체크가 되고 있는데

iOS는 FA에 뜨질 않아서 삽질 하던 중 알게 된 내용 정리해 놓음.


[참조1] https://firebase.google.com/docs/analytics/ios/start?hl=ko

FA에서는 위 참조1 링크의 설명과 같이 iOS의 XCode에서 작업하는 내용을 설명하고 있다.


설명에는 AppDelegate 파일이라고 돼있지만,

유니티에서 Export 된 XCode 프로젝트는 파일명이 약간 달라서 UnityAppController.mm 파일에서 application:(UIApplication*) didFinishLaunchingWithOptions 를 찾을 수 있다.


내 경우는 OBJECTIVE-C 여서 아래와 같은 소스를 UnityAppController.mm에 추가해서 빌드하니 FA에 잘 뜨는 걸 확인 했다.


@import Firebase;
// Use Firebase library to configure APIs
[FIRApp configure];



근데 유니티로 빌드하는데 네이티브인 XCode에서 항상 소스를 수정해줘야 된다는 건 귀찮기 때문에 유니티에서 그냥 셋팅하는 방법이 없나 하고 삽질하다가 찾아낸 방법이 아래와 같다.



[참조2] https://github.com/firebase/quickstart-unity/issues/91

참조2 링크 내용을 보면 FirebaseAnalytics.SetAnalyticsCollectionEnabled(true); 부분이 있다.

XCode에서 셋팅을 하지 않고, 유니티 실행 시 Firebase Analytics를 켤 수 있는 것 같다.


Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);


namespace를 포함해서 위와 같이 앱 실행 시작 부분에서 실행하도록 해주고나서 iOS 앱에서도 FA 체크가 잘되는 걸 확인 완료.



반응형
Posted by blueasa
, |

[파일] 

unity-excel-importer-master.zip


Unity Excel Importer

Automatically import from xls, xlsx to custom ScriptableObject in Unity Editor

Import Setup

1. Create Excel and add to Unity

Create an Excel file, make the first row the name of the column, and enter the data from the second row. And add it to Unity’s Project view.

create_excel import_excel_to_unity

2. Create Entity Class Script

Create a new script and define a class with Excel column names and public fields of the desired type. Also give the class ‘System.Serializable’ attribute.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class MstItemEntity
{
	public int id;
	public string name;
	public int price; 
}

3. Create Excel Asset Script

After selecting Excel, execute ExcelAssetScript from the Create menu and create a ScriptableObject script for Excel.

create_excel_asset

As for the generated script, the Excel file name and the sheet name are extracted and the part is commented out as below.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset]
public class MstItems : ScriptableObject
{
	//public List<EntityType> Entities; // Replace 'EntityType' to an actual type that is serializable.
}

4. Replace EntityType in created Excel Asset

Uncomment fields and replace the generic type of List with the Entity class defined above.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset]
public class MstItems : ScriptableObject
{
	public List<MstItemEntity> Entities;
}

4. Reimport or re-save Excel

When you import or re-save Excel, a ScriptableObject with the same name as Excel is created in the same directory and the contents of Excel are imported.

reimport_excel imported_entities

After this setting, updating Excel automatically updates ScriptableObject as well.

Advanced

Comment Row

If you enter ‘#’ in the first cell of the row, you can treat it as a comment and skip.

Change Asset Path

You can change the ScriptableObject generation position by specifying AssetPath as the ExcelAssetAttribute as shown below.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExcelAsset(AssetPath = "Resources/MasterData")]
public class MstItems : ScriptableObject
{
	public List<MstItemEntity> Entities;
}

Use Enum

You can use enum by entering the element name as string in cell. It is also useful to set Data Validation pull down as an element of enum in Excel.

Lisence

This library is under the MIT License. This software includes the work that is distributed in the Apache License 2.0.



[출처] https://unitylist.com/p/28t/Unity-excel-importer

반응형

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

[펌] Socket.io-Client for Unity3D 소개  (0) 2019.03.08
[링크] iOSPlugin Sample  (0) 2019.01.29
[링크] Emoji_Extension  (0) 2018.06.07
[펌] Background Worker for Unity3D  (0) 2018.06.01
[Link] UnityAppNameLocalizationForIOS  (0) 2018.03.27
Posted by blueasa
, |

[출처http://theeye.pe.kr/archives/2725#disqus_thread

유니티에서 사용되는 코루틴(Coroutine)은 왜 필요한가?

유니티에서 화면의 변화를 일으키기 위해서는 Update() 함수 내에서 작업을 하게 됩니다. 이 Update() 함수는 매 프레임을 그릴때마다 호출되며 60fps의경우라면 초당 60번의 Update() 함수 호출이 발생하게 됩니다. 하나의 프레임 안에서 어떤 작업을 한다면 이 Update() 함수에 코드를 작성하면 될 것입니다.

하지만 다수의 프레임을 오가며 어떤 작업을 수행해야 한다면 어떻게 해야 할까요? 혹은 특정 시간, 가령 3초 동안 특정 작업을 수행해야 한다면 어떻게 해야 할까요? 3초니깐 3 x 60 = 180 프레임동안 작업을 수행하도록 하면 될까요?

안타깝게도 기기의 성능이나 상황에 따라 프레임 드랍(Frame drop)이라는 상황이 발생하게 됩니다. 60fps의 게임일지라 하더라도 디바이스의 성능에 따라 그 이하로 떨어질 수 있다는 의미가 됩니다. 이렇게 되면 더더욱 3초 동안 작업을 수행한다는게 쉽지 않은 일이 됩니다.

예로 다음의 코드를 준비하였습니다. 특정 오브젝트를 페이드 아웃(Fade out) 시키는 예제 코드입니다. 이 코드를 수행하면 스프라이트의 알파값이 점점 작아져서 결국 화면에서 사라지게 됩니다.






위의 코드를 보면 매 프레임마다 스프라이트 렌더러의 알파값을 0.1씩 감소시키고 있습니다. Update() 함수가 10번 호출되면 사라지게 되겠네요. 이는 1/6 초만에 사라지게 된다는것을 의미합니다. 이것도 1/6초만에 사라질지 보장받기가 어렵습니다.

그럼 혹시, 1초에 걸쳐 (60fps가 정상적으로 보장될 경우 60 프레임에 걸쳐) 사라지게 하려면 어떻게 하면 될까요? 대충 알파값을 0.017씩 감소시키면 될까요? 프레임이 아닌 시간 단위로 특정 작업을 수행할 수 있을까요? 여기서 생각할 수 있는 수단은 Time.deltaTime 이 있습니다.

하지만 우리가 여기서 알아보고자 하는것은 델타 타임이 아닌 코루틴이므로 코루틴에 대해서 알아보도록 하겠습니다. 코루틴은 프레임과 상관없이 별도의 서브 루틴에서 원하는 작업을 원하는 시간만큼 수행하는 것이 가능합니다.

다음은 코루틴을 사용하여 1초동안 페이드 아웃을 진행하는 예제 코드입니다.








이전 코드에서는 Update() 에서 모든 작업을 처리하던것을 Start() 에서 RunFadeOut() 코루틴을 실행하는것으로 변경된 것을 볼 수 있습니다. 여기서 주목해야 하는 부분은 yield return new WaitForSeconds(0.1f); 부분입니다.

이 복잡해 보이는 코드는 0.1초 동안 잠시 멈추라는 의미를 가진 코드입니다. 이제 위의 코드를 통해서 페이드 아웃 효과는 0.1초씩 10번을 수행하며 1초동안 사라지는 모습을 보여주게 됩니다. 이 코루틴은 Update() 함수에 종속적이지 않으며 마치 별도의 쓰레드와 같이 동작을 하게 됩니다. 이와 같은 코드로 프레임율에 영향을 받지 않는 시간 기반의 서브루틴을 구동할 수 있게 되었습니다.

IEnumerator와 yield는 무엇이며 어떤 관계가 있는가?

그렇다면 여기서 궁금증을 유발하는 부분이 몇가지 있는데요 RunFadeOut의 리턴 타입은 IEnumerator(열거자) 입니다. 또한 while 문 내부에 보면 yield(양보)라는 구문이 보이는군요. 그 뒤로 return이 따라나오는 것도 일반적인 언어에서 보기 힘든 문법입니다. 이것들이 어떤 관계를 가지고 있는지 알아보겠습니다.

우선 다음의 일반적인 C# 코드를 한번 살펴보도록 하겠습니다.





위의 Main() 함수를 실행하게 되면 다음과 같은 결과물이 출력됩니다.



조금 헷갈리지만 알고보면 어렵지 않은 코드입니다. 이 코드는 다음과 같은 순서로 동작하게 됩니다.

  1. SomeNumbers() 함수를 실행한 결과를 IEnumerator 열거자로 받습니다. 정확히는 실행된 결과가 아닙니다. enumerator 에 함수의 실행결과가 할당 되었다고 생각될만한 코드지만 여기서는 SomeNumbers() 함수는 한줄도 실행되지 않은 상태입니다. 함수의 포인터를 받았다고 생각하시는게 이해하시기 편할 것 같습니다.
  2. while 문을 만나면서 처음으로 enumerator의 MoveNext()가 호출됩니다. 여기서 SomeNumbers()가 실행이 되며 딱 yield 문을 만날때까지 실행이 됩니다.
  3. 첫번째 yield 문인 yield return 3; 을 만납니다. 여기서는 표현식 그대로 return 3에게 양보한다는 느낌으로 코드를 읽으시면 될 것 같습니다. 우선 여기까지 오면 3을 리턴하는것에 양보가 일어납니다. 이때에 리턴되는 값이 존재하므로 MoveNext()의 결과값으로 true가 반환됩니다.
  4. 이제 enumerator의 Current를 통해서 현재 반환된 값을 꺼내올 수 있습니다. MoveNext()를 통해서 yield return 되는 값이 있는지를 알 수 있고 반환된 값이 있다면 Current에 담겨 있게 됩니다.
  5. Debug.Log를 사용하여 Current를 출력해보면 처음으로 양보 반환된 3이 출력되게 됩니다.
  6. 다시한번 while문이 실행되며 MoveNext()가 호출되면 정말 재미있게도 가장 마지막에 yield return이 일어났던 위치의 다음줄부터 재실행이 되게 됩니다. 다시한번 yield 문을 만날때까지 진행이 됩니다.
  7. 이번에는 두번째 yield문인 yield return 5를 만나게 됩니다. 결과적으로 MoveNext() 의 결과값은 true가 되게 됩니다.
  8. 현재 Current에 할당된 값은 MoveNext()의 양보 반환된 값인 5가 될 것입니다.
  9. Debug.Log를 통해 값을 출력해보면 5가 출력됩니다.
  10. 다시한번 while문의 MoveNext()를 호출하면 yield return 5; 다음줄부터 재시작이 되게 되면 yield return 8;까지 진행이 되게 됩니다.
  11. 8이 양보 반환되었으므로 MoveNext()의 값은 true가 되며 Current에는 8이 들어가있게 됩니다.
  12. Debug.Log로 8이 출력됩니다.
  13. 다시한번 MoveNext() 가 호출되며 yield return 8; 이후의 코드부터 실행이 되지만 함수의 끝을 만나게 되므로 더이상 yield가 일어나지 않습니다.
  14. MoveNext() 의 결과 값으로 false가 반환되며 while 문이 종료됩니다.

조금 특이하지만 함수의 반환값이 IEnumerable, IEnumerable<T>, IEnumerator, IEnumerator<T> 인 경우에는 위와 같은 동작을 하게 됩니다. 함수의 동작이 비동기적으로 동작하게 되므로 파라미터에 ref나 out을 사용할 수 없다는 제약 사항이 있습니다. 위의 코드 동작 예시는 코루틴이 어떻게 동작하는지 알기위한 기본적인 코드라고 생각됩니다. 이제 다시 코루틴으로 돌아가 보겠습니다.







StartCoroutine을 직접 구현해 본다면 위와 같은 형태의 코드가 될 것 같습니다. 먼저 코루틴 함수의 포인터 역할을 하는 열거자를 받은 다음에 MoveNext()를 통해 첫번째 yield를 만날때까지 수행하고 그 결과값을 받습니다. 그리고 그 결과값에 맞는 작업을 수행해줍니다. 그리고 이것을 함수가 완료될 때까지 반복합니다.

위의 코드에서는 4번의 MoveNext()가 호출될 것이며 3번의 yield문을 만날 것입니다. 마지막 MoveNext()에서는 false가 반환될 것이므로 코루틴이 종료됩니다. 만약 함수의 실행이 완료되기 이전에 임의로 코루틴을 종료시키고 싶다면 yield break를 호출하면 됩니다. 즉시 MoveNext()에서 false가 반환되어 종료됩니다.

결론적으로 StartCoroutine은 IEnumerator를 반환하는 함수를 인자로 받으며 이 함수는 특이하게도 실행된 결과를 의미하는것이 아니라 함수 포인터와 같은 개념으로 사용이 됩니다.




이 코드를 한번 봐보겠습니다. 일반적인 함수의 개념으로 보자면 StartCoroutine에는 RunCoroutine() 함수의 결과값이 파라미터로 넘겨지게 되어있습니다. 하지만 여기서 RunCoroutine()은 단 한줄도 실행이 되지 않습니다. 함수의 포인터 역할을 하는 IEnumerator가 넘겨지게 되고 MoveNext()를 호출할 때마다 yield 문을 만날때까지 수행됩니다. 만나게 되면 MoveNext()가 true를 반환하고 함수가 끝나거나 yield break; 를 만나게 되면 false를 반환하게 됩니다. true를 반환할 경우 Current를 통해 반환된 값을 꺼내볼 수 있습니다.

StartCoroutine을 수행할 때 사용할 수 있는 두가지 방법

public Coroutine StartCoroutine(IEnumerator routine);

일반적으로 사용할 수 있는 방법입니다. 수행하고자 하는 코루틴의 IEnumerator 열거자를 넘겨서 실행되도록 합니다. 다음과 같은 방법으로 사용이 가능합니다.




위와 같은 방법은 일반적인 방법으로 waitTime 파라미터 값을 넘길 수 있으며 코루틴이 실행되는데에 추가적인 오버헤드가 전혀 없는 방법입니다. 뿐만 아니라 Start() 함수의 반환값을 IEnumerator로 변경하여 아예 코루틴이 실행 완료될때까지 기다리도록 의존적인 방법으로 실행하는 것도 가능합니다.




위의 코드는 WaitAndPrint(waitTime) 코루틴이 실행 완료된 이후에야 Done이 출력되는 과정을 보여줍니다.

public Coroutine StartCoroutine(string methodName, object value = null);

대부분의 경우는 StartCoroutine을 사용하기 위해 전자의 방법을 사용합니다. 하지만 StartCoroutine을 문자열 형태의 코루틴 함수 이름으로도 호출하는 것이 가능합니다. 이렇게 호출하면 StopCoroutine 역시 함수 이름만으로 호출하는것이 가능해 집니다.





위의 코드는 DoSomething(someParameter) 코루틴 함수를 함수 이름과 넘겨질 파라미터를 통해 호출하는 과정을 보여주고 있습니다. 그리고 1초 기다린 뒤에 실행했었던 DoSomething 코루틴을 종료시킵니다. 이러한 함수 이름을 문자열로 넘겨 실행하는 방법은 StartCoroutine을 수행하는데에 오버헤드가 크고 파라미터를 한개밖에 넘길 수 없다는 제약사항이 있습니다. 물론 배열을 넘기는것 역시 가능합니다.

yield return에서 사용할 수 있는 것들

위에서 본 예시에는 WaitForSeconds 클래스를 양보 반환함으로써 원하는 시간(초)만큼 기다리는 것이 가능하다는것을 알 수 있었습니다. 추가로 더 알아 보도록 하겠습니다.

yield return new WaitForSecondsRealtime (float time);

WaitForSeconds와 하는 역할은 동일하지만 결정적으로 다른것이 있습니다. 유니티상의 시간은 임의로 느리게 하거나 빠르게 하는 것이 가능합니다. 이를 Time.timeScale을 통해서 조정을 할 수 있습니다. 매트릭스에서 보던 총알이 느리게 날아오면서 그것을 피하는 모션을 구현해 본다면 이 값을 1보다 낮추게 되면 현재 시간의 진행보다 느려지게 되며 1보다 빠르게 변경하면 현재의 시간의 진행보다 빨라지게 됩니다. 하지만 WaitForSecondsRealtime는 이러한 Scaled Time의 영향을 받지 않고 현실 시간 기준으로만 동작을 하게 됩니다.

yield return new WaitForFixedUpdate ();

다음 FixedUpdate() 가 실행될때까지 기다리게 됩니다. 이 FixedUpdate()는 Update()와 달리 일정한 시간 단위로 호출되는 Update() 함수라고 생각하시면 됩니다.

yield return new WaitForEndOfFrame ();

하나의 프레임워 완전히 종료될 때 호출이 됩니다. Update(), LateUpdate() 이벤트가 모두 실행되고 화면에 렌더링이 끝난 이후에 호출이 됩니다. 특수한 경우에 사용하면 될 것 같습니다만 잘 모르겠군요.

yield return null;

WaitForEndOfFrame를 이야기 했다면 이것을 꼭 이야기 해야 할 것 같습니다. yield return null; 을 하게 되면 다음 Update() 가 실행될때까지 기다린다는 의미를 갖게 됩니다. 좀 더 정확하게는 Update()가 먼저 실행되고 null을 양보 반환했던 코루틴이 이어서 진행 됩니다. 그 다음에 LateUpdate()가 호출됩니다.

yield return new WaitUntil (System.Func<Bool> predicate);

이번엔 특정 조건식이 성공할때까지 기다리는 방법입니다. WaitUntil에 실행하고자 하는 식을 정의해 두면 매번 Update() 와 LateUpdate() 이벤트 사이에 호출해 보고 결과값이 true면 이후로 재진행을 하게 됩니다. 다음의 예제 코드를 보겠습니다.








이 코드는 Update() 함수를 통해 매 프레임마다 frame 멤버 변수값을 1씩 최대 10까지 증가시키게 됩니다. 실행중인 코루틴은 frame값이 10또는 10보다 커질때까지 기다리다가 이 식이 충족되게 되면 다음으로 진행을 하게 됩니다. 여기서 사용되는 식은 람다 표기법이 사용됩니다. 다음과 같은 느낌이라고 생각하시면 될 것 같습니다.

yield return new WaitWhile(System.Func<Bool> predicate);

WaitWhile은 WaitUntil과 동일한 목적을 가지고 있지만 한가지만 다릅니다. WaitUntil은 람다식 실행 결과값이 true가 될때까지 기다린다면 WaitWhile은 false가 될때까지 기다립니다. 즉 WaitWhile은 결과가 true인 동안 계속 기다리게 됩니다.








위의 코드는 첫프레임부터 람다식의 결과가 true이게 됩니다. 10프레임에 도달하면 false가 되어서 이후 진행이 되겠네요.

yield return StartCoroutine (IEnumerator coroutine);

이번에는 심지어 코루틴 내부에서 또다른 코루틴을 호출할 수 있습니다. 물론 그 코루틴이 완료될 때까지 기다리게 됩니다. 의존성 있는 여러작업을 수행하는데에 유리하게 사용 될 수 있습니다.







위와 같은 코드를 실행해 본다면 결과는 다음과 같이 출력됩니다.

Coroutine 중단하기

public void StopCoroutine(IEnumerator routine);

이 방법은 기존에 StartCoroutine을 실행할 때 넘겨주었던 코루틴 함수의 열거자를 파라미터로 사용하여 그것을 중단시키는 방법입니다. 다음과 같은 사용이 가능합니다.








Start() 함수에서 WaitAndPrint(waitTime) 코루틴 함수의 열거자를 획득하여 클래스의 멤버 변수로 설정해 두고 이 코루틴을 실행합니다. 이 코루틴은 1초에 한번씩 WaitAndPrint 를 출력하게 되며 유저가 스페이스키를 누르게 되면 멤버 변수에 담겨 있는 기존 코루틴의 열거자를 이용하여 실행중인 코루틴을 중단시킵니다.

public void StopCoroutine(string methodName);

이 방법은 이전 방식보다 오버헤드는 크지만 간편하게 사용할 수 있는 방법입니다. 다음과 같이 멤버 변수 없이도 간편하게 사용할 수 있습니다.







이때에 주의할 점으로는 StopCoroutine을 문자열로 종료시키려면 StartCoroutine 역시 문자열로 실행했었어야 한다는 점입니다. StartCoroutine(IEnumerator routine) 으로 실행한 다음에 StopCoroutine(string methodName) 으로 종료시킬 수 없습니다.

public void StopAllCoroutines();

마지막으로 현재 Behaviour (클래스라고 이해하면 될 것 같습니다)에서 실행한 모든 코루틴을 한번에 종료시키는 함수입니다. 이와 같은 방법으로 현재 클래스에서 실행한 모든 코루틴을 한번에 중단시키게 됩니다.





어디선가 Example()을 실행하게 되면 DoSomething 코루틴이 실행되게 되면 곧바로 StopAllCoroutines() 이 호출되어 모든 코루틴이 종료됩니다.

참고 :
http://docs.unity3d.com/kr/current/Manual/Coroutines.html
http://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html


반응형
Posted by blueasa
, |


[링크] https://assetstore.unity.com/packages/tools/gui/emoji-extension-27267




it is a perfect Emoji solution that lets you make your animated Emoji Text easily.

Now Support emojis of IME 

Demo: Emoji_Extension

887 Emojis 

-Works with dynamic TTF fonts like Korean,Japanese, and Chinese
-Pixel perfect alignment
-the perfect emoticon and text solution for chat rooms
-Complete source code
-Supports the nativeSize of emoticonImage

Key Features:
* Supports animated images
* Supports dynamic fonts
* Scripting Interface and dynamic control of text and Emoticon objectss
* Fully supports richtext 
Formatting and Styling Options
* Dynamic font sizing
* Text Anchoring - The usual 9 positions
* Text Alignment - Left, Center, Right and Justified
* Character, Line and Paragraph spacing control
* Automatic Word-Wrapping


Mail me


Thank you.

반응형

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

[링크] iOSPlugin Sample  (0) 2019.01.29
[펌] Unity Excel Importer  (0) 2019.01.03
[펌] Background Worker for Unity3D  (0) 2018.06.01
[Link] UnityAppNameLocalizationForIOS  (0) 2018.03.27
[에셋] Anti-Cheat Toolkit  (0) 2018.03.06
Posted by blueasa
, |

개인적인 학습 목적으로 번역된 강좌글입니다. 

 

제 블로그로 링크가 되어 있는것은, 이쪽으로 번역글을 옮기는 과정이 번거롭고

비효율적이기 때문에 그렇고, 결코 블로그 홍보를 목적으로 하지 않습니다.

 

다른 곳에 퍼가신다면 일본어 원문 링크를 꼭 표기하여 주시기 바랍니다.

 

유니티 에디터에서 기본 제공되는 에디터 UI에서 더 나아가 직접 커스터마이즈하고

툴을 만들기 위해 필요한 정보들을 담고 있습니다.

 

원문

http://anchan828.github.io/editor-manual/web/index.htmlViewer

 

1장 에디터 확장에서 사용하는 폴더Viewer

2장 표준에서 사용할 수 있는 에디터 확장기능Viewer

3장 데이터 저장Viewer

4장 ScriptableObjectViewer

5장 SerializedObject에 대해서Viewer

6장 EditorGUIViewer

7장 EditorWindowViewer

8장 MenuItemViewer

9장 CustomEditorViewer

10장 PropertyDrawerViewer

11장 ProjectWindowUtilViewer

12장 Undo에 대해서Viewer

13장 다양한 이벤트의 콜백Viewer

14장 ReorderbleListViewer

15장 ScriptTemplatesViewer

16장 Gizmo(기즈모)Viewer

17장 Handle(핸들)Viewer

18장 HierarchySortViewer

19장 GUI를 직접 만들기Viewer

20장 OverwriterViewer

21장 파티클을 제어하기Viewer

22장 SpriteAnimationPreview(스프라이트 목록의 표시)Viewer

23장 SpriteAnimationPreviwe(스프라이트 애니메이션)Viewer

24장 씬 Asset에 스크립트를 AttachViewer

25장 시간을 제어하는 TimeControlViewer

26장 AssetDatabaseViewer

27장 HideFlagsViewer

28장 AssetPostprocessorViewer(완)



[출처] http://lab.gamecodi.com/board/zboard.php?id=GAMECODILAB_Lecture&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=hit&desc=asc&no=477

반응형
Posted by blueasa
, |


IntPtr.Size returns 8 when the app is 64 bit and 4 when the app is 32 bit. – Programmer Oct 9 '16 at 5:12


[출처] https://stackoverflow.com/questions/39939785/how-to-know-unity-build-application-is-32bit-or-64bit

반응형
Posted by blueasa
, |
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Tools : MonoBehaviour {

    //get local ip address
    public string getIP() {

        string IP = "";

        IP = Network.player.ipAddress; <--- this

        return IP;
    }

    //get all ip addresses in local network
    public List<string> getIPArray() {

        List<string> listIP = new List<string>();


        return listIP;
    }
}



[출처]

https://stackoverflow.com/questions/37951902/how-to-get-ip-addresses-of-all-devices-in-local-network-with-unity-unet-in-c


[참조] http://www.devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=29214

반응형
Posted by blueasa
, |

Unity에서 Xcode 출력 후 필요한 설정을 자동화하는 방법입니다. 
이번에는 잘 사용할 것 같은 것을 샘플 형식으로 정리했습니다.

■ 이용하는 기능 
Unity5에서 표준 이용할 수있게되었다 XcodeAPI을 이용 
Unity - Scripting API : PBXProject

■ 자동화 항목 
빌드 설정 편집 
프레임 워크의 추가 
컴파일 플래그의 설정 
· Info.plist 추가

■ 전 준비 
PostProcessBuildAttribute를 이용하여 빌드 후 메소드를 호출

using System.IO;
 using UnityEngine;
 using UnityEditor;
 using UnityEditor.iOS.Xcode;
 using UnityEditor.Callbacks;
 using System.Collections;

public  class XcodeSettingsPostProcesser
{
    [PostProcessBuildAttribute ( 0 )]
     public  static  void OnPostprocessBuild (BuildTarget buildTarget, string pathToBuiltProject)
    {
        // iOS 이외 플랫폼은 처리를하지 
        if (buildTarget! = BuildTarget.iOS) return ;

        // PBXProject 초기화 
        var projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj" ;
        PBXProject pbxProject = new PBXProject ();
        pbxProject.ReadFromFile (projectPath);
        string targetGuid = pbxProject.TargetGuidByName ( "Unity-iPhone" );
        
        // 여기에 자동화 처리 기술

        // 설정을 반영
        File.WriteAllText (projectPath, pbxProject.WriteToString ());
    }
}

■ 빌드 설정 편집

// 빌드 설정 추가 
pbxProject.AddBuildProperty (targetGuid, "OTHER_LDFLAGS" , "-all_load" );

// 빌드 설정 추가 
pbxProject.SetBuildProperty (targetGuid, "ENABLE_BITCODE" , "NO" );

// 빌드 설정 편집, 제 3 인수는 추가 설정 제 4 인수는 삭제 설정 
pbxProject.UpdateBuildProperty (targetGuid, "OTHER_LDFLAGS" , new  string [] { "-ObjC" }, new  string [] { "- weak_framework " });

■ 프레임 워크 추가

// 필수 프레임 워크의 추가 
pbxProject.AddFrameworkToProject (targetGuid, "Security.framework" , false );

// 옵션 프레임 워크의 추가 
pbxProject.AddFrameworkToProject (targetGuid, "SafariServices.framework" , true );

■ 컴파일 플래그 설정

// Keyboard.mm에 -fno-objc-arc를 설정 
var guid = pbxProject.FindFileGuidByProjectPath ( "Classes / UI / Keyboard.mm" );
var flags = pbxProject.GetCompileFlagsForFile (targetGuid, guid);
flags.Add ( "-fno-objc-arc" );
pbxProject.SetCompileFlagsForFile (targetGuid, guid, flags);

■ Info.plist 추가

// Plist 설정을위한 초기화 

var plistPath = Path.Combine (pathToBuiltProject, "Info.plist" );

var plist = new PlistDocument ();

plist.ReadFromFile (plistPath);



// 문자열의 설정 

plist.root.SetString ( "hogehogeId" , "dummyid" );



// URL 스키마 추가 var array = plist.root.CreateArray ( "CFBundleURLTypes");

var urlDict = array.AddDict ();

urlDict.SetString ( "CFBundleURLName" , "hogehogeName" );

var urlInnerArray = urlDict.CreateArray ( "CFBundleURLSchemes" );

urlInnerArray.AddString ( "hogehogeValue" );



// 설정을 반영

plist.WriteToFile (plistPath);

■ 정리 
Unity5되어 설정이 상당히 쉬워졌습니다

■ 코드 전체

using System.IO ;
using UnityEngine ;
using UnityEditor ;
using UnityEditor.iOS.Xcode ;
using UnityEditor.Callbacks ;
using System.Collections ;
public class XcodeSettingsPostProcesser
{
[PostProcessBuildAttribute ( 0 )
public static void OnPostprocessBuild ( BuildTarget buildTarget , string pathToBuiltProject )
{
// Stop processing if targe is NOT iOS
if (buildTarget! = BuildTarget.iOS)
return ;
// Initialize PbxProject
var projectPath = pathToBuiltProject + " /Unity-iPhone.xcodeproj/project.pbxproj " ;
PBXProject pbxProject = new PBXProject ();
pbxProject.ReadFromFile (projectPath);
string targetGuid = pbxProject.TargetGuidByName ( " Unity-iPhone " );
// Sample of adding build property
pbxProject.AddBuildProperty (targetGuid, " OTHER_LDFLAGS " , " -all_load " );
// Sample of setting build property
pbxProject.SetBuildProperty (targetGuid, " ENABLE_BITCODE " , " NO " );
// Sample of update build property
pbxProject.UpdateBuildProperty (targetGuid, " OTHER_LDFLAGS " , new string [] { " -ObjC " }, new string [] { " -weak_framework " });
// Sample of adding REQUIRED framwrok
pbxProject.AddFrameworkToProject (targetGuid, " Security.framework " , false );
// Sample of adding OPTIONAL framework
pbxProject.AddFrameworkToProject (targetGuid, " SafariServices.framework " , true );
// Sample of setting compile flags
var guid = pbxProject.FindFileGuidByProjectPath ( " Classes / UI / Keyboard.mm " );
var flags = pbxProject.GetCompileFlagsForFile (targetGuid, guid);
flags.Add ( " -fno-objc-arc " );
pbxProject.SetCompileFlagsForFile (targetGuid, guid, flags);
// Apply settings
File.WriteAllText (projectPath, pbxProject.WriteToString ());
// Samlpe of editing Info.plist
var plistPath = Path.Combine (pathToBuiltProject, " Info.plist " );
var plist = new PlistDocument ();
plist.ReadFromFile (plistPath);
// Add string setting
plist.root.SetString ( " hogehogeId " , " dummyid " );
// Add URL Scheme
var array = plist.root.CreateArray ( " CFBundleURLTypes " );
var urlDict = array.AddDict ();
urlDict.SetString ( " CFBundleURLName " , " hogehogeName " );
var urlInnerArray = urlDict.CreateArray ( " CFBundleURLSchemes " );
urlInnerArray.AddString ( " hogehogeValue " );

// Localizations [added blueasa / 2018-03-28] // need Language Code(ref:https://ko.wikipedia.org/wiki/ISO_639) var arrayLocalizations = plist.root.CreateArray("CFBundleLocalizations"); arrayLocalizations.AddString("en"); // 영어 arrayLocalizations.AddString("ko"); // 한국어

//arrayLocalizations.AddString("zh"); // 중국어

arrayLocalizations.AddString("zh_CN"); // 중국어(간체) : 중국 arrayLocalizations.AddString("zh_TW"); // 중국어(번체) : 대만 arrayLocalizations.AddString("ja"); // 일본어 arrayLocalizations.AddString("de"); // 독일어

// Apply editing settings to Info.plist
plist.WriteToFile (plistPath);
}
}

gist.github.com



[출처] http://smartgames.hatenablog.com/entry/2016/06/19/164052

반응형
Posted by blueasa
, |