Ship the WeChat hot-update catalogs and the camp, TideWhale T2, UI atlas, and animation-lab work.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,11 +6,10 @@ using UnityEngine.UI;
|
||||
|
||||
namespace HotUpdate.UI
|
||||
{
|
||||
/// <summary>Walks a placeholder explorer over the camp painting and speaks only after a tap.</summary>
|
||||
/// <summary>Walks the camp guide over the camp painting and speaks only after a tap.</summary>
|
||||
public sealed class HomeExplorerPresenter : MonoBehaviour
|
||||
{
|
||||
const int Layer = 31;
|
||||
static readonly Color Key = new Color(0.07f, 0.02f, 0.09f, 1f);
|
||||
static readonly string[] Lines =
|
||||
{
|
||||
"喷泉今天的水声很好听。",
|
||||
@@ -26,6 +25,9 @@ namespace HotUpdate.UI
|
||||
UiPrefabLoader _loader;
|
||||
GameObject _stage;
|
||||
Camera _camera;
|
||||
RenderTexture _texture;
|
||||
RawImage _image;
|
||||
bool _booting;
|
||||
Transform _actor;
|
||||
RectTransform _button;
|
||||
RectTransform _bubble;
|
||||
@@ -41,30 +43,50 @@ namespace HotUpdate.UI
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_image = GetComponent<RawImage>();
|
||||
if (_image != null) _image.enabled = _camera != null;
|
||||
if (_camera != null) _camera.enabled = true;
|
||||
else StartCoroutine(Boot());
|
||||
else if (!_booting) StartCoroutine(Boot());
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (_camera != null) _camera.enabled = false;
|
||||
if (_image != null) _image.enabled = false;
|
||||
if (_bubble != null) _bubble.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_button != null) _button.GetComponent<Button>().onClick.RemoveListener(Speak);
|
||||
if (_stage != null) Destroy(_stage);
|
||||
if (_camera != null && _camera.targetTexture != null)
|
||||
if (_image != null) _image.texture = null;
|
||||
if (_camera != null) _camera.targetTexture = null;
|
||||
if (_texture != null)
|
||||
{
|
||||
_camera.targetTexture.Release();
|
||||
Destroy(_camera.targetTexture);
|
||||
_texture.Release();
|
||||
Destroy(_texture);
|
||||
}
|
||||
if (_stage != null) Destroy(_stage);
|
||||
_loader?.Dispose();
|
||||
}
|
||||
|
||||
IEnumerator Boot()
|
||||
{
|
||||
_booting = true;
|
||||
try { yield return BootCore(); }
|
||||
finally { _booting = false; }
|
||||
}
|
||||
|
||||
IEnumerator BootCore()
|
||||
{
|
||||
// The serialized material makes the shader a real AssetBundle dependency.
|
||||
// Never display the opaque camera clear color when that dependency is unavailable.
|
||||
if (_image == null || _image.material == null || _image.material.shader == null ||
|
||||
_image.material.shader.name != "AIGame/HomeExplorerCutout" || !_image.material.shader.isSupported)
|
||||
{
|
||||
Debug.LogWarning("[HomeExplorer] Preview material unavailable; keeping the camp background visible.");
|
||||
yield break;
|
||||
}
|
||||
var root = transform.parent;
|
||||
_button = root.Find("Btn_Explorer") as RectTransform;
|
||||
_bubble = root.Find("Panel_ExplorerTalk") as RectTransform;
|
||||
@@ -73,9 +95,9 @@ namespace HotUpdate.UI
|
||||
yield return null;
|
||||
|
||||
GameObject prefab = null;
|
||||
_loader = new UiPrefabLoader(null, "Assets/Bundles/Characters/Explorer");
|
||||
yield return _loader.LoadAsync("ExplorerSimple", loaded => prefab = loaded);
|
||||
if (prefab == null || _stage != null) yield break;
|
||||
_loader = new UiPrefabLoader(null, "Assets/Bundles/Characters/Human/CampGuideStudio");
|
||||
yield return _loader.LoadAsync("CampGuideStudio_Rigged", loaded => prefab = loaded);
|
||||
if (prefab == null || _stage != null || !isActiveAndEnabled) yield break;
|
||||
|
||||
_stage = new GameObject("HomeExplorerStage");
|
||||
_stage.transform.position = new Vector3(40f, 0f, 0f);
|
||||
@@ -97,7 +119,8 @@ namespace HotUpdate.UI
|
||||
camGo.transform.SetParent(_stage.transform, false);
|
||||
_camera = camGo.AddComponent<Camera>();
|
||||
_camera.clearFlags = CameraClearFlags.SolidColor;
|
||||
_camera.backgroundColor = Key;
|
||||
// Read the shipped material: a hot-update DLL may run with an older Art bundle.
|
||||
_camera.backgroundColor = _image.material.GetColor("_Key");
|
||||
_camera.cullingMask = 1 << Layer;
|
||||
_camera.orthographic = true;
|
||||
_camera.orthographicSize = 1.45f;
|
||||
@@ -107,21 +130,11 @@ namespace HotUpdate.UI
|
||||
_camera.depth = -50;
|
||||
_camera.transform.localPosition = new Vector3(0.15f, 1.7f, -3.6f);
|
||||
_camera.transform.LookAt(_stage.transform.TransformPoint(0f, 0.7f, 0f));
|
||||
var rt = new RenderTexture(512, 512, 16, RenderTextureFormat.ARGB32);
|
||||
rt.Create();
|
||||
_camera.targetTexture = rt;
|
||||
|
||||
var raw = gameObject.GetComponent<RawImage>() ?? gameObject.AddComponent<RawImage>();
|
||||
raw.texture = rt;
|
||||
raw.raycastTarget = false;
|
||||
raw.color = Color.white;
|
||||
var shader = Shader.Find("AIGame/HomeExplorerCutout");
|
||||
if (shader != null)
|
||||
{
|
||||
var material = new Material(shader);
|
||||
material.SetColor("_Key", Key);
|
||||
raw.material = material;
|
||||
}
|
||||
_texture = new RenderTexture(512, 512, 16, RenderTextureFormat.ARGB32);
|
||||
_texture.Create();
|
||||
_camera.targetTexture = _texture;
|
||||
_image.texture = _texture;
|
||||
_image.enabled = true;
|
||||
_bubble.gameObject.SetActive(false);
|
||||
if (!_hooked && _button != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user