12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using UnityEngine;
- using UnityEngine.Assertions;
- using UnityEditor;
- using System;
- using System.IO;
- using System.Collections;
- using System.Collections.Generic;
- namespace VoxelImporter
- {
- public class VoxelChunksObjectChunkCore
- {
- public VoxelChunksObjectChunkCore(VoxelChunksObjectChunk target)
- {
- voxelChunk = target;
- voxelObject = target.transform.parent.GetComponent<VoxelChunksObject>();
- objectCore = new VoxelChunksObjectCore(voxelObject);
- }
- public VoxelChunksObjectChunk voxelChunk { get; protected set; }
- public VoxelChunksObject voxelObject { get; protected set; }
- public VoxelChunksObjectCore objectCore { get; protected set; }
- public void Initialize()
- {
- voxelChunk.EditorInitialize();
- }
-
- #region CreateVoxel
- public string GetDefaultPath()
- {
- var path = objectCore.GetDefaultPath();
- if (voxelObject != null)
- {
- if (voxelObject.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- if (voxelChunk.mesh != null && AssetDatabase.Contains(voxelChunk.mesh))
- {
- var assetPath = AssetDatabase.GetAssetPath(voxelChunk.mesh);
- if (!string.IsNullOrEmpty(assetPath))
- {
- path = Path.GetDirectoryName(assetPath);
- }
- }
- }
- else if (voxelObject.materialMode == VoxelChunksObject.MaterialMode.Individual)
- {
- if (voxelChunk.mesh != null && AssetDatabase.Contains(voxelChunk.mesh))
- {
- var assetPath = AssetDatabase.GetAssetPath(voxelChunk.mesh);
- if (!string.IsNullOrEmpty(assetPath))
- {
- path = Path.GetDirectoryName(assetPath);
- }
- }
- if (voxelChunk.materials != null)
- {
- for (int i = 0; i < voxelChunk.materials.Count; i++)
- {
- if (AssetDatabase.Contains(voxelChunk.materials[i]))
- {
- var assetPath = AssetDatabase.GetAssetPath(voxelChunk.materials[i]);
- if (!string.IsNullOrEmpty(assetPath))
- {
- path = Path.GetDirectoryName(assetPath);
- }
- }
- }
- }
- if (voxelChunk.atlasTexture != null && AssetDatabase.Contains(voxelChunk.atlasTexture))
- {
- var assetPath = AssetDatabase.GetAssetPath(voxelChunk.atlasTexture);
- if (!string.IsNullOrEmpty(assetPath))
- {
- path = Path.GetDirectoryName(assetPath);
- }
- }
- }
- else
- {
- Assert.IsTrue(false);
- }
- }
- return path;
- }
- #endregion
- }
- }
|