void Awake() { m_terrainCreator = GameObject.FindObjectOfType <EPMPolyTerrainCreator>(); m_terrainCreator.Init(); m_terrainCreator.ImportData(); GameObject terrianRoot = m_terrainCreator.CreateTerrain(); for (int i = 0; i < terrianRoot.transform.childCount; i++) { terrianRoot.transform.GetChild(i).gameObject.AddComponent <MeshCollider>(); } }
private void DrawDataReadWrite() { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Data File:", GUILayout.Width(80)); TextAsset ta = (TextAsset)EditorGUILayout.ObjectField(m_creator.g_dataFile, typeof(TextAsset), false); if (m_creator.g_dataFile != ta) { m_creator.g_dataFile = ta; m_creator.g_dataFilePath = ta != null?AssetDatabase.GetAssetPath(ta) : ""; Debug.Log(m_creator.g_dataFilePath); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create Data")) { string path = m_creator.CreateData(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); m_creator.g_dataFile = (TextAsset)AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)); m_creator.g_dataFilePath = path; } if (GUILayout.Button("Import Data")) { if (EditorUtility.DisplayDialog("Caution!", "The imported data will replace current data.", "OK", "Cancel")) { if (m_creator.g_dataFile == null) { Debug.LogError("Data File is Null!!!!"); } else { m_creator.ImportData(); } } } if (GUILayout.Button("Save Data")) { m_creator.g_dataFilePath = ta != null?AssetDatabase.GetAssetPath(ta) : ""; m_creator.ExportData(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } EditorGUILayout.EndHorizontal(); }