- UI SFX v3: procedurally synthesized one-shots (Tools/synth_ui_sfx.py) wired to buttons, rewards, errors and red dots via UiSfx, gated by the SFX setting. - Five formal enemies (Hornlet, Dashlet, Shellhorn, HornCaptain, GreatHorn): Hunyuan 50k -> 2000-tri XPbr, DGXA TokenRig, Idle/Walk/Attack, nested per type in PrototypeArena; PrototypeBattle.Enemy gains presentation-only Moving/Strikes. - Formal partners for all ten pets in the arena and portraits, including new VineSprite, ThunderLeopard and TideWhale. - Pipeline fixes: reject local TokenRig fallback, drop loose mesh islands, configurable Unity run_script timeout, companion static stage. - Also includes concurrent work from another tool in this working tree (FlameLion, enemy combat FX, challenge mode, home explorer, server updates). - Resources registered in Doc/ResDesc_*.md; verified on isolated :18081. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
5.7 KiB
C#
112 lines
5.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using AIGame.EditorTools;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
/// <summary>Installs the empty camp painting and authors the placeholder explorer.</summary>
|
|
public static class BuildHomeExplorer
|
|
{
|
|
static string Repo => Directory.GetParent(Application.dataPath).Parent.FullName;
|
|
const string Folder = "Assets/Bundles/Characters/Explorer";
|
|
const string Generated = @"C:\Users\Administrator\.cursor\projects\d-UD-AI-AIGame\assets\home_camp_clear.jpg";
|
|
|
|
public static string Install()
|
|
{
|
|
if (EditorApplication.isPlaying) throw new Exception("Install the camp background in Edit Mode");
|
|
string design = Path.Combine(Repo, "Doc/Design/UI/Home");
|
|
string source = Path.Combine(design, "home_camp_source.png");
|
|
string cast = Path.Combine(design, "home_camp_with_cast.png");
|
|
if (!File.Exists(cast)) File.Copy(source, cast, false);
|
|
var tex = new Texture2D(2, 2, TextureFormat.RGBA32, false);
|
|
try
|
|
{
|
|
if (!tex.LoadImage(File.ReadAllBytes(Generated))) throw new Exception("Camp image failed to decode");
|
|
byte[] png = tex.EncodeToPNG();
|
|
File.WriteAllBytes(source, png);
|
|
Directory.CreateDirectory(Path.Combine(Application.dataPath, "Bundles/UI/Texture/Home"));
|
|
File.WriteAllBytes(Path.Combine(Application.dataPath, "Bundles/UI/Texture/Home/home_camp.png"), png);
|
|
}
|
|
finally { UnityEngine.Object.DestroyImmediate(tex); }
|
|
AssetDatabase.ImportAsset("Assets/Bundles/UI/Texture/Home/home_camp.png");
|
|
var importer = (TextureImporter)AssetImporter.GetAtPath("Assets/Bundles/UI/Texture/Home/home_camp.png");
|
|
importer.textureType = TextureImporterType.Sprite;
|
|
importer.spriteImportMode = SpriteImportMode.Single;
|
|
importer.mipmapEnabled = false;
|
|
importer.alphaIsTransparency = true;
|
|
importer.textureCompression = TextureImporterCompression.Uncompressed;
|
|
importer.filterMode = FilterMode.Bilinear;
|
|
importer.wrapMode = TextureWrapMode.Clamp;
|
|
var settings = new TextureImporterSettings();
|
|
importer.ReadTextureSettings(settings);
|
|
settings.spriteMeshType = SpriteMeshType.FullRect;
|
|
importer.SetTextureSettings(settings);
|
|
importer.SaveAndReimport();
|
|
return "Installed empty camp painting " + importer.spriteImportMode;
|
|
}
|
|
|
|
public static string Prefab()
|
|
{
|
|
if (EditorApplication.isPlaying) throw new Exception("Author the explorer in Edit Mode");
|
|
Directory.CreateDirectory(Path.Combine(Application.dataPath, "Bundles/Characters/Explorer"));
|
|
var root = new GameObject("ExplorerSimple");
|
|
try
|
|
{
|
|
root.AddComponent<HotUpdate.Gameplay.ExplorerPuppet>();
|
|
Part(root.transform, "Body", PrimitiveType.Capsule, new Vector3(0f, 0.78f, 0f), new Vector3(0.5f, 0.42f, 0.36f), "#C4895A");
|
|
Part(root.transform, "Head", PrimitiveType.Sphere, new Vector3(0f, 1.28f, -0.02f), Vector3.one * 0.4f, "#F3D2B3");
|
|
Part(root.transform, "Hair", PrimitiveType.Sphere, new Vector3(0f, 1.46f, 0.04f), new Vector3(0.38f, 0.22f, 0.36f), "#6B3E2A");
|
|
Part(root.transform, "Goggles", PrimitiveType.Cube, new Vector3(0f, 1.32f, -0.16f), new Vector3(0.34f, 0.1f, 0.08f), "#7EC8C3");
|
|
Limb(root.transform, "LegL", new Vector3(-0.12f, 0.48f, 0f));
|
|
Limb(root.transform, "LegR", new Vector3(0.12f, 0.48f, 0f));
|
|
string path = Folder + "/ExplorerSimple.prefab";
|
|
PrefabUtility.SaveAsPrefabAsset(root, path);
|
|
}
|
|
finally { UnityEngine.Object.DestroyImmediate(root); }
|
|
return "Authored ExplorerSimple placeholder prefab";
|
|
}
|
|
|
|
public static string Hud()
|
|
{
|
|
if (EditorApplication.isPlaying) throw new Exception("Build the HUD in Edit Mode");
|
|
string json = Path.Combine(Repo, "Doc/UIPrefabCreater/UI_MainHUD.json");
|
|
var validation = JsonUIPrefabBuilder.Validate(json);
|
|
if (!validation.Ok) throw new Exception(string.Join("\n", validation.Errors));
|
|
if (string.IsNullOrEmpty(JsonUIPrefabBuilder.BuildFromJsonFile(json))) throw new Exception("HUD build failed");
|
|
return "Rebuilt UI_MainHUD with the walking explorer";
|
|
}
|
|
|
|
static void Limb(Transform parent, string name, Vector3 hip)
|
|
{
|
|
var pivot = new GameObject(name);
|
|
pivot.layer = 31;
|
|
pivot.transform.SetParent(parent, false);
|
|
pivot.transform.localPosition = hip;
|
|
Part(pivot.transform, "Mesh", PrimitiveType.Capsule, new Vector3(0f, -0.24f, 0f), new Vector3(0.16f, 0.24f, 0.16f), "#3E6EA8");
|
|
Part(pivot.transform, "Boot", PrimitiveType.Sphere, new Vector3(0f, -0.46f, -0.04f), new Vector3(0.18f, 0.12f, 0.24f), "#5C4033");
|
|
}
|
|
|
|
static void Part(Transform parent, string name, PrimitiveType type, Vector3 position, Vector3 scale, string color)
|
|
{
|
|
var go = GameObject.CreatePrimitive(type);
|
|
go.name = name;
|
|
go.layer = 31;
|
|
go.transform.SetParent(parent, false);
|
|
go.transform.localPosition = position;
|
|
go.transform.localScale = scale;
|
|
UnityEngine.Object.DestroyImmediate(go.GetComponent<Collider>());
|
|
string matPath = Folder + "/" + name + ".mat";
|
|
var material = AssetDatabase.LoadAssetAtPath<Material>(matPath);
|
|
if (material == null)
|
|
{
|
|
material = new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
|
AssetDatabase.CreateAsset(material, matPath);
|
|
}
|
|
ColorUtility.TryParseHtmlString(color, out var parsed);
|
|
material.SetColor("_BaseColor", parsed);
|
|
material.SetFloat("_Smoothness", 0.25f);
|
|
go.GetComponent<Renderer>().sharedMaterial = material;
|
|
EditorUtility.SetDirty(material);
|
|
}
|
|
}
|