2011. 11. 4. 01:26
[Dev/iOS]
// 파일의 존재 유무를 검사한다.
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 |
2011. 10. 20. 13:34
public static Mesh CreatePlaneMesh(string name, int widthSegments, int heightSegments, int width, int height, bool vertical) { int width_segments = Mathf.Clamp(widthSegments, 1, 254); int height_segments = Mathf.Clamp(heightSegments, 1, 254); Mesh m = new Mesh(); m.name = name; int hCount2 = width_segments + 1; int vCount2 = height_segments + 1; int numTriangles = width_segments * height_segments * 6; int numVertices = hCount2 * vCount2; Vector3[] vertices = new Vector3[numVertices]; Vector2[] uvs = new Vector2[numVertices]; Color[] colors = new Color[numVertices]; int[] triangles = new int[numTriangles]; int index = 0; float uvFactorX = 1.0f / width_segments; float uvFactorY = 1.0f / height_segments; float scaleX = width / width_segments; float scaleY = height / height_segments; float halfWidth = width / 2.0f; float halfHeight = height / 2.0f; float realX = -halfWidth; float realY = -halfHeight; for (float y = 0.0f; y < vCount2; y++) { for (float x = 0.0f; x < hCount2; x++) { if (vertical) { vertices[index] = new Vector3(x * scaleX + realX, y * scaleY + realY, 0.0f); } else { vertices[index] = new Vector3(x * scaleX + realX, 0.0f, y * scaleY + realY); } uvs[index++] = new Vector2(x * uvFactorX, y * uvFactorY); } } index = 0; for (int y = 0; y < height_segments; y++) { for (int x = 0; x < width_segments; x++) { triangles[index] = (y * hCount2) + x; triangles[index + 1] = ((y + 1) * hCount2) + x; triangles[index + 2] = (y * hCount2) + x + 1; triangles[index + 3] = ((y + 1) * hCount2) + x; triangles[index + 4] = ((y + 1) * hCount2) + x + 1; triangles[index + 5] = (y * hCount2) + x + 1; index += 6; } } m.vertices = vertices; m.uv = uvs; m.colors = colors; m.triangles = triangles; m.RecalculateNormals(); return m; }
'Dev > Unity3D' 카테고리의 다른 글
Unity, Audio, and Memory (0) | 2012.01.25 |
---|---|
unity3d data path! (0) | 2011.12.14 |
Unity3D Inspector object 선택후 일괄 처리 (0) | 2011.07.02 |
Unity3D 에서 XML Serialize Encrypt/Decrypt. (3) | 2011.04.22 |
FindObjectOfType fail. (0) | 2010.12.14 |
2011. 7. 27. 14:19
Eclipse 에서 Android Library 로 다른 프로젝트 추가해서 사용할 경우
Eclipse 에서 생성한 R.java 와 unity 에서 생성한 R.java 의 id 들이 틀려서 리소스들이 꼬인다..
이럴땐 http://limchaeng.tistory.com/24 에서 merge 한 resource 들을 가지고
Ant 에서 수동으로 R.java(패키지별로) 만들고 그걸 이용해서 Ant 에서 compile 한후 jar 로 묶고
unity 에서 사용하면 된다.
*R.java 만든는 Ant code
<property name="aapt" location="${sdk.dir}/platforms/${target}/tools/aapt.exe" />
<target name="build-aapt" depends="copy-resource">
Eclipse 에서 생성한 R.java 와 unity 에서 생성한 R.java 의 id 들이 틀려서 리소스들이 꼬인다..
이럴땐 http://limchaeng.tistory.com/24 에서 merge 한 resource 들을 가지고
Ant 에서 수동으로 R.java(패키지별로) 만들고 그걸 이용해서 Ant 에서 compile 한후 jar 로 묶고
unity 에서 사용하면 된다.
*R.java 만든는 Ant code
<property name="aapt" location="${sdk.dir}/platforms/${target}/tools/aapt.exe" />
<target name="build-aapt" depends="copy-resource">
<exec executable="${aapt}" failonerror="true">
<arg value="package" />
<arg value="-m" />
<arg value="-J" />
<arg value="${output.gen.absolute.dir}" />
<arg value="-M" />
<arg value="AndroidManifest.xml" />
<arg value="-S" />
<arg value="${unity3dresource.absolute.dir}" />
<arg value="-I" />
<arg value="${android-jar}" />
</exec>
</target>
*compile code
<target name="build-class" depends="build-aapt" >
<echo>Build Classes</echo>
<javac target="1.6" extdirs=""
destdir="${output.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
includeantruntime="false">
<src path="${output.gen.absolute.dir}" />
<src path="${source.absolute.dir}" />
<!-- 링크된 라이브러리들의 소스도 컴파일해준다. -->
<src path="${android.library.reference.1}/src" />
<src path="${android.library.reference.2}/src" />
<src path="${android.library.reference.3}/src" />
<classpath>
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${twitter.libs.absolute.dir}" includes="*.jar" />
<!-- ************************************************** -->
<!-- 여기에 외부 라이브러리들을 넣어준다. -->
<fileset dir="${unity3dlibrary.absolute.dir}" includes="*.jar" />
<!-- ************************************************** -->
</classpath>
</javac>
</target>
<arg value="package" />
<arg value="-m" />
<arg value="-J" />
<arg value="${output.gen.absolute.dir}" />
<arg value="-M" />
<arg value="AndroidManifest.xml" />
<arg value="-S" />
<arg value="${unity3dresource.absolute.dir}" />
<arg value="-I" />
<arg value="${android-jar}" />
</exec>
</target>
*compile code
<target name="build-class" depends="build-aapt" >
<echo>Build Classes</echo>
<javac target="1.6" extdirs=""
destdir="${output.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
includeantruntime="false">
<src path="${output.gen.absolute.dir}" />
<src path="${source.absolute.dir}" />
<!-- 링크된 라이브러리들의 소스도 컴파일해준다. -->
<src path="${android.library.reference.1}/src" />
<src path="${android.library.reference.2}/src" />
<src path="${android.library.reference.3}/src" />
<classpath>
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${twitter.libs.absolute.dir}" includes="*.jar" />
<!-- ************************************************** -->
<!-- 여기에 외부 라이브러리들을 넣어준다. -->
<fileset dir="${unity3dlibrary.absolute.dir}" includes="*.jar" />
<!-- ************************************************** -->
</classpath>
</javac>
</target>
'Dev > Android' 카테고리의 다른 글
Unity3d Android Plugin Guide - UnityPlayer 상속 받아 사용하기. (0) | 2011.07.19 |
---|---|
Unity3d Android Plugin Guide - Resource Merge (5) | 2011.07.19 |
Unity3d Android Plugin Guide - Main Activity 변경하기. (0) | 2011.07.19 |