-
-
Save todorok1/ff8a1e59437696dc285742797464c28f to your computer and use it in GitHub Desktop.
エディタ上でパーリンノイズによる地形を生成するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 結合処理の進捗を表示します。 | |
int step = 0; | |
int maxStep = 6; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"メッシュを結合しています。", | |
(float) step / maxStep | |
); | |
// 作成したゲームオブジェクトにセットします。 | |
combinedMeshFilter.sharedMesh = new Mesh(); | |
combinedMeshFilter.sharedMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; | |
combinedMeshFilter.sharedMesh.CombineMeshes(combine); | |
combinedMeshFilter.sharedMesh.name = pair.Key; | |
step++; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"UVを生成しています。", | |
(float) step / maxStep | |
); | |
// 結合したメッシュでUV2を自動生成します。 | |
Unwrapping.GenerateSecondaryUVSet(combinedMeshFilter.sharedMesh); | |
step++; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"メッシュをアセットとして保存しています。", | |
(float) step / maxStep | |
); | |
// 結合したメッシュをアセットとして保存します。 | |
SaveMeshAsAsset(combinedMeshFilter.sharedMesh); | |
step++; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"結合したメッシュにマテリアルをセットしています。", | |
(float) step / maxStep | |
); | |
// 結合したメッシュにマテリアルをセットします。 | |
combinedMeshRenderer.sharedMaterial = matNameDict[pair.Key]; | |
step++; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"結合したメッシュをコライダーにセットしています。", | |
(float) step / maxStep | |
); | |
// 結合したメッシュをコライダーにセットします。 | |
MeshCollider meshCol = CheckComponent<MeshCollider>(obj); | |
meshCol.sharedMesh = combinedMeshFilter.sharedMesh; | |
step++; | |
EditorUtility.DisplayProgressBar( | |
"メッシュの結合中(" + pair.Key + ")", | |
"結合したメッシュを表示します。", | |
(float) step / maxStep | |
); | |
// 親オブジェクトを表示します。 | |
generator.fieldParent.gameObject.SetActive(true); | |
EditorUtility.ClearProgressBar(); | |
} | |
// 結合済みのオブジェクトを削除します。 | |
DestroyImmediate(combinedObjects); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment