Пример #1
0
        public static GTerrainGeneratedData GetTerrainGeneratedDataAsset(GTerrainData terrainData, string namePrefix = "Generated")
        {
            GTerrainGeneratedData generatedData = null;

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                string path      = AssetDatabase.GetAssetPath(terrainData);
                string directory = Path.GetDirectoryName(path);
                string filePath  = Path.Combine(directory, string.Format("{0}_{1}.asset", namePrefix, terrainData.Id));
                generatedData = AssetDatabase.LoadAssetAtPath <GTerrainGeneratedData>(filePath);
                if (generatedData == null)
                {
                    generatedData = ScriptableObject.CreateInstance <GTerrainGeneratedData>();
                    AssetDatabase.CreateAsset(generatedData, filePath);
                }
            }
            else
            {
                generatedData = ScriptableObject.CreateInstance <GTerrainGeneratedData>();
            }
#else
            generatedData = ScriptableObject.CreateInstance <GTerrainGeneratedData>();
#endif
            return(generatedData);
        }
        public void OnGUI()
        {
            Container = EditorGUILayout.ObjectField("Container", Container, typeof(GTerrainGeneratedData), false) as GTerrainGeneratedData;

            if (GUILayout.Button("Generate"))
            {
                Generate();
            }
        }
        private static void ClearGrassMeshes()
        {
            Object o = Selection.activeObject;

            if (o is GTerrainGeneratedData)
            {
                GTerrainGeneratedData data = o as GTerrainGeneratedData;
                data.Internal_DeleteMeshIf((k) => { return(k.StartsWith(GCommon.GRASS_MESH_NAME_PREFIX)); });
                AssetDatabase.Refresh();
            }
        }
 private void OnEnable()
 {
     instance = target as GTerrainGeneratedData;
 }