BLOG main image
for our next (37)
Dev (32)
Mac (1)
Windows (2)
FreeTalk (1)
Shell (1)
Private (0)
Visitors up to today!
Today hit, Yesterday hit
daisy rss
tistory 티스토리 가입하기!
'Dev'에 해당되는 글 32건
2021. 12. 14. 10:45

TestFlight 에 올릴때

버전(CFBundleShortVersionString)이 올라가면 빌드넘버(CFBundleVersion)는 다시 처음부터 시작됨.

 

예)

- XCode 13 의 manageAppVersionAndBuildNumber 때문에 내부에서 관리하던 빌드넘버가 꼬여버림

-- 1.xx.xx => 2 로 되어 버림

- 강제로 내부에서 관리하는 빌드넘버에 +1 을 해서 사용 (2.xx 로)

 

버전이 올라가면서 1.xx 로 내려가도 문제 없음

 

2021. 11. 8. 15:04

IronSource, unity 2020.3.21f1 기준, android

  • 리워드 광고 비디오 보기 후 이전에 광고 볼때의 화면이 나타나고 멈추어 있음
    • UnityPlayerActivity resume 이 안되는것 같음
    • 이것저것 다해봤지만(2019 -> 2020 업데이트등..) 안됨
    • 원인은 광고 activity 가 나오기 전에 Handheld.StartActivityIndicator(); 로 인디게이터 돌려주는게 원인.
      • 제거하니 문제 발생 안함.
      • 광고activity 가 종료되면서 뭔가 activtiy 가 꼬이는듯.
2021. 11. 6. 21:50

Graphics Setting 의 Always included shaders 에 아래 포함

Hidden/VideoDecode

Hidden/VideoDecodeAndroid


Unity 2020.3.21f1 기준으로

Video 항목이 새로 생귐 = Always include

  • Always included shaders 에 안해도 될것 같지만 귀찮아서 안해봄

batchmode 에서는 여전히 안됨

  • -nographics 옵션을 뺴고 하면 잘됨.(MAC 빌드 기준)
2012. 6. 18. 19:14

- 서버에서 다운받는 데이터를 아직 서버가 마련되지 않아 파일형식으로 유니티에 포함시킬때 사용.


- Assets/StreamingAssets/ 폴더에 넣어두면 된다.


- 위치

Standalone

- path = = Application.dataPath + "/StreamingAssets";


iOS

- path = Application.dataPath + "/Raw";


Android

- path = "jar:file://" + Application.dataPath + "!/assets/";

- WWW 는 사용하지 못한다..jar 를 열수 있는 다른 것을 사용한 후에 사용가능.


2012. 6. 5. 01:04

* Memory 해제 관련...

*. Prefab 을 public GameObject variable 로 연결하면 1개가 살아있다...
     - Resource 로 옮기고 Resource.Load 후 Instantiate 해준다음 Resource.UnloadUnusedAsset으로 로드했던 prefab을 해제시키자.


* Texture

- WWW 혹은 다른곳에서 load 한 texture 들은 사용하지 않을때 DestroyImmediate 로 꼭 해제시켜줘야 한다. DestroyImmediate 해주면 바로 memory 에서 해제된다.


*. GameObject Destroy 는 memory 를 바로 해제시키지 않는다.
     - Resource.UnloadUnusedAssets 를 해야 memory 에서 해제된다.
     - GameObject 를 DestroyImmediate 해도 포함되있는 Texture, material, 등은 memory에서 해제되지 않는다.

*. Load 한 Texture 들을 Member 로 가지고 있으면 GameObject Destroy 시 memory 해제 안된다.
     - Texture 는 개별 DestroyImmediate 하여 바로바로 해제하자.

2012. 6. 5. 00:45

GameObject.active = true;

  • StartCoroutine : OK
  • Coroutine Method : OK
  • StopAllCoroutine : OK
  • Invoke : OK
  • InvokeRepeating : OK
  • CancelInvoke : OK


GameObject.active = false;

  • StartCoroutine : Error
  • Coroutine Method : Stop (active 상태에서 돌고 있는 상태였다면 정지된다.)
  • StopAllCoroutine : OK
  • Invoke : OK
  • InvokeRepeating : OK
  • CancelInvoke : OK

** 결론

  • StartCoroutine 으로 코루틴 메소드를 열심히 돌리다가 해당 GameObject 의 active 가 꺼지면 돌던 코루틴 메소드는 정지되고 다시 active 가 켜지더라도 재실행되지 않는다.....
  • 코루틴을 많이 사용하는 로직(Async 로 돌리는 함수들..(WWW, ... 같은...))에서는 꼭 염두해 두어야 한다..
  • OnDisable() {} 에서 관련 처리를 해 주는게 좋다.
  • Invoke 관련은 GameObject 의 active 유무랑 관계없이 돌아간다..


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

StreamingAsset 활용하기.  (0) 2012.06.18
Texture, Resource.... and Memory!!  (1) 2012.06.05
Unity, Audio, and Memory  (0) 2012.01.25
unity3d data path!  (0) 2011.12.14
Unity3D Mesh Create Code  (0) 2011.10.20
2012. 5. 10. 13:40

- (NSString *)getModel {

    size_t size;

    sysctlbyname("hw.machine", NULL, &size, NULL, 0);

    char *model = malloc(size);

    sysctlbyname("hw.machine", model, &size, NULL, 0);

    NSString *sDeviceModel = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];

    free(model);                              

    if ([sDeviceModel isEqual:@"i386"])      return @"Simulator"//iPhone Simulator

    if ([sDeviceModel isEqual:@"iPhone1,1"]) return @"iPhone1G";   //iPhone 1G

    if ([sDeviceModel isEqual:@"iPhone1,2"]) return @"iPhone3G";   //iPhone 3G

    if ([sDeviceModel isEqual:@"iPhone2,1"]) return @"iPhone3GS"//iPhone 3GS

    if ([sDeviceModel isEqual:@"iPhone3,1"]) return @"iPhone4"//iPhone 4 - AT&T

    if ([sDeviceModel isEqual:@"iPhone3,2"]) return @"iPhone4"//iPhone 4 - Other carrier

    if ([sDeviceModel isEqual:@"iPhone3,3"]) return @"iPhone4";    //iPhone 4 - Verizone

    if ([sDeviceModel isEqual:@"iPhone4,1"]) return @"iPhone4S";   //iPhone 4S

    if ([sDeviceModel isEqual:@"iPod1,1"])   return @"iPod1stGen"; //iPod Touch 1G

    if ([sDeviceModel isEqual:@"iPod2,1"])   return @"iPod2ndGen"; //iPod Touch 2G

    if ([sDeviceModel isEqual:@"iPod3,1"])   return @"iPod3rdGen"; //iPod Touch 3G

    if ([sDeviceModel isEqual:@"iPod4,1"])   return @"iPod4thGen"; //iPod Touch 4G

    if ([sDeviceModel isEqual:@"iPad1,1"])   return @"iPadWiFi";   //iPad Wifi

    if ([sDeviceModel isEqual:@"iPad1,2"])   return @"iPad3G";     //iPad 3G

    if ([sDeviceModel isEqual:@"iPad2,1"])   return @"iPad2WiFi";      //iPad 2 (WiFi)

    if ([sDeviceModel isEqual:@"iPad2,2"])   return @"iPad2GSM";      //iPad 2 (GSM)

    if ([sDeviceModel isEqual:@"iPad2,3"])   return @"iPad2CDMA";      //iPad 2 (CDMA)

    if ([sDeviceModel isEqual:@"iPad3,1"])   return @"iPad3GWiFi";      //iPad 3G (WiFi)

    if ([sDeviceModel isEqual:@"iPad3,2"])   return @"iPad3G4G";      //iPad 3G (4G)

    if ([sDeviceModel isEqual:@"iPad3,3"])   return @"iPad3G4G";      //iPad 3G (4G)

    

    NSString *aux = [[sDeviceModel componentsSeparatedByString:@","] objectAtIndex:0];

    

    //If a newer version exist

    if ([aux rangeOfString:@"iPhone"].location!=NSNotFound) {

        int version = [[aux stringByReplacingOccurrencesOfString:@"iPhone" withString:@""] intValue];

        if (version == 3) return @"iPhone4";

            if (version >= 4) return @"iPhone4s";

        

    }

    if ([aux rangeOfString:@"iPod"].location!=NSNotFound) {

        int version = [[aux stringByReplacingOccurrencesOfString:@"iPod" withString:@""] intValue];

        if (version >=4) return @"iPod4thGen";

    }

    if ([aux rangeOfString:@"iPad"].location!=NSNotFound) {

        int version = [[aux stringByReplacingOccurrencesOfString:@"iPad" withString:@""] intValue];

        if (version ==1) return @"iPad3G";

        if (version >=2) return @"iPad2";

    }

    //If none was found, send the original string

    return sDeviceModel;

}


@end


2012. 1. 25. 15:26

The project I am currently programming audio for targets low end machines. I spent many many hours google and forum searching trying to find definitive answers to how Audio works, especially when related to how it consumes memory and how I can release that memory when the audio is no longer needed. Hopefully the following information will save you loads of time.

Hierarchy and Audio Memory
Any AudioClips that are referenced in the hierarchy of a scene will be loaded in to memory when the scene gets loaded. Keep this in mind if you have a large audio library and are throwing a huge prefab of all your sounds into the scene hierarchy (nom nom memory nom nom). The only way to avoid this is to load audio dynamically with scripts.

Objects and Garbage Collection
Unity keeps track of anything you create that extends from their Object class. That means a couple things. If you do reference one of those objects and set that reference to null, the garbage collector WILL NOT pick it up. The reason for this is that the object still has references in Unity. If you want to release memory for Unity Objects you must call Destroy and pass the object as a parameter. Why is this important? AudioClips extend from Object. Hence setting them to null will not release them from memory.

Resources.Load
Resources.Load creates an object in memory and returns a reference to it. That object is actually the physical asset in your library which is loaded from a .asset file. This file is created when you build.

If you call Destroy on the resource inside the editor you will get a warning that it will delete the actual asset itself. The editor protects you against doing this, but the build will actually delete the asset (but not permanently – more testing required to confirm full behavior). DestroyImmediate will destroy the asset without warning, so be careful when using it. If you are in the editor and that happens you will have to reimport your asset.

The only way to release the memory held by the resource is to call Resources.UnloadUnusedAssets(). This process isn’t the fastest, so doing it during an Update can hurt your performance.

One of the strongest advantages to using Resources.Load is that multiple copies of your AudioClip do not increase your memory size. You can play your clip with 8 different sources and all 8 will play individually and fully layered without adding more AudioClips to memory. The main disadvantage is that if you need to free up memory that an asset occupies, you really can’t be specific and must run the bulky Resources.UnloadUnusedAssets function.

Note that you cannot instantiate an asset object in the build. The editor will allow you to do this however, which is unfortunately very misleading.

Asset Bundles
Asset bundles behave exactly like Resources.Load. Think of them as a way to fragment the .asset file into .unity3d files. This is especially powerful for the web player since you can prioritize which assets get downloaded by the user. Asset bundles need to be loaded with the WWW class. Just like Resources.Load, you will receive an actual asset so destroying them to release memory is not an option. You can however be more specific when unloading them compared to Resources.UnloadUnusedAssets.

WWW
WWW.audioClip does not return a reference to an AudioClip. In fact, it creates an entirely new clip object. The documentation does state that the returned AudioClip is “generated”, but let’s explore the implications of that statement. Note that WWW.GetAudioClip() does the exact same thing except is allows you to specify whether the sound is 3D or 2D.

You can see that new clips are generated by running the following script:


WWW www = new WWW(urltosound);
AudioClip clip;
 
for (int i = 0; i < 20; i++)
{
    clip = www.audioClip;
}
Debug.Log("AudioClips " + FindObjectsOfTypeAll(typeof(AudioClip)).Length);

You will see that 20 AudioClips are created. That creates a huge problem. These clips will reside in memory until they are destroyed. You can do that manually if you have a reference or if you don’t, by calling Resources.UnloadUnusedAssets(). Note that UnloadUnusedAssets will look through the entire game hierarchy and scripts to make sure there are no references to the resources. This IS slow so avoid putting in places where it will be called often (Update for example).

Based on testing 3.3.0f4 and recent forum postings, you can not stream audio in the standalone player with the WWW class using WWW.GetAudioClip() and WWW.audioClip. Both return unplayable sounds until the file has been fully loaded. You can however stream Ogg files using WWW.oggVorbis (which sadly is not documented).

WWW variables DO take up memory space. Since they do not extend from a Unity Object, you can release them from memory by setting them to null.

Unlike Resources.Load, AudioClips you get from WWW do not automatically layer. In other words, if you play the clip with 8 sources, you will only hear one instance of your AudioClip (restarts to the beginning with each call to Play). So for each instance you want, you must create a new clip for it. You can do this with Instantiate(), but with one caveat: PlayOneShot() will return a channel error. That means that you must manually handle the creation and destruction of your AudioSources when using sounds created from WWW. If you do wish to use PlayOneShot(), you can instead create your copies by keeping the WWW in memory and calling WWW.audioClip or WWW.GetAudioClip().

PlayOneShot
PlayOneShot automatically creates an AudioSource for you and destroys it. However, what it does not do is destroy the AudioClip that you pass it. Hence you could get a huge memory leak if you pass it www.audioClip since it will create an un-referenced AudioClip object each time you PlayOneShot.

AudioSource
AudioSource.clip is a reference to an AudioClip. So you can destroy the AudioClip by running Destroy(AudioSource.clip). If you have another reference to the destroyed clip it will become null. Destroying an AudioSource DOES NOT destroy the AudioClip it references. This is significant if you are using AudioSources to store you AudioClips. You must destroy the AudioClip before you destroy the AudioSource if you want all related memory to get released.

Original : http://www.alexander-fisher.com/?p=351


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

Texture, Resource.... and Memory!!  (1) 2012.06.05
GameObject active 여부와 Coroutine / Invoke...  (1) 2012.06.05
unity3d data path!  (0) 2011.12.14
Unity3D Mesh Create Code  (0) 2011.10.20
Unity3D Inspector object 선택후 일괄 처리  (0) 2011.07.02
2011. 12. 14. 10:37
// ** Editor
- Application.dataPath /*project*/Assets

// ** iPhone device
- Application.dataPath /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Assets

- Application.persistentDataPath : /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents

- Application.temporaryCachePath : /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Library/Caches
 
- iPhpone Simulator Path : /Users/<Name>/Library/Application Support/iPhone Simulator/4.1/Applications/<GUID>/
 
// ** Android
- Application.dataPath /mnt/asec/com.xxx.xxx/pkg.apk
- Application.persistentDataPath /data/data/com.xxx.xxx/files/
- Application.temporaryCachePath /data/data/com.xxx.xxx/cache/
* sdcard 사용시.
- Application.persistentDataPath /mnt/sdcard/Android/data/com.xxx.xxx/files/
- Application.temporaryCachePath /mnt/sdcard/Android/data/com.xxx.xxx/cache/
2011. 11. 4. 01:26
// 파일의 존재 유무를 검사한다.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"BountyHunter.sqlite"];
// 파일 존재 유무에 따라 없으면 복사하고 있으면 복사하지 않는다.
BOOL dbExists = [fileManager  fileExistsAtPath:[storeURL path]];
if ( !dbExists )
{
  // 파일이 없는 경우.
  NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"BountyHunter.sqlite"];
  NSError *error = nil;
  BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:[storeURL path] error:&error];
  if ( !success )
  NSAssert1(0, @"Failed to create writable database file with message '%@'", [error localizedDescription]);
}
  Copyright: http://teddevtalk.blogger.com 이 글은 저작자의 허락 없이 변경하거나 상업적인 목적으로 인용할 수 없습니다. 인용시 출처와 링크를 표기하여 주시기 바랍니다. 

'Dev > iOS' 카테고리의 다른 글

CFBundleVersion  (1) 2021.12.14
iOS Model 정보!  (0) 2012.05.10
In App Purchase : invalidProductIdentifiers  (1) 2011.01.14
App 안에 Store Link 달기  (0) 2011.01.10
[Xcode] Build and Archive  (1) 2010.12.22