Move Files, remove 2D world gen

This commit is contained in:
2026-04-07 03:10:03 +07:00
parent 55cea836ed
commit 9675b7b31d
121 changed files with 77 additions and 6922 deletions
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 36d3f51da8e6a734797f93d32dd6a32a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1fadae35d0dcad7478e9716ea65762b4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 41de4e97ebade7a4a8e018f68bde560e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 85e740c52ab3e0a488b0109bd39c9e86
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
-62
View File
@@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
namespace Project.Tasks.Editor
{
internal static class TaskBoardConstants
{
public const int MinutesPerHour = 60;
public const int HoursPerDay = 8;
public const int MinutesPerDay = HoursPerDay * MinutesPerHour;
public const int WorkDaysPerWeek = 5;
public const int MinutesPerWeek = WorkDaysPerWeek * MinutesPerDay;
public static readonly string[] Statuses = { "BackLog", "ToDo", "InProgress", "Review", "Done" };
public static readonly string[] Priorities = { "Lowest", "Low", "Medium", "High", "Highest" };
}
[Serializable]
internal sealed class TaskRecord
{
public string Id;
public string Title;
public string Status;
public string Priority;
public string Area;
public string Owner;
public string Created;
public string Updated;
public string ExecutionTime;
public string RelativeFilePath;
public string AbsoluteFilePath;
public string IndexSummary;
public string TaskSummary;
public int EstimatedMinutes = -1;
public string Header;
public string Why;
public string ExpectedOutcome;
public string CurrentContext;
public string AcceptanceCriteria;
public string Verification;
public string Risks;
public string HumanDecisions;
public string DecisionLog;
public string HandoffNotes;
public bool FileExists;
public bool DetailsLoaded;
public int IndexLineNumber = -1;
public readonly List<string> ValidationMessages = new List<string>();
}
[Serializable]
internal sealed class TaskBoardData
{
public string ProjectRoot;
public string TasksDirectory;
public string IndexPath;
public string OwnersConfigPath;
public readonly List<TaskRecord> Tasks = new List<TaskRecord>();
public readonly List<string> Warnings = new List<string>();
public readonly List<string> OwnerPresets = new List<string>();
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 4716897eb71185742ad590f2a59df8e3
-20
View File
@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: acfa62607cc78b8499e371559154647f, type: 3}
m_Name: TaskBoardOwners
m_EditorClassIdentifier: Assembly-CSharp-Editor::Project.Tasks.Editor.TaskBoardOwnersConfig
owners:
- unassigned
- pretty_kotik
- gitenax
- abysscion
- Firinor
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 84c93775036fa9242b5e5e4397f96d04
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,10 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
namespace Project.Tasks.Editor
{
internal sealed class TaskBoardOwnersConfig : ScriptableObject
{
public List<string> owners = new List<string> { "unassigned" };
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: acfa62607cc78b8499e371559154647f
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: da90adbe6fa0acb429453d3550e18961
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 5203f967846df5f43baaa0a3ba2e2d5b
@@ -1,75 +0,0 @@
namespace InfiniteWorld.Editor
{
internal static class WorldAutotileEditorLabels
{
public static string GetShapeLabel(AutoTileShape shape)
{
switch (shape)
{
case AutoTileShape.Center:
return "Center";
case AutoTileShape.Top:
return "Top";
case AutoTileShape.Right:
return "Right";
case AutoTileShape.Bottom:
return "Bottom";
case AutoTileShape.Left:
return "Left";
case AutoTileShape.OuterTopLeft:
return "Outer Top Left";
case AutoTileShape.OuterTopRight:
return "Outer Top Right";
case AutoTileShape.OuterBottomRight:
return "Outer Bottom Right";
case AutoTileShape.OuterBottomLeft:
return "Outer Bottom Left";
case AutoTileShape.InnerTopLeft:
return "Inner Top Left";
case AutoTileShape.InnerTopRight:
return "Inner Top Right";
case AutoTileShape.InnerBottomRight:
return "Inner Bottom Right";
case AutoTileShape.InnerBottomLeft:
return "Inner Bottom Left";
default:
return shape.ToString();
}
}
public static string GetPropertyName(AutoTileShape shape)
{
switch (shape)
{
case AutoTileShape.Center:
return "center";
case AutoTileShape.Top:
return "top";
case AutoTileShape.Right:
return "right";
case AutoTileShape.Bottom:
return "bottom";
case AutoTileShape.Left:
return "left";
case AutoTileShape.OuterTopLeft:
return "outerTopLeft";
case AutoTileShape.OuterTopRight:
return "outerTopRight";
case AutoTileShape.OuterBottomRight:
return "outerBottomRight";
case AutoTileShape.OuterBottomLeft:
return "outerBottomLeft";
case AutoTileShape.InnerTopLeft:
return "innerTopLeft";
case AutoTileShape.InnerTopRight:
return "innerTopRight";
case AutoTileShape.InnerBottomRight:
return "innerBottomRight";
case AutoTileShape.InnerBottomLeft:
return "innerBottomLeft";
default:
return string.Empty;
}
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 7f9b9a3347cfc82428971840cb651f99
@@ -1,642 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Tilemaps;
namespace InfiniteWorld.Editor
{
[InitializeOnLoad]
public static class WorldAutotileProfilePipeline
{
private const string AuthoringLayoutFolder = "Assets/Editor/Generated/WorldAutotileAuthoring";
private static readonly AutoTileShape[] WallShapeOrder =
{
AutoTileShape.OuterTopLeft,
AutoTileShape.Top,
AutoTileShape.OuterTopRight,
AutoTileShape.Left,
AutoTileShape.Center,
AutoTileShape.Right,
AutoTileShape.OuterBottomLeft,
AutoTileShape.Bottom,
AutoTileShape.OuterBottomRight,
AutoTileShape.InnerTopLeft,
AutoTileShape.InnerTopRight,
AutoTileShape.InnerBottomLeft,
AutoTileShape.InnerBottomRight
};
private static readonly Vector3Int[] WallShapePositions =
{
new Vector3Int(0, 4, 0),
new Vector3Int(1, 4, 0),
new Vector3Int(2, 4, 0),
new Vector3Int(0, 3, 0),
new Vector3Int(1, 3, 0),
new Vector3Int(2, 3, 0),
new Vector3Int(0, 2, 0),
new Vector3Int(1, 2, 0),
new Vector3Int(2, 2, 0),
new Vector3Int(0, 1, 0),
new Vector3Int(2, 1, 0),
new Vector3Int(0, 0, 0),
new Vector3Int(2, 0, 0)
};
private static readonly HashSet<string> PendingProfilePaths = new HashSet<string>();
private static readonly MethodInfo SetIconForObjectMethod = typeof(EditorGUIUtility).GetMethod("SetIconForObject", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
private static bool refreshQueued;
static WorldAutotileProfilePipeline()
{
AssemblyReloadEvents.beforeAssemblyReload += ClearQueue;
EditorApplication.projectChanged += QueueAllProfilesRefresh;
}
public static void QueueProfileRefresh(WorldAutotileProfile profile)
{
if (profile == null)
{
return;
}
string path = AssetDatabase.GetAssetPath(profile);
if (string.IsNullOrEmpty(path))
{
return;
}
PendingProfilePaths.Add(path);
if (refreshQueued)
{
return;
}
refreshQueued = true;
EditorApplication.delayCall += ProcessPendingProfiles;
}
public static string GetAuthoringLayoutPath(WorldAutotileProfile profile)
{
return AuthoringLayoutFolder + "/" + profile.name + "_AuthoringLayout.prefab";
}
public static GameObject LoadAuthoringLayoutAsset(WorldAutotileProfile profile)
{
if (profile == null)
{
return null;
}
return AssetDatabase.LoadAssetAtPath<GameObject>(GetAuthoringLayoutPath(profile));
}
public static void GenerateAuthoringLayout(WorldAutotileProfile profile, bool pingAsset = true)
{
if (profile == null)
{
return;
}
EnsureFolderExists(AuthoringLayoutFolder);
string path = GetAuthoringLayoutPath(profile);
DeleteExistingAuthoringLayout(path);
GameObject root = BuildAuthoringLayoutRoot(profile);
PrefabUtility.SaveAsPrefabAsset(root, path);
Object.DestroyImmediate(root);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
if (!pingAsset)
{
return;
}
GameObject layout = AssetDatabase.LoadAssetAtPath<GameObject>(path);
if (layout != null)
{
EditorGUIUtility.PingObject(layout);
Selection.activeObject = layout;
}
}
public static bool BuildProfileFromAuthoringLayout(WorldAutotileProfile profile, bool pingProfile = true)
{
if (profile == null)
{
return false;
}
string path = GetAuthoringLayoutPath(profile);
if (!System.IO.File.Exists(path))
{
Debug.LogWarning($"Authoring layout was not found for profile '{profile.name}' at '{path}'.");
return false;
}
GameObject prefabRoot = PrefabUtility.LoadPrefabContents(path);
try
{
Undo.RecordObject(profile, "Build World Autotile Profile From Layout");
if (!TryBuildProfileFromLayout(prefabRoot, profile, out string error))
{
Debug.LogError(error);
return false;
}
EditorUtility.SetDirty(profile);
AssetDatabase.SaveAssets();
if (pingProfile)
{
EditorGUIUtility.PingObject(profile);
Selection.activeObject = profile;
}
if (profile.autoRefreshGeneratedWorld && Application.isPlaying)
{
RefreshActiveGenerators(profile);
}
return true;
}
finally
{
PrefabUtility.UnloadPrefabContents(prefabRoot);
}
}
private static void ProcessPendingProfiles()
{
refreshQueued = false;
if (EditorApplication.isCompiling || EditorApplication.isUpdating)
{
if (PendingProfilePaths.Count > 0)
{
refreshQueued = true;
EditorApplication.delayCall += ProcessPendingProfiles;
}
return;
}
string[] paths = new string[PendingProfilePaths.Count];
PendingProfilePaths.CopyTo(paths);
PendingProfilePaths.Clear();
for (int i = 0; i < paths.Length; i++)
{
WorldAutotileProfile profile = AssetDatabase.LoadAssetAtPath<WorldAutotileProfile>(paths[i]);
if (profile == null || !profile.autoUpdatePaletteLayout)
{
continue;
}
if (LoadAuthoringLayoutAsset(profile) == null)
{
GenerateAuthoringLayout(profile, false);
}
}
}
private static GameObject BuildAuthoringLayoutRoot(WorldAutotileProfile profile)
{
GameObject root = new GameObject(profile.name + "_AuthoringLayout", typeof(Grid), typeof(WorldAutotileAuthoringRoot));
WorldAutotileAuthoringRoot rootMarker = root.GetComponent<WorldAutotileAuthoringRoot>();
rootMarker.profile = profile;
Transform guidesRoot = new GameObject("Guides").transform;
guidesRoot.SetParent(root.transform, false);
CreateGuideLabel(guidesRoot, "Workflow Label", new Vector3(5f, 6.6f, 0f), "sv_label_0");
Transform wallSection = CreateSection(root.transform, "WallShapes", WorldAutotileAuthoringSectionType.WallShapes, new Vector3(0f, 0f, 0f), new Vector2Int(3, 5));
Tilemap wallBackground = CreateTilemap(wallSection, "Background", 0);
Tilemap wallTiles = CreateTilemap(wallSection, "Walls", 1);
PopulateWallSection(profile, wallBackground, wallTiles);
CreateGuideLabel(guidesRoot, "Wall Shapes Label", wallSection.localPosition + new Vector3(1f, 5.6f, 0f), "sv_label_3");
CreateWallShapeLabels(guidesRoot, wallSection.localPosition, "sv_label_6");
Transform backgroundSection = CreateSection(root.transform, "BackgroundSample", WorldAutotileAuthoringSectionType.BackgroundSample, new Vector3(5f, 0f, 0f), new Vector2Int(5, 3));
Tilemap backgroundTilemap = CreateTilemap(backgroundSection, "Background", 0);
PopulateBackgroundSection(profile, backgroundTilemap);
CreateGuideLabel(guidesRoot, "Background Sample Label", backgroundSection.localPosition + new Vector3(2f, 3.6f, 0f), "sv_label_4");
int environmentWidth = Mathf.Max(1, CountAssignedEnvironmentTiles(profile));
Transform environmentSection = CreateSection(root.transform, "EnvironmentPalette", WorldAutotileAuthoringSectionType.EnvironmentPalette, new Vector3(0f, -3f, 0f), new Vector2Int(environmentWidth, 1));
Tilemap environmentBackground = CreateTilemap(environmentSection, "Background", 0);
Tilemap environmentTilemap = CreateTilemap(environmentSection, "Environment", 1);
PopulateEnvironmentSection(profile, environmentBackground, environmentTilemap);
float environmentCenterX = Mathf.Max(0f, (environmentWidth - 1) * 0.5f);
CreateGuideLabel(guidesRoot, "Environment Palette Label", environmentSection.localPosition + new Vector3(environmentCenterX, 1.6f, 0f), "sv_label_2");
return root;
}
private static Transform CreateSection(Transform parent, string name, WorldAutotileAuthoringSectionType sectionType, Vector3 localPosition, Vector2Int size)
{
GameObject section = new GameObject(name, typeof(WorldAutotileAuthoringSection));
section.transform.SetParent(parent, false);
section.transform.localPosition = localPosition;
WorldAutotileAuthoringSection marker = section.GetComponent<WorldAutotileAuthoringSection>();
marker.sectionType = sectionType;
marker.size = size;
return section.transform;
}
private static void CreateGuideLabel(Transform parent, string labelName, Vector3 position, string iconName)
{
GameObject label = new GameObject(labelName);
label.transform.SetParent(parent, false);
label.transform.localPosition = position;
SetIconForObject(label, iconName);
}
private static void CreateWallShapeLabels(Transform parent, Vector3 sectionPosition, string iconName)
{
for (int i = 0; i < WallShapeOrder.Length; i++)
{
Vector3Int cell = WallShapePositions[i];
string label = WorldAutotileEditorLabels.GetShapeLabel(WallShapeOrder[i]) + " Label";
Vector3 position = sectionPosition + new Vector3(cell.x + 0.5f, cell.y + 0.5f, 0f);
CreateGuideLabel(parent, label, position, iconName);
}
}
private static void PopulateWallSection(WorldAutotileProfile profile, Tilemap backgroundTilemap, Tilemap wallsTilemap)
{
TileBase background = profile.baseGroundTile;
for (int i = 0; i < WallShapeOrder.Length; i++)
{
Vector3Int position = WallShapePositions[i];
if (background != null)
{
backgroundTilemap.SetTile(position, background);
}
TileBase wallTile = profile.wallTiles != null ? profile.wallTiles.GetAssignedTile(WallShapeOrder[i]) : null;
if (wallTile != null)
{
wallsTilemap.SetTile(position, wallTile);
}
}
if (background != null)
{
backgroundTilemap.SetTile(new Vector3Int(1, 1, 0), background);
backgroundTilemap.SetTile(new Vector3Int(1, 0, 0), background);
}
}
private static void PopulateBackgroundSection(WorldAutotileProfile profile, Tilemap backgroundTilemap)
{
if (profile.baseGroundTile == null)
{
return;
}
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 3; y++)
{
backgroundTilemap.SetTile(new Vector3Int(x, y, 0), profile.baseGroundTile);
}
}
}
private static void PopulateEnvironmentSection(WorldAutotileProfile profile, Tilemap backgroundTilemap, Tilemap environmentTilemap)
{
if (profile.environmentTiles == null)
{
return;
}
int x = 0;
for (int i = 0; i < profile.environmentTiles.Count; i++)
{
EnvironmentTileEntry entry = profile.environmentTiles[i];
if (entry == null || entry.tile == null)
{
continue;
}
Vector3Int position = new Vector3Int(x, 0, 0);
if (profile.baseGroundTile != null)
{
backgroundTilemap.SetTile(position, profile.baseGroundTile);
}
environmentTilemap.SetTile(position, entry.tile);
x++;
}
}
private static Tilemap CreateTilemap(Transform parent, string name, int sortingOrder)
{
GameObject child = new GameObject(name, typeof(Tilemap), typeof(TilemapRenderer));
child.transform.SetParent(parent, false);
TilemapRenderer renderer = child.GetComponent<TilemapRenderer>();
renderer.sortingOrder = sortingOrder;
return child.GetComponent<Tilemap>();
}
private static bool TryBuildProfileFromLayout(GameObject prefabRoot, WorldAutotileProfile profile, out string error)
{
error = null;
if (prefabRoot == null)
{
error = "Could not load authoring layout prefab contents.";
return false;
}
WorldAutotileAuthoringRoot rootMarker = prefabRoot.GetComponent<WorldAutotileAuthoringRoot>();
if (rootMarker == null)
{
error = $"Authoring layout '{prefabRoot.name}' is missing {nameof(WorldAutotileAuthoringRoot)}.";
return false;
}
if (rootMarker.profile != null && rootMarker.profile != profile)
{
error = $"Authoring layout '{prefabRoot.name}' is linked to profile '{rootMarker.profile.name}', not '{profile.name}'.";
return false;
}
WorldAutotileAuthoringSection wallSection = FindSection(prefabRoot, WorldAutotileAuthoringSectionType.WallShapes);
WorldAutotileAuthoringSection backgroundSection = FindSection(prefabRoot, WorldAutotileAuthoringSectionType.BackgroundSample);
WorldAutotileAuthoringSection environmentSection = FindSection(prefabRoot, WorldAutotileAuthoringSectionType.EnvironmentPalette);
if (wallSection == null || backgroundSection == null || environmentSection == null)
{
error = $"Authoring layout '{prefabRoot.name}' is missing one or more required section markers.";
return false;
}
Tilemap wallTilemap = FindTilemap(wallSection.transform, "Walls");
Tilemap backgroundTilemap = FindTilemap(backgroundSection.transform, "Background");
Tilemap environmentTilemap = FindTilemap(environmentSection.transform, "Environment");
if (wallTilemap == null || backgroundTilemap == null || environmentTilemap == null)
{
error = $"Authoring layout '{prefabRoot.name}' is missing one or more required tilemaps.";
return false;
}
profile.baseGroundTile = FindFirstTile(backgroundTilemap, backgroundSection.size);
profile.wallTiles = ExtractWallTiles(wallTilemap);
profile.environmentTiles = ExtractEnvironmentTiles(environmentTilemap, environmentSection.size, profile.environmentTiles);
return true;
}
private static WorldAutotileAuthoringSection FindSection(GameObject root, WorldAutotileAuthoringSectionType sectionType)
{
WorldAutotileAuthoringSection[] sections = root.GetComponentsInChildren<WorldAutotileAuthoringSection>(true);
for (int i = 0; i < sections.Length; i++)
{
if (sections[i].sectionType == sectionType)
{
return sections[i];
}
}
return null;
}
private static Tilemap FindTilemap(Transform root, string name)
{
Transform child = root.Find(name);
return child != null ? child.GetComponent<Tilemap>() : null;
}
private static TileBase FindFirstTile(Tilemap tilemap, Vector2Int size)
{
for (int y = 0; y < Mathf.Max(1, size.y); y++)
{
for (int x = 0; x < Mathf.Max(1, size.x); x++)
{
TileBase tile = tilemap.GetTile(new Vector3Int(x, y, 0));
if (tile != null)
{
return tile;
}
}
}
return null;
}
private static AutoTileDefinition ExtractWallTiles(Tilemap wallTilemap)
{
AutoTileDefinition definition = new AutoTileDefinition();
for (int i = 0; i < WallShapeOrder.Length; i++)
{
AssignWallTile(definition, WallShapeOrder[i], wallTilemap.GetTile(WallShapePositions[i]));
}
return definition;
}
private static void AssignWallTile(AutoTileDefinition definition, AutoTileShape shape, TileBase tile)
{
switch (shape)
{
case AutoTileShape.Center:
definition.center = tile;
break;
case AutoTileShape.Top:
definition.top = tile;
break;
case AutoTileShape.Right:
definition.right = tile;
break;
case AutoTileShape.Bottom:
definition.bottom = tile;
break;
case AutoTileShape.Left:
definition.left = tile;
break;
case AutoTileShape.OuterTopLeft:
definition.outerTopLeft = tile;
break;
case AutoTileShape.OuterTopRight:
definition.outerTopRight = tile;
break;
case AutoTileShape.OuterBottomRight:
definition.outerBottomRight = tile;
break;
case AutoTileShape.OuterBottomLeft:
definition.outerBottomLeft = tile;
break;
case AutoTileShape.InnerTopLeft:
definition.innerTopLeft = tile;
break;
case AutoTileShape.InnerTopRight:
definition.innerTopRight = tile;
break;
case AutoTileShape.InnerBottomRight:
definition.innerBottomRight = tile;
break;
case AutoTileShape.InnerBottomLeft:
definition.innerBottomLeft = tile;
break;
}
}
private static List<EnvironmentTileEntry> ExtractEnvironmentTiles(Tilemap tilemap, Vector2Int size, List<EnvironmentTileEntry> previousEntries)
{
List<EnvironmentTileEntry> entries = new List<EnvironmentTileEntry>();
for (int y = 0; y < Mathf.Max(1, size.y); y++)
{
for (int x = 0; x < Mathf.Max(1, size.x); x++)
{
TileBase tile = tilemap.GetTile(new Vector3Int(x, y, 0));
if (tile == null || ContainsEnvironmentTile(entries, tile))
{
continue;
}
EnvironmentTileEntry existing = FindEnvironmentEntry(previousEntries, tile);
entries.Add(new EnvironmentTileEntry
{
id = existing != null && !string.IsNullOrWhiteSpace(existing.id) ? existing.id : tile.name,
tile = tile,
weight = existing != null ? existing.weight : 1f
});
}
}
return entries;
}
private static bool ContainsEnvironmentTile(List<EnvironmentTileEntry> entries, TileBase tile)
{
for (int i = 0; i < entries.Count; i++)
{
if (entries[i] != null && entries[i].tile == tile)
{
return true;
}
}
return false;
}
private static EnvironmentTileEntry FindEnvironmentEntry(List<EnvironmentTileEntry> entries, TileBase tile)
{
if (entries == null)
{
return null;
}
for (int i = 0; i < entries.Count; i++)
{
if (entries[i] != null && entries[i].tile == tile)
{
return entries[i];
}
}
return null;
}
private static int CountAssignedEnvironmentTiles(WorldAutotileProfile profile)
{
if (profile.environmentTiles == null)
{
return 0;
}
int count = 0;
for (int i = 0; i < profile.environmentTiles.Count; i++)
{
if (profile.environmentTiles[i] != null && profile.environmentTiles[i].tile != null)
{
count++;
}
}
return count;
}
private static void DeleteExistingAuthoringLayout(string path)
{
if (!File.Exists(path))
{
return;
}
AssetDatabase.DeleteAsset(path);
}
private static void SetIconForObject(GameObject gameObject, string iconName)
{
if (gameObject == null || SetIconForObjectMethod == null)
{
return;
}
Texture2D icon = EditorGUIUtility.IconContent(iconName).image as Texture2D;
if (icon == null)
{
return;
}
SetIconForObjectMethod.Invoke(null, new object[] { gameObject, icon });
}
private static void RefreshActiveGenerators(WorldAutotileProfile profile)
{
InfiniteWorldGenerator[] generators = Object.FindObjectsByType<InfiniteWorldGenerator>(FindObjectsSortMode.None);
for (int i = 0; i < generators.Length; i++)
{
InfiniteWorldGenerator generator = generators[i];
if (generator != null && generator.UsesProfile(profile))
{
generator.EditorRefreshFromProfile();
}
}
}
private static void EnsureFolderExists(string assetFolder)
{
string[] parts = assetFolder.Split('/');
string current = parts[0];
for (int i = 1; i < parts.Length; i++)
{
string next = current + "/" + parts[i];
if (!AssetDatabase.IsValidFolder(next))
{
AssetDatabase.CreateFolder(current, parts[i]);
}
current = next;
}
}
private static void ClearQueue()
{
PendingProfilePaths.Clear();
refreshQueued = false;
}
private static void QueueAllProfilesRefresh()
{
string[] guids = AssetDatabase.FindAssets("t:WorldAutotileProfile");
for (int i = 0; i < guids.Length; i++)
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
WorldAutotileProfile profile = AssetDatabase.LoadAssetAtPath<WorldAutotileProfile>(path);
if (profile != null)
{
QueueProfileRefresh(profile);
}
}
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 24d3fe24380362140ab8b0a89ecb61e4
-281
View File
@@ -1,281 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace InfiniteWorld.Editor
{
public class WorldGeneratorEditorWindow : EditorWindow
{
private static readonly AutoTileShape[] WallShapeOrder =
{
AutoTileShape.OuterTopLeft,
AutoTileShape.Top,
AutoTileShape.OuterTopRight,
AutoTileShape.Left,
AutoTileShape.Center,
AutoTileShape.Right,
AutoTileShape.OuterBottomLeft,
AutoTileShape.Bottom,
AutoTileShape.OuterBottomRight,
AutoTileShape.InnerTopLeft,
AutoTileShape.InnerTopRight,
AutoTileShape.InnerBottomLeft,
AutoTileShape.InnerBottomRight
};
private WorldAutotileProfile profile;
private SerializedObject serializedProfile;
private Vector2 scroll;
[MenuItem("Tools/Infinite World/World Builder")]
public static void Open()
{
GetWindow<WorldGeneratorEditorWindow>("World Builder");
}
private void OnGUI()
{
DrawToolbar();
EditorGUILayout.Space(6f);
if (profile == null)
{
EditorGUILayout.HelpBox("Assign or create a WorldAutotileProfile. The workflow is: create the authoring layout prefab, edit tiles inside that grid, then build the final profile back from the layout.", MessageType.Info);
return;
}
if (serializedProfile == null || serializedProfile.targetObject != profile)
{
serializedProfile = new SerializedObject(profile);
}
serializedProfile.Update();
scroll = EditorGUILayout.BeginScrollView(scroll);
DrawPaletteTools();
EditorGUILayout.Space(8f);
DrawValidation();
EditorGUILayout.Space(8f);
DrawProfileFields();
EditorGUILayout.EndScrollView();
serializedProfile.ApplyModifiedProperties();
if (GUI.changed)
{
EditorUtility.SetDirty(profile);
WorldAutotileProfilePipeline.QueueProfileRefresh(profile);
}
}
private void DrawToolbar()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
profile = (WorldAutotileProfile)EditorGUILayout.ObjectField(profile, typeof(WorldAutotileProfile), false, GUILayout.Width(position.width * 0.55f));
if (GUILayout.Button("New Profile", EditorStyles.toolbarButton, GUILayout.Width(90f)))
{
CreateProfileAsset();
}
using (new EditorGUI.DisabledScope(profile == null))
{
if (GUILayout.Button("Create Authoring Layout", EditorStyles.toolbarButton, GUILayout.Width(155f)))
{
WorldAutotileProfilePipeline.GenerateAuthoringLayout(profile);
}
}
EditorGUILayout.EndHorizontal();
}
private void DrawPaletteTools()
{
EditorGUILayout.LabelField("Palette Tools", EditorStyles.boldLabel);
EditorGUILayout.BeginVertical("box");
EditorGUILayout.HelpBox("Create Authoring Layout builds a temporary editor-only prefab with marked grid sections. Edit tiles there, then use Build Profile From Layout to write the final WorldAutotileProfile.", MessageType.None);
EditorGUILayout.PropertyField(serializedProfile.FindProperty("autoUpdatePaletteLayout"), new GUIContent("Auto Update Authoring Layout"));
EditorGUILayout.PropertyField(serializedProfile.FindProperty("autoRefreshGeneratedWorld"), new GUIContent("Auto Refresh Generated World"));
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Create / Update Layout"))
{
WorldAutotileProfilePipeline.GenerateAuthoringLayout(profile);
}
using (new EditorGUI.DisabledScope(WorldAutotileProfilePipeline.LoadAuthoringLayoutAsset(profile) == null))
{
if (GUILayout.Button("Build Profile From Layout"))
{
WorldAutotileProfilePipeline.BuildProfileFromAuthoringLayout(profile);
}
if (GUILayout.Button("Open Layout Prefab"))
{
GameObject layout = WorldAutotileProfilePipeline.LoadAuthoringLayoutAsset(profile);
if (layout != null)
{
AssetDatabase.OpenAsset(layout);
}
}
}
EditorGUILayout.EndHorizontal();
using (new EditorGUI.DisabledScope(WorldAutotileProfilePipeline.LoadAuthoringLayoutAsset(profile) == null))
{
if (GUILayout.Button("Ping Layout Prefab"))
{
GameObject layout = WorldAutotileProfilePipeline.LoadAuthoringLayoutAsset(profile);
if (layout != null)
{
EditorGUIUtility.PingObject(layout);
Selection.activeObject = layout;
}
}
}
EditorGUILayout.LabelField("Layout Path", WorldAutotileProfilePipeline.GetAuthoringLayoutPath(profile));
EditorGUILayout.EndVertical();
}
private void DrawValidation()
{
EditorGUILayout.LabelField("Profile Check", EditorStyles.boldLabel);
EditorGUILayout.BeginVertical("box");
List<string> missingShapes = GetMissingWallShapes();
if (missingShapes.Count == 0)
{
EditorGUILayout.HelpBox("All wall variants are assigned. The generated palette layout will include every corner, side, and center tile.", MessageType.Info);
}
else
{
EditorGUILayout.HelpBox("Missing wall variants: " + string.Join(", ", missingShapes), MessageType.Warning);
}
int environmentCount = CountAssignedEnvironmentTiles();
int prefabCount = CountAssignedRandomPrefabs();
EditorGUILayout.LabelField("Background", profile.baseGroundTile != null ? profile.baseGroundTile.name : "Not assigned");
EditorGUILayout.LabelField("Environment Tiles", environmentCount.ToString());
EditorGUILayout.LabelField("Random Prefabs", prefabCount.ToString());
EditorGUILayout.EndVertical();
}
private void DrawProfileFields()
{
EditorGUILayout.LabelField("Profile Assets", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedProfile.FindProperty("baseGroundTile"), new GUIContent("Background Tile"));
EditorGUILayout.Space(6f);
EditorGUILayout.LabelField("Wall Variants", EditorStyles.miniBoldLabel);
SerializedProperty walls = serializedProfile.FindProperty("wallTiles");
DrawWallGrid(walls);
EditorGUILayout.Space(6f);
EditorGUILayout.PropertyField(serializedProfile.FindProperty("environmentTiles"), true);
EditorGUILayout.Space(6f);
EditorGUILayout.PropertyField(serializedProfile.FindProperty("randomPrefabs"), true);
}
private void DrawWallGrid(SerializedProperty walls)
{
DrawLabeledRow(walls, AutoTileShape.OuterTopLeft, AutoTileShape.Top, AutoTileShape.OuterTopRight);
DrawLabeledRow(walls, AutoTileShape.Left, AutoTileShape.Center, AutoTileShape.Right);
DrawLabeledRow(walls, AutoTileShape.OuterBottomLeft, AutoTileShape.Bottom, AutoTileShape.OuterBottomRight);
DrawLabeledRow(walls, AutoTileShape.InnerTopLeft, AutoTileShape.InnerTopRight);
DrawLabeledRow(walls, AutoTileShape.InnerBottomLeft, AutoTileShape.InnerBottomRight);
}
private static void DrawLabeledRow(SerializedProperty root, params AutoTileShape[] shapes)
{
EditorGUILayout.BeginHorizontal();
for (int i = 0; i < shapes.Length; i++)
{
DrawLabeledCell(root, shapes[i]);
}
EditorGUILayout.EndHorizontal();
}
private static void DrawLabeledCell(SerializedProperty root, AutoTileShape shape)
{
SerializedProperty property = root.FindPropertyRelative(WorldAutotileEditorLabels.GetPropertyName(shape));
EditorGUILayout.BeginVertical(GUILayout.MaxWidth(150f));
EditorGUILayout.LabelField(WorldAutotileEditorLabels.GetShapeLabel(shape), EditorStyles.miniLabel);
EditorGUILayout.PropertyField(property, GUIContent.none);
EditorGUILayout.EndVertical();
}
private List<string> GetMissingWallShapes()
{
List<string> missing = new List<string>();
for (int i = 0; i < WallShapeOrder.Length; i++)
{
AutoTileShape shape = WallShapeOrder[i];
if (profile.wallTiles == null || profile.wallTiles.GetAssignedTile(shape) == null)
{
missing.Add(shape.ToString());
}
}
return missing;
}
private int CountAssignedEnvironmentTiles()
{
if (profile.environmentTiles == null)
{
return 0;
}
int count = 0;
for (int i = 0; i < profile.environmentTiles.Count; i++)
{
if (profile.environmentTiles[i] != null && profile.environmentTiles[i].tile != null)
{
count++;
}
}
return count;
}
private int CountAssignedRandomPrefabs()
{
if (profile.randomPrefabs == null)
{
return 0;
}
int count = 0;
for (int i = 0; i < profile.randomPrefabs.Count; i++)
{
if (profile.randomPrefabs[i] != null && profile.randomPrefabs[i].prefab != null)
{
count++;
}
}
return count;
}
private void CreateProfileAsset()
{
string path = EditorUtility.SaveFilePanelInProject("Create World Profile", "WorldAutotileProfile", "asset", "Choose where to save the tile profile.");
if (string.IsNullOrEmpty(path))
{
return;
}
WorldAutotileProfile asset = CreateInstance<WorldAutotileProfile>();
AssetDatabase.CreateAsset(asset, path);
AssetDatabase.SaveAssets();
profile = asset;
serializedProfile = new SerializedObject(profile);
Selection.activeObject = asset;
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: ff365d4e73b85cc4987c7984d5f8c7cb