添加画报相关功能
parent
469dc2feda
commit
0ce259ef27
|
|
@ -0,0 +1,396 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[ExecuteAlways] // 在编辑模式下也执行
|
||||
public class BackgroundRelativePosition : MonoBehaviour
|
||||
{
|
||||
[Header("背景参考")]
|
||||
[SerializeField] private RectTransform _background; // 参考背景
|
||||
|
||||
[Header("设计分辨率设置")]
|
||||
[SerializeField] private Vector2 _designResolution = new Vector2(1920, 1080); // 设计分辨率
|
||||
|
||||
[Header("设计时位置")]
|
||||
[SerializeField] private Vector2 _designPosition; // 在设计分辨率下的位置(相对于父节点中心)
|
||||
|
||||
[Header("相对位置模式")]
|
||||
[SerializeField] private RelativeMode _relativeMode = RelativeMode.UV;
|
||||
|
||||
[Header("更新设置")]
|
||||
[SerializeField] private bool _autoUpdate = true; // 自动更新
|
||||
[SerializeField] private UpdateMode _updateMode = UpdateMode.OnStartAndResolutionChange;
|
||||
|
||||
private RectTransform _rectTransform;
|
||||
private Vector2 _lastScreenSize;
|
||||
private Vector2 _lastBackgroundSize;
|
||||
|
||||
public enum RelativeMode
|
||||
{
|
||||
UV, // 使用UV坐标(0-1范围)
|
||||
PixelPerfect, // 像素完美缩放
|
||||
AnchorBased // 基于锚点
|
||||
}
|
||||
|
||||
public enum UpdateMode
|
||||
{
|
||||
OnStartAndResolutionChange,
|
||||
EveryFrame,
|
||||
Manual
|
||||
}
|
||||
|
||||
#region 属性
|
||||
|
||||
/// <summary>
|
||||
/// 背景参考
|
||||
/// </summary>
|
||||
public RectTransform Background
|
||||
{
|
||||
get => _background;
|
||||
set
|
||||
{
|
||||
_background = value;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设计时位置(在设计分辨率下相对于父节点中心的位置)
|
||||
/// </summary>
|
||||
public Vector2 DesignPosition
|
||||
{
|
||||
get => _designPosition;
|
||||
set
|
||||
{
|
||||
_designPosition = value;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设计分辨率
|
||||
/// </summary>
|
||||
public Vector2 DesignResolution
|
||||
{
|
||||
get => _designResolution;
|
||||
set
|
||||
{
|
||||
_designResolution = value;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前相对位置(UV坐标)
|
||||
/// </summary>
|
||||
public Vector2 RelativeUV
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_background == null || _rectTransform == null) return Vector2.zero;
|
||||
|
||||
// 计算当前相对于背景的UV坐标
|
||||
Vector2 backgroundSize = _background.rect.size;
|
||||
Vector2 relativePos = _rectTransform.anchoredPosition - _background.anchoredPosition;
|
||||
|
||||
return new Vector2(
|
||||
(relativePos.x + backgroundSize.x * 0.5f) / backgroundSize.x,
|
||||
(relativePos.y + backgroundSize.y * 0.5f) / backgroundSize.y
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity生命周期
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
_lastScreenSize = new Vector2(Screen.width, Screen.height);
|
||||
|
||||
// 如果没有设置背景,尝试从父对象获取
|
||||
if (_background == null)
|
||||
{
|
||||
Transform parent = transform.parent;
|
||||
if (parent != null)
|
||||
{
|
||||
_background = parent.GetComponent<RectTransform>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_updateMode == UpdateMode.OnStartAndResolutionChange)
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_autoUpdate) return;
|
||||
|
||||
switch (_updateMode)
|
||||
{
|
||||
case UpdateMode.EveryFrame:
|
||||
UpdatePosition();
|
||||
break;
|
||||
|
||||
case UpdateMode.OnStartAndResolutionChange:
|
||||
CheckResolutionChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRectTransformDimensionsChange()
|
||||
{
|
||||
if (_autoUpdate && _updateMode != UpdateMode.Manual)
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
// 在编辑器模式下验证时更新
|
||||
if (_rectTransform == null)
|
||||
_rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
if (Application.isPlaying || UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 编辑器模式下,参数改变时更新
|
||||
UnityEditor.EditorApplication.delayCall += () =>
|
||||
{
|
||||
if (this != null && _autoUpdate)
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region 核心方法
|
||||
|
||||
/// <summary>
|
||||
/// 更新Item位置
|
||||
/// </summary>
|
||||
public void UpdatePosition()
|
||||
{
|
||||
if (_background == null || _rectTransform == null)
|
||||
{
|
||||
Debug.LogWarning("BackgroundRelativePosition: 背景或RectTransform未设置", this);
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存原始锚点
|
||||
Vector2 originalAnchorMin = _rectTransform.anchorMin;
|
||||
Vector2 originalAnchorMax = _rectTransform.anchorMax;
|
||||
Vector2 originalPivot = _rectTransform.pivot;
|
||||
|
||||
try
|
||||
{
|
||||
// 根据模式计算位置
|
||||
Vector2 newPosition = CalculatePosition();
|
||||
|
||||
// 设置位置
|
||||
_rectTransform.anchoredPosition = newPosition;
|
||||
|
||||
// 记录背景大小变化
|
||||
_lastBackgroundSize = _background.rect.size;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 恢复原始锚点设置
|
||||
_rectTransform.anchorMin = originalAnchorMin;
|
||||
_rectTransform.anchorMax = originalAnchorMax;
|
||||
_rectTransform.pivot = originalPivot;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算当前位置
|
||||
/// </summary>
|
||||
private Vector2 CalculatePosition()
|
||||
{
|
||||
switch (_relativeMode)
|
||||
{
|
||||
case RelativeMode.UV:
|
||||
return CalculateUVPosition();
|
||||
|
||||
case RelativeMode.PixelPerfect:
|
||||
return CalculatePixelPerfectPosition();
|
||||
|
||||
case RelativeMode.AnchorBased:
|
||||
return CalculateAnchorBasedPosition();
|
||||
|
||||
default:
|
||||
return CalculateUVPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用UV模式计算位置
|
||||
/// </summary>
|
||||
private Vector2 CalculateUVPosition()
|
||||
{
|
||||
// 获取背景实际大小
|
||||
Vector2 backgroundSize = _background.rect.size;
|
||||
if (backgroundSize.x <= 0 || backgroundSize.y <= 0)
|
||||
{
|
||||
Debug.LogWarning("BackgroundRelativePosition: 背景大小为0", this);
|
||||
return _rectTransform.anchoredPosition;
|
||||
}
|
||||
|
||||
// 计算设计分辨率下,item相对于设计背景的相对位置(以背景中心为原点)
|
||||
// _designPosition是相对于父节点中心的位置
|
||||
// 假设在设计分辨率下,背景也是相对于父节点中心居中的
|
||||
// 那么item相对于背景的偏移 = _designPosition - 背景位置偏移
|
||||
// 但如果背景居中,背景位置偏移 = (0, 0)
|
||||
Vector2 relativeToDesignBackground = _designPosition;
|
||||
|
||||
// 计算相对位置的比例(相对于设计背景大小)
|
||||
Vector2 relativeRatio = new Vector2(
|
||||
relativeToDesignBackground.x / _designResolution.x,
|
||||
relativeToDesignBackground.y / _designResolution.y
|
||||
);
|
||||
|
||||
// 应用该比例到当前背景,得到相对于当前背景中心的位置
|
||||
Vector2 relativePos = new Vector2(
|
||||
relativeRatio.x * backgroundSize.x,
|
||||
relativeRatio.y * backgroundSize.y
|
||||
);
|
||||
|
||||
// 加上背景的实际位置,得到相对于父节点的最终位置
|
||||
return _background.anchoredPosition + relativePos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用像素完美模式计算位置
|
||||
/// </summary>
|
||||
private Vector2 CalculatePixelPerfectPosition()
|
||||
{
|
||||
// 获取背景实际大小
|
||||
Vector2 backgroundSize = _background.rect.size;
|
||||
Vector2 designBackgroundSize = _designResolution;
|
||||
|
||||
// 计算缩放比例
|
||||
float scaleX = backgroundSize.x / designBackgroundSize.x;
|
||||
float scaleY = backgroundSize.y / designBackgroundSize.y;
|
||||
|
||||
// 应用缩放
|
||||
Vector2 scaledPosition = new Vector2(
|
||||
_designPosition.x * scaleX,
|
||||
_designPosition.y * scaleY
|
||||
);
|
||||
|
||||
// 加上背景的位置偏移
|
||||
return _background.anchoredPosition + scaledPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用锚点模式计算位置
|
||||
/// </summary>
|
||||
private Vector2 CalculateAnchorBasedPosition()
|
||||
{
|
||||
// 将设计位置转换为锚点值
|
||||
Vector2 designUV = new Vector2(
|
||||
(_designPosition.x + _designResolution.x * 0.5f) / _designResolution.x,
|
||||
(_designPosition.y + _designResolution.y * 0.5f) / _designResolution.y
|
||||
);
|
||||
|
||||
// 直接设置锚点(这会改变RectTransform的布局方式)
|
||||
_rectTransform.anchorMin = designUV;
|
||||
_rectTransform.anchorMax = designUV;
|
||||
_rectTransform.pivot = new Vector2(0.5f, 0.5f);
|
||||
|
||||
// 返回背景位置
|
||||
return _background.anchoredPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查分辨率变化
|
||||
/// </summary>
|
||||
private void CheckResolutionChange()
|
||||
{
|
||||
Vector2 currentScreenSize = new Vector2(Screen.width, Screen.height);
|
||||
Vector2 currentBackgroundSize = _background != null ? _background.rect.size : Vector2.zero;
|
||||
|
||||
if (currentScreenSize != _lastScreenSize ||
|
||||
(_background != null && currentBackgroundSize != _lastBackgroundSize))
|
||||
{
|
||||
_lastScreenSize = currentScreenSize;
|
||||
_lastBackgroundSize = currentBackgroundSize;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从当前位置反推设计位置
|
||||
/// </summary>
|
||||
public void CalculateDesignPositionFromCurrent()
|
||||
{
|
||||
if (_background == null || _rectTransform == null)
|
||||
return;
|
||||
|
||||
// 获取当前相对位置
|
||||
Vector2 currentPos = _rectTransform.anchoredPosition - _background.anchoredPosition;
|
||||
Vector2 backgroundSize = _background.rect.size;
|
||||
|
||||
// 计算当前UV
|
||||
Vector2 currentUV = new Vector2(
|
||||
(currentPos.x + backgroundSize.x * 0.5f) / backgroundSize.x,
|
||||
(currentPos.y + backgroundSize.y * 0.5f) / backgroundSize.y
|
||||
);
|
||||
|
||||
// 反推设计位置
|
||||
_designPosition = new Vector2(
|
||||
currentUV.x * _designResolution.x - _designResolution.x * 0.5f,
|
||||
currentUV.y * _designResolution.y - _designResolution.y * 0.5f
|
||||
);
|
||||
|
||||
Debug.Log($"设计位置已更新为: {_designPosition}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制立即更新位置
|
||||
/// </summary>
|
||||
public void ForceUpdate()
|
||||
{
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑器辅助
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("GameObject/UI/Background Relative Position", false, 10)]
|
||||
static void CreateBackgroundRelativeItem(UnityEditor.MenuCommand menuCommand)
|
||||
{
|
||||
// 创建GameObject
|
||||
GameObject go = new GameObject("BackgroundRelativeItem");
|
||||
UnityEditor.GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
|
||||
|
||||
// 添加必要的组件
|
||||
go.AddComponent<Image>();
|
||||
go.AddComponent<BackgroundRelativePosition>();
|
||||
|
||||
// 注册撤销操作
|
||||
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
|
||||
|
||||
// 选中新创建的对象
|
||||
UnityEditor.Selection.activeObject = go;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c3eca939f9fb10f41ba792d07b5c1126
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 461d6fb6191e9e442989630996609d33
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,492 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Framework.UI.Pictorial
|
||||
{
|
||||
/// <summary>
|
||||
/// 画报背景组件
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[RequireComponent(typeof(Image))]
|
||||
[ExecuteAlways] // 允许在编辑器非运行模式下执行Update
|
||||
public class PictorialBackground : MonoBehaviour
|
||||
{
|
||||
[Header("画报数据")]
|
||||
[TextArea(5, 20)]
|
||||
[SerializeField] private string pictorialDataJson;
|
||||
|
||||
private PictorialData pictorialData;
|
||||
private List<PictorialItem> items = new List<PictorialItem>();
|
||||
|
||||
private RectTransform rectTransform;
|
||||
private Image backgroundImage;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private Vector2Int lastResolution; // 上次检查的屏幕分辨率
|
||||
private Vector2Int lastBackgroundSize; // 上次检查的背景尺寸
|
||||
private const float CHECK_INTERVAL = 0.5f; // 每0.5秒棆查一次
|
||||
private float lastCheckTime;
|
||||
private bool debugLogEnabled = true; // 调试日志开关
|
||||
#endif
|
||||
|
||||
public PictorialData PictorialData => pictorialData;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
backgroundImage = GetComponent<Image>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// 初始化分辨率和背景尺寸
|
||||
Vector2 backgroundSize = rectTransform.rect.size;
|
||||
lastBackgroundSize = new Vector2Int((int)backgroundSize.x, (int)backgroundSize.y);
|
||||
lastResolution = GetCurrentScreenResolution();
|
||||
Debug.Log($"[画报系统] PictorialBackground Awake - 初始化 屏幕: {lastResolution.x}x{lastResolution.y}, 背景: {lastBackgroundSize.x}x{lastBackgroundSize.y}");
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialBackground Start被调用 - isPlaying={Application.isPlaying}, pictorialData={pictorialData != null}, pictorialDataJson.Length={pictorialDataJson?.Length ?? 0}");
|
||||
|
||||
// 运行时加载画报数据
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (pictorialData == null && !string.IsNullOrEmpty(pictorialDataJson))
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialBackground 运行时加载画报数据");
|
||||
LoadPictorialData(pictorialDataJson);
|
||||
}
|
||||
else if (pictorialData == null)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] PictorialBackground 运行时没有画报数据,pictorialDataJson为空");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialBackground 画报数据已加载: {pictorialData.pictorialName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
// 只在编辑器非运行模式下检查
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (debugLogEnabled && Time.realtimeSinceStartup - lastCheckTime > 5f)
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialBackground.Update 运行中,但处于运行模式,跳过");
|
||||
lastCheckTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 编辑器模式下,如果没有数据但有JSON,尝试加载
|
||||
if (pictorialData == null && !string.IsNullOrEmpty(pictorialDataJson))
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialBackground 编辑器模式加载画报数据");
|
||||
LoadPictorialData(pictorialDataJson);
|
||||
}
|
||||
|
||||
// 清理null引用
|
||||
items.RemoveAll(item => item == null);
|
||||
|
||||
// 实时检查场景中的元素数量
|
||||
int sceneItemCount = 0;
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
if (transform.GetChild(i).GetComponent<PictorialItem>() != null)
|
||||
{
|
||||
sceneItemCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否有画报数据和元素
|
||||
if (pictorialData == null || sceneItemCount == 0)
|
||||
{
|
||||
if (debugLogEnabled && Time.realtimeSinceStartup - lastCheckTime > 5f)
|
||||
{
|
||||
Debug.Log($"[画报系统] Update运行中,但暂无画报数据:pictorialData={pictorialData != null}, sceneItemCount={sceneItemCount}, items.Count={items.Count}");
|
||||
lastCheckTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 限制检查频率
|
||||
if (Time.realtimeSinceStartup - lastCheckTime < CHECK_INTERVAL)
|
||||
return;
|
||||
|
||||
lastCheckTime = Time.realtimeSinceStartup;
|
||||
|
||||
// 确保组件已初始化
|
||||
if (rectTransform == null)
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
// 获取当前屏幕分辨率和背景尺寸
|
||||
Vector2Int currentScreenResolution = GetCurrentScreenResolution();
|
||||
Vector2 backgroundSize = rectTransform.rect.size;
|
||||
Vector2Int currentBackgroundSize = new Vector2Int((int)backgroundSize.x, (int)backgroundSize.y);
|
||||
|
||||
// 检查屏幕分辨率是否变化
|
||||
if (currentScreenResolution != lastResolution)
|
||||
{
|
||||
Debug.Log($"[画报系统] 检测到屏幕分辨率变化: {lastResolution.x}x{lastResolution.y} -> {currentScreenResolution.x}x{currentScreenResolution.y}");
|
||||
lastResolution = currentScreenResolution;
|
||||
|
||||
// 查找是否有匹配的配置
|
||||
var matchedConfig = FindMatchingResolutionConfig(currentScreenResolution.x, currentScreenResolution.y);
|
||||
if (matchedConfig != null)
|
||||
{
|
||||
Debug.Log($"[画报系统] 匹配到已保存的分辨率配置: 屏幕={matchedConfig.width}x{matchedConfig.height}, 背景={matchedConfig.backgroundWidth}x{matchedConfig.backgroundHeight}");
|
||||
|
||||
// 等待背景尺寸调整到目标尺寸,然后自动恢复位置
|
||||
// 注:这里不立即恢复,等待下一次Update检测到背景尺寸匹配时再恢复
|
||||
}
|
||||
}
|
||||
|
||||
// 检查背景尺寸是否变化
|
||||
if (currentBackgroundSize != lastBackgroundSize)
|
||||
{
|
||||
Debug.Log($"[画报系统] 检测到背景尺寸变化: {lastBackgroundSize.x}x{lastBackgroundSize.y} -> {currentBackgroundSize.x}x{currentBackgroundSize.y}");
|
||||
lastBackgroundSize = currentBackgroundSize;
|
||||
|
||||
// 检查当前屏幕分辨率和背景尺寸是否匹配已保存的配置
|
||||
var matchedConfig = FindMatchingResolutionConfig(currentScreenResolution.x, currentScreenResolution.y);
|
||||
if (matchedConfig != null)
|
||||
{
|
||||
// 检查背景尺寸是否匹配
|
||||
bool backgroundMatches = Mathf.Approximately(currentBackgroundSize.x, matchedConfig.backgroundWidth) &&
|
||||
Mathf.Approximately(currentBackgroundSize.y, matchedConfig.backgroundHeight);
|
||||
|
||||
if (backgroundMatches)
|
||||
{
|
||||
Debug.Log($"[画报系统] 屏幕分辨率和背景尺寸匹配已保存的配置,自动恢复元素位置");
|
||||
|
||||
// 恢复所有元素到该配置下的位置
|
||||
RestoreItemsPosition((int)matchedConfig.backgroundWidth, (int)matchedConfig.backgroundHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 屏幕分辨率匹配但背景尺寸不匹配,使用插值
|
||||
Debug.Log($"[画报系统] 屏幕分辨率匹配但背景尺寸不匹配,使用插值计算位置");
|
||||
UpdateAllItemsPosition();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有匹配的配置,使用插值
|
||||
Debug.Log($"[画报系统] 未找到匹配的分辨率配置,使用插值计算位置");
|
||||
UpdateAllItemsPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前屏幕分辨率
|
||||
/// </summary>
|
||||
private Vector2Int GetCurrentScreenResolution()
|
||||
{
|
||||
var T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
|
||||
var GetSizeOfMainGameView = T.GetMethod("GetSizeOfMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
|
||||
var Res = GetSizeOfMainGameView.Invoke(null, null);
|
||||
var resolution = (Vector2)Res;
|
||||
return new Vector2Int((int)resolution.x, (int)resolution.y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找匹配的分辨率配置
|
||||
/// </summary>
|
||||
private ResolutionConfig FindMatchingResolutionConfig(int screenWidth, int screenHeight)
|
||||
{
|
||||
if (pictorialData == null || pictorialData.resolutionConfigs == null)
|
||||
return null;
|
||||
|
||||
return pictorialData.resolutionConfigs.Find(c => c.width == screenWidth && c.height == screenHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复元素到指定背景尺寸下的位置
|
||||
/// </summary>
|
||||
private void RestoreItemsPosition(int bgWidth, int bgHeight)
|
||||
{
|
||||
// 实时从场景中获取元素
|
||||
List<PictorialItem> sceneItems = new List<PictorialItem>();
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Transform child = transform.GetChild(i);
|
||||
PictorialItem item = child.GetComponent<PictorialItem>();
|
||||
if (item != null)
|
||||
{
|
||||
sceneItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
int restoredCount = 0;
|
||||
foreach (var item in sceneItems)
|
||||
{
|
||||
if (item != null && item.ItemData != null)
|
||||
{
|
||||
// 查找匹配的位置数据
|
||||
var posData = item.ItemData.positions.Find(p =>
|
||||
Mathf.Approximately(p.resolutionWidth, bgWidth) &&
|
||||
Mathf.Approximately(p.resolutionHeight, bgHeight));
|
||||
|
||||
if (posData != null)
|
||||
{
|
||||
// 直接恢复位置,不进行插值
|
||||
var rectTransform = item.GetComponent<RectTransform>();
|
||||
if (rectTransform != null)
|
||||
{
|
||||
rectTransform.anchoredPosition = posData.position;
|
||||
rectTransform.sizeDelta = posData.size;
|
||||
rectTransform.localEulerAngles = posData.rotation;
|
||||
rectTransform.localScale = posData.scale;
|
||||
|
||||
restoredCount++;
|
||||
Debug.Log($"[画报系统] 恢复元素位置: {item.ItemData.itemName}, pos={posData.position}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[画报系统] 元素位置恢复完成,成功恢复 {restoredCount}/{sceneItems.Count} 个元素");
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 加载画报数据
|
||||
/// </summary>
|
||||
public void LoadPictorialData(string json)
|
||||
{
|
||||
pictorialDataJson = json;
|
||||
|
||||
Debug.Log($"[画报系统] 开始加载画报数据 - json.Length={json?.Length ?? 0}");
|
||||
|
||||
try
|
||||
{
|
||||
pictorialData = JsonUtility.FromJson<PictorialData>(json);
|
||||
Debug.Log($"[画报系统] 成功加载画报数据: {pictorialData.pictorialName}, 元素数量: {pictorialData.items.Count}");
|
||||
|
||||
// 打印所有元素的名称
|
||||
if (pictorialData.items.Count > 0)
|
||||
{
|
||||
Debug.Log($"[画报系统] PictorialData中的元素列表:");
|
||||
for (int i = 0; i < pictorialData.items.Count; i++)
|
||||
{
|
||||
var item = pictorialData.items[i];
|
||||
Debug.Log($" [{i}] itemName: {item.itemName}, itemId: {item.itemId}, positions: {item.positions.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"[画报系统] 加载画报数据失败: {e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载画报数据对象
|
||||
/// </summary>
|
||||
public void LoadPictorialData(PictorialData data)
|
||||
{
|
||||
pictorialData = data;
|
||||
pictorialDataJson = JsonUtility.ToJson(data, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重绘画报(在编辑器中使用)
|
||||
/// </summary>
|
||||
public void RebuildPictorial()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (string.IsNullOrEmpty(pictorialDataJson))
|
||||
{
|
||||
Debug.LogWarning("画报数据为空,无法重绘");
|
||||
return;
|
||||
}
|
||||
|
||||
// 清除现有元素
|
||||
ClearItems();
|
||||
|
||||
// 加载数据
|
||||
LoadPictorialData(pictorialDataJson);
|
||||
|
||||
if (pictorialData == null)
|
||||
return;
|
||||
|
||||
// 创建画报元素
|
||||
foreach (var itemData in pictorialData.items)
|
||||
{
|
||||
CreatePictorialItem(itemData);
|
||||
}
|
||||
|
||||
// 获取当前背景尺寸用于调试
|
||||
Vector2 backgroundSize = rectTransform.rect.size;
|
||||
|
||||
// 更新记录的分辨率
|
||||
lastResolution = new Vector2Int((int)backgroundSize.x, (int)backgroundSize.y);
|
||||
|
||||
Debug.Log($"[画报系统] 画报重绘完成,共创建 {items.Count} 个元素,当前背景尺寸: {(int)backgroundSize.x}x{(int)backgroundSize.y}");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建画报元素
|
||||
/// </summary>
|
||||
private PictorialItem CreatePictorialItem(PictorialItemData itemData)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
GameObject itemObj = new GameObject(itemData.itemName);
|
||||
itemObj.transform.SetParent(transform, false);
|
||||
|
||||
// 添加RectTransform
|
||||
RectTransform itemRect = itemObj.AddComponent<RectTransform>();
|
||||
itemRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
itemRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
itemRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
itemRect.sizeDelta = itemData.defaultSize;
|
||||
|
||||
// 添加Image
|
||||
Image itemImage = itemObj.AddComponent<Image>();
|
||||
|
||||
// 加载图片
|
||||
if (!string.IsNullOrEmpty(itemData.imagePath))
|
||||
{
|
||||
Sprite sprite = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(itemData.imagePath);
|
||||
if (sprite != null)
|
||||
{
|
||||
itemImage.sprite = sprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] 无法加载元素图片: {itemData.imagePath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 添加PictorialItem组件
|
||||
PictorialItem item = itemObj.AddComponent<PictorialItem>();
|
||||
item.SetData(itemData);
|
||||
|
||||
items.Add(item);
|
||||
|
||||
return item;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有元素
|
||||
/// </summary>
|
||||
public void ClearItems()
|
||||
{
|
||||
Debug.Log($"[画报系统] 开始清除元素,当前items.Count={items.Count}, isPlaying={Application.isPlaying}");
|
||||
|
||||
// 实时从场景中获取子对象
|
||||
List<GameObject> childrenToDelete = new List<GameObject>();
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Transform child = transform.GetChild(i);
|
||||
// 只删除有PictorialItem组件的子对象
|
||||
if (child.GetComponent<PictorialItem>() != null)
|
||||
{
|
||||
childrenToDelete.Add(child.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[画报系统] 从场景中找到 {childrenToDelete.Count} 个画报元素");
|
||||
|
||||
// 删除找到的所有元素
|
||||
int deletedCount = 0;
|
||||
foreach (var obj in childrenToDelete)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
// 在删除前保存名字
|
||||
string objName = obj.name;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
DestroyImmediate(obj);
|
||||
Debug.Log($"[画报系统] 使用DestroyImmediate删除: {objName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(obj);
|
||||
Debug.Log($"[画报系统] 使用Destroy删除: {objName}");
|
||||
}
|
||||
#else
|
||||
Destroy(obj);
|
||||
#endif
|
||||
deletedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// 清空列表
|
||||
items.Clear();
|
||||
|
||||
// 清空画报数据引用
|
||||
pictorialData = null;
|
||||
|
||||
Debug.Log($"[画报系统] 元素清除完成,删除 {deletedCount} 个元素,items.Count={items.Count}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有画报元素
|
||||
/// </summary>
|
||||
public List<PictorialItem> GetAllItems()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新所有元素位置
|
||||
/// </summary>
|
||||
public void UpdateAllItemsPosition()
|
||||
{
|
||||
// 清理null引用
|
||||
items.RemoveAll(item => item == null);
|
||||
|
||||
// 实时从场景中获取元素
|
||||
List<PictorialItem> sceneItems = new List<PictorialItem>();
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Transform child = transform.GetChild(i);
|
||||
PictorialItem item = child.GetComponent<PictorialItem>();
|
||||
if (item != null)
|
||||
{
|
||||
sceneItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[画报系统] 开始更新所有元素位置,从场景找到 {sceneItems.Count} 个元素,items.Count={items.Count}");
|
||||
|
||||
int successCount = 0;
|
||||
foreach (var item in sceneItems)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
item.UpdatePosition();
|
||||
successCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[画报系统] 发现null元素,跳过");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[画报系统] 元素位置更新完成,成功更新 {successCount}/{sceneItems.Count} 个元素");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 959dd1fcd1f81dc43b0b8176863dbd6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Framework.UI.Pictorial
|
||||
{
|
||||
/// <summary>
|
||||
/// 画报数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PictorialData
|
||||
{
|
||||
/// <summary>
|
||||
/// 画报名称
|
||||
/// </summary>
|
||||
public string pictorialName;
|
||||
|
||||
/// <summary>
|
||||
/// 背景图片路径
|
||||
/// </summary>
|
||||
public string backgroundPath;
|
||||
|
||||
/// <summary>
|
||||
/// 背景默认尺寸
|
||||
/// </summary>
|
||||
public Vector2 backgroundSize;
|
||||
|
||||
/// <summary>
|
||||
/// 所有画报元素
|
||||
/// </summary>
|
||||
public List<PictorialItemData> items = new List<PictorialItemData>();
|
||||
|
||||
/// <summary>
|
||||
/// 保存的分辨率配置列表
|
||||
/// </summary>
|
||||
public List<ResolutionConfig> resolutionConfigs = new List<ResolutionConfig>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 画报元素数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PictorialItemData
|
||||
{
|
||||
/// <summary>
|
||||
/// 元素ID(唯一标识)
|
||||
/// </summary>
|
||||
public string itemId;
|
||||
|
||||
/// <summary>
|
||||
/// 元素名称
|
||||
/// </summary>
|
||||
public string itemName;
|
||||
|
||||
/// <summary>
|
||||
/// 元素图片路径
|
||||
/// </summary>
|
||||
public string imagePath;
|
||||
|
||||
/// <summary>
|
||||
/// 默认尺寸
|
||||
/// </summary>
|
||||
public Vector2 defaultSize;
|
||||
|
||||
/// <summary>
|
||||
/// 不同分辨率下的位置信息
|
||||
/// </summary>
|
||||
public List<ItemPositionData> positions = new List<ItemPositionData>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ResolutionConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 屏幕分辨率宽度
|
||||
/// </summary>
|
||||
public int width;
|
||||
|
||||
/// <summary>
|
||||
/// 屏幕分辨率高度
|
||||
/// </summary>
|
||||
public int height;
|
||||
|
||||
/// <summary>
|
||||
/// 对应的背景尺寸宽度
|
||||
/// </summary>
|
||||
public float backgroundWidth;
|
||||
|
||||
/// <summary>
|
||||
/// 对应的背景尺寸高度
|
||||
/// </summary>
|
||||
public float backgroundHeight;
|
||||
|
||||
/// <summary>
|
||||
/// 保存时间戳
|
||||
/// </summary>
|
||||
public string timestamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 元素位置数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ItemPositionData
|
||||
{
|
||||
/// <summary>
|
||||
/// 分辨率宽度
|
||||
/// </summary>
|
||||
public int resolutionWidth;
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率高度
|
||||
/// </summary>
|
||||
public int resolutionHeight;
|
||||
|
||||
/// <summary>
|
||||
/// 位置(anchoredPosition)
|
||||
/// </summary>
|
||||
public Vector2 position;
|
||||
|
||||
/// <summary>
|
||||
/// 尺寸(sizeDelta)
|
||||
/// </summary>
|
||||
public Vector2 size;
|
||||
|
||||
/// <summary>
|
||||
/// 旋转
|
||||
/// </summary>
|
||||
public Vector3 rotation;
|
||||
|
||||
/// <summary>
|
||||
/// 缩放
|
||||
/// </summary>
|
||||
public Vector3 scale;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c481006cb55f25b418d9018783ecd70d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,396 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Linq;
|
||||
|
||||
namespace Framework.UI.Pictorial
|
||||
{
|
||||
/// <summary>
|
||||
/// 画报元素组件
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[RequireComponent(typeof(Image))]
|
||||
[ExecuteAlways] // 允许在编辑器和运行时执行Update
|
||||
public class PictorialItem : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 元素ID
|
||||
/// </summary>
|
||||
[SerializeField] private string itemId;
|
||||
|
||||
/// <summary>
|
||||
/// 元素数据引用
|
||||
/// </summary>
|
||||
private PictorialItemData itemData;
|
||||
|
||||
private RectTransform rectTransform;
|
||||
private Image image;
|
||||
|
||||
// 运行时背景尺寸监测
|
||||
private Vector2 lastBackgroundSize;
|
||||
private const float CHECK_INTERVAL = 0.5f;
|
||||
private float lastCheckTime;
|
||||
private bool runtimeInitialized = false; // 运行时是否已初始化
|
||||
|
||||
public string ItemId => itemId;
|
||||
public PictorialItemData ItemData => itemData; // 添加公共属性
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
image = GetComponent<Image>();
|
||||
Debug.Log($"[画报系统] {name} Awake被调用 - rectTransform={rectTransform != null}, image={image != null}");
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log($"[画报系统] {name} Start被调用 - isPlaying={Application.isPlaying}, itemData={itemData != null}, parent={transform.parent?.name}");
|
||||
|
||||
// 运行时初始化移到Update中,因为Start()可能比PictorialBackground.Start()先执行
|
||||
// 这里只记录日志
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试从父节点的PictorialBackground获取数据
|
||||
/// </summary>
|
||||
private void TryLoadDataFromParent()
|
||||
{
|
||||
if (transform.parent == null)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} 无法加载数据 - 没有父节点");
|
||||
return;
|
||||
}
|
||||
|
||||
var background = transform.parent.GetComponent<PictorialBackground>();
|
||||
if (background == null)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} 无法加载数据 - 父节点没有PictorialBackground组件, parent={transform.parent.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = background.PictorialData;
|
||||
if (data == null)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} 无法加载数据 - PictorialBackground没有数据");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"[画报系统] {name} 尝试匹配数据 - 当前GameObject名称: '{name}', PictorialData元素数: {data.items.Count}");
|
||||
|
||||
// 根据名称查找匹配的itemData
|
||||
var matchedItem = data.items.Find(item => item.itemName == name);
|
||||
if (matchedItem != null)
|
||||
{
|
||||
Debug.Log($"[画报系统] {name} 从父节点加载数据成功 - positions数量: {matchedItem.positions.Count}");
|
||||
SetData(matchedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} 在PictorialData中找不到匹配的数据, 总元素数: {data.items.Count}");
|
||||
|
||||
// 打印所有可用的itemName供参考
|
||||
if (data.items.Count > 0)
|
||||
{
|
||||
Debug.Log($"[画报系统] 可用的itemName列表:");
|
||||
for (int i = 0; i < data.items.Count; i++)
|
||||
{
|
||||
Debug.Log($" [{i}] '{data.items[i].itemName}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// OnEnable只记录日志,不做运行时初始化
|
||||
// 因为OnEnable可能在Awake阶段被调用,此时Application.isPlaying可能为false
|
||||
Debug.Log($"[画报系统] {name} OnEnable被调用 - isPlaying={Application.isPlaying}, itemData={itemData != null}");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 运行时逻辑
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
// 运行时首次初始化
|
||||
if (!runtimeInitialized)
|
||||
{
|
||||
runtimeInitialized = true;
|
||||
Debug.Log($"[画报系统] {name} Update首次运行 - 尝试初始化");
|
||||
|
||||
// 尝试从父节点加载数据
|
||||
if (itemData == null)
|
||||
{
|
||||
TryLoadDataFromParent();
|
||||
}
|
||||
|
||||
// 初始化背景尺寸
|
||||
if (itemData != null)
|
||||
{
|
||||
RectTransform bgRect = transform.parent?.GetComponent<RectTransform>();
|
||||
if (bgRect != null)
|
||||
{
|
||||
lastBackgroundSize = bgRect.rect.size;
|
||||
Debug.Log($"[画报系统] {itemData.itemName} Update初始化 - 背景尺寸: {lastBackgroundSize.x}x{lastBackgroundSize.y}");
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} Update初始化失败 - itemData仍然为null");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 运行时没有数据则跳过
|
||||
if (itemData == null)
|
||||
{
|
||||
if (Time.frameCount % 300 == 0) // 每5秒(假设60fps)打印一次
|
||||
{
|
||||
Debug.Log($"[画报系统] {name} Update跳过 - itemData=null");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 限制检查频率
|
||||
if (Time.time - lastCheckTime < CHECK_INTERVAL)
|
||||
return;
|
||||
|
||||
lastCheckTime = Time.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 编辑器非运行模式
|
||||
// 检查是否需要重新加载数据(itemData为null或positions为空)
|
||||
if (itemData == null || itemData.positions.Count == 0)
|
||||
{
|
||||
// 尝试从父节点加载数据
|
||||
TryLoadDataFromParent();
|
||||
|
||||
// 如果还是没有数据,跳过
|
||||
if (itemData == null || itemData.positions.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 限制检查频率(编辑器模式使用realtimeSinceStartup)
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEngine.Time.realtimeSinceStartup - lastCheckTime < CHECK_INTERVAL)
|
||||
return;
|
||||
|
||||
lastCheckTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 获取当前背景尺寸
|
||||
RectTransform backgroundRect = transform.parent?.GetComponent<RectTransform>();
|
||||
if (backgroundRect == null)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {itemData.itemName} Update - 无法获取背景RectTransform, parent={transform.parent?.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 currentBackgroundSize = backgroundRect.rect.size;
|
||||
|
||||
// 初始化lastBackgroundSize(如果还没有初始化)
|
||||
if (lastBackgroundSize == Vector2.zero)
|
||||
{
|
||||
lastBackgroundSize = currentBackgroundSize;
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 初始化背景尺寸: {lastBackgroundSize.x}x{lastBackgroundSize.y}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查背景尺寸是否变化
|
||||
if (!Mathf.Approximately(currentBackgroundSize.x, lastBackgroundSize.x) ||
|
||||
!Mathf.Approximately(currentBackgroundSize.y, lastBackgroundSize.y))
|
||||
{
|
||||
string mode = Application.isPlaying ? "运行时" : "编辑器";
|
||||
Debug.Log($"[画报系统] {itemData.itemName} {mode}检测到背景尺寸变化: {lastBackgroundSize.x}x{lastBackgroundSize.y} -> {currentBackgroundSize.x}x{currentBackgroundSize.y}");
|
||||
lastBackgroundSize = currentBackgroundSize;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置元素数据
|
||||
/// </summary>
|
||||
public void SetData(PictorialItemData data)
|
||||
{
|
||||
itemData = data;
|
||||
itemId = data.itemId;
|
||||
name = data.itemName;
|
||||
|
||||
Debug.Log($"[画报系统] {name} SetData被调用 - isPlaying={Application.isPlaying}");
|
||||
|
||||
// 运行时初始化背景尺寸
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
RectTransform backgroundRect = transform.parent?.GetComponent<RectTransform>();
|
||||
if (backgroundRect != null)
|
||||
{
|
||||
lastBackgroundSize = backgroundRect.rect.size;
|
||||
Debug.Log($"[画报系统] {name} SetData - 初始化背景尺寸: {lastBackgroundSize.x}x{lastBackgroundSize.y}");
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新位置
|
||||
/// </summary>
|
||||
public void UpdatePosition()
|
||||
{
|
||||
if (itemData == null || itemData.positions.Count == 0)
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {name} 无法更新位置:itemData={itemData != null}, positions={itemData?.positions.Count ?? 0}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保组件已初始化
|
||||
if (rectTransform == null)
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
if (rectTransform == null)
|
||||
{
|
||||
Debug.LogError($"[画报系统] {name} PictorialItem缺少RectTransform组件");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取背景的实际尺寸
|
||||
RectTransform backgroundRect = transform.parent?.GetComponent<RectTransform>();
|
||||
if (backgroundRect == null)
|
||||
{
|
||||
Debug.LogError($"[画报系统] {name} 无法获取背景RectTransform");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 backgroundSize = backgroundRect.rect.size;
|
||||
int currentWidth = (int)backgroundSize.x;
|
||||
int currentHeight = (int)backgroundSize.y;
|
||||
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 更新位置 - 使用背景尺寸: {currentWidth}x{currentHeight}");
|
||||
|
||||
// 计算插值位置
|
||||
ItemPositionData interpolatedPos = InterpolatePosition(currentWidth, currentHeight);
|
||||
|
||||
if (interpolatedPos != null)
|
||||
{
|
||||
Vector2 oldPos = rectTransform.anchoredPosition;
|
||||
rectTransform.anchoredPosition = interpolatedPos.position;
|
||||
rectTransform.sizeDelta = interpolatedPos.size;
|
||||
rectTransform.localEulerAngles = interpolatedPos.rotation;
|
||||
rectTransform.localScale = interpolatedPos.scale;
|
||||
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 位置已更新: {oldPos} -> {interpolatedPos.position}, size: {interpolatedPos.size}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[画报系统] {itemData.itemName} 插值计算返回null");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 插值计算当前分辨率下的位置
|
||||
/// </summary>
|
||||
private ItemPositionData InterpolatePosition(int targetWidth, int targetHeight)
|
||||
{
|
||||
if (itemData.positions.Count == 0)
|
||||
return null;
|
||||
|
||||
// 按分辨率宽度排序
|
||||
var sortedPositions = itemData.positions.OrderBy(p => p.resolutionWidth).ToList();
|
||||
|
||||
// 如果只有一个配置,直接返回
|
||||
if (sortedPositions.Count == 1)
|
||||
{
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 只有一个分辨率配置: {sortedPositions[0].resolutionWidth}x{sortedPositions[0].resolutionHeight}");
|
||||
return sortedPositions[0];
|
||||
}
|
||||
|
||||
// 查找最接近的两个分辨率配置
|
||||
ItemPositionData lowerPos = null;
|
||||
ItemPositionData upperPos = null;
|
||||
|
||||
for (int i = 0; i < sortedPositions.Count; i++)
|
||||
{
|
||||
if (sortedPositions[i].resolutionWidth <= targetWidth)
|
||||
{
|
||||
lowerPos = sortedPositions[i];
|
||||
}
|
||||
|
||||
if (sortedPositions[i].resolutionWidth >= targetWidth)
|
||||
{
|
||||
upperPos = sortedPositions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果目标宽度小于最小配置,使用最小配置
|
||||
if (lowerPos == null)
|
||||
{
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 目标分辨率{targetWidth}x{targetHeight}小于最小配置,使用: {sortedPositions[0].resolutionWidth}x{sortedPositions[0].resolutionHeight}");
|
||||
return sortedPositions[0];
|
||||
}
|
||||
|
||||
// 如果目标宽度大于最大配置,使用最大配置
|
||||
if (upperPos == null)
|
||||
{
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 目标分辨率{targetWidth}x{targetHeight}大于最大配置,使用: {sortedPositions[sortedPositions.Count - 1].resolutionWidth}x{sortedPositions[sortedPositions.Count - 1].resolutionHeight}");
|
||||
return sortedPositions[sortedPositions.Count - 1];
|
||||
}
|
||||
|
||||
// 如果找到精确匹配
|
||||
if (lowerPos == upperPos)
|
||||
{
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 精确匹配分辨率: {lowerPos.resolutionWidth}x{lowerPos.resolutionHeight}, 位置: {lowerPos.position}");
|
||||
return lowerPos;
|
||||
}
|
||||
|
||||
// 线性插值
|
||||
float t = (float)(targetWidth - lowerPos.resolutionWidth) /
|
||||
(upperPos.resolutionWidth - lowerPos.resolutionWidth);
|
||||
|
||||
ItemPositionData result = new ItemPositionData
|
||||
{
|
||||
resolutionWidth = targetWidth,
|
||||
resolutionHeight = targetHeight,
|
||||
position = Vector2.Lerp(lowerPos.position, upperPos.position, t),
|
||||
size = Vector2.Lerp(lowerPos.size, upperPos.size, t),
|
||||
rotation = Vector3.Lerp(lowerPos.rotation, upperPos.rotation, t),
|
||||
scale = Vector3.Lerp(lowerPos.scale, upperPos.scale, t)
|
||||
};
|
||||
|
||||
Debug.Log($"[画报系统] {itemData.itemName} 插值计算 - 目标:{targetWidth}x{targetHeight}, 下限:{lowerPos.resolutionWidth}x{lowerPos.resolutionHeight}, 上限:{upperPos.resolutionWidth}x{upperPos.resolutionHeight}, t={t:F2}, 结果位置:{result.position}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存当前位置信息
|
||||
/// </summary>
|
||||
public ItemPositionData SaveCurrentPosition()
|
||||
{
|
||||
// 确保组件已初始化
|
||||
if (rectTransform == null)
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
// 获取背景尺寸
|
||||
RectTransform backgroundRect = transform.parent?.GetComponent<RectTransform>();
|
||||
Vector2 backgroundSize = backgroundRect != null ? backgroundRect.rect.size : Vector2.zero;
|
||||
|
||||
return new ItemPositionData
|
||||
{
|
||||
resolutionWidth = (int)backgroundSize.x,
|
||||
resolutionHeight = (int)backgroundSize.y,
|
||||
position = rectTransform.anchoredPosition,
|
||||
size = rectTransform.sizeDelta,
|
||||
rotation = rectTransform.localEulerAngles,
|
||||
scale = rectTransform.localScale
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2a45ee4c5f287924692f425d857a0b21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d77c924148b0efc4586708ffad25f4f7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Framework.UI.Pictorial;
|
||||
|
||||
namespace PictorialEditor
|
||||
{
|
||||
[CustomEditor(typeof(PictorialBackground))]
|
||||
public class PictorialBackgroundEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PictorialBackground background = (PictorialBackground)target;
|
||||
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("画报操作", EditorStyles.boldLabel);
|
||||
|
||||
if (GUILayout.Button("重绘画报", GUILayout.Height(30)))
|
||||
{
|
||||
background.RebuildPictorial();
|
||||
EditorUtility.SetDirty(background);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("清除所有元素", GUILayout.Height(30)))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("确认清除", "确定要清除所有画报元素吗?", "确定", "取消"))
|
||||
{
|
||||
background.ClearItems();
|
||||
EditorUtility.SetDirty(background);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("更新元素位置", GUILayout.Height(30)))
|
||||
{
|
||||
background.UpdateAllItemsPosition();
|
||||
EditorUtility.SetDirty(background);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c3e3979c704f12f44bac5ab8ddcf4c5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,975 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &142384204
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 142384205}
|
||||
- component: {fileID: 142384208}
|
||||
- component: {fileID: 142384207}
|
||||
- component: {fileID: 142384206}
|
||||
m_Layer: 0
|
||||
m_Name: Item_Poster_Full_A00011
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &142384205
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 142384204}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1864423311}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 712.2807, y: 0}
|
||||
m_SizeDelta: {x: 1000, y: 1000}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &142384206
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 142384204}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2a45ee4c5f287924692f425d857a0b21, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
itemId: a3315d9e-543b-46d9-bb71-15d0184a403f
|
||||
--- !u!114 &142384207
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 142384204}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 188bceea84681da46b548b70c874f000, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &142384208
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 142384204}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &145043008
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 145043009}
|
||||
- component: {fileID: 145043012}
|
||||
- component: {fileID: 145043011}
|
||||
- component: {fileID: 145043010}
|
||||
m_Layer: 0
|
||||
m_Name: Item_Poster_Full_A00084
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &145043009
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 145043008}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1864423311}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -712.2807, y: 0}
|
||||
m_SizeDelta: {x: 1000, y: 1000}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &145043010
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 145043008}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2a45ee4c5f287924692f425d857a0b21, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
itemId: 636a02b8-99d7-4003-b71b-3a24e33ddb6f
|
||||
--- !u!114 &145043011
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 145043008}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 8d84383903be64840bde32d3b1e4478a, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &145043012
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 145043008}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &410089546
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 410089550}
|
||||
- component: {fileID: 410089549}
|
||||
- component: {fileID: 410089548}
|
||||
- component: {fileID: 410089547}
|
||||
m_Layer: 5
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &410089547
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410089546}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4194303
|
||||
--- !u!114 &410089548
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410089546}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!223 &410089549
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410089546}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 1
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!224 &410089550
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 410089546}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 655091519}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1001 &655091518
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 410089550}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1906464270324237561, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_Sprite
|
||||
value:
|
||||
objectReference: {fileID: 21300000, guid: 5a84c2b3846029b40b18da0169d6ceb3,
|
||||
type: 3}
|
||||
- target: {fileID: 6900747949703306378, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: UI_DrawMainPanelNew
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects:
|
||||
- {fileID: 2206807862819451585, guid: 0237158083cad3b49a81e2a887b344c2, type: 3}
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 9187515146072176872, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 145043009}
|
||||
- targetCorrespondingSourceObject: {fileID: 9187515146072176872, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1004594402}
|
||||
- targetCorrespondingSourceObject: {fileID: 9187515146072176872, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 142384205}
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 2801276852109929304, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1864423312}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 0237158083cad3b49a81e2a887b344c2, type: 3}
|
||||
--- !u!224 &655091519 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 7904143998750432161, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 655091518}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1004594401
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1004594402}
|
||||
- component: {fileID: 1004594405}
|
||||
- component: {fileID: 1004594404}
|
||||
- component: {fileID: 1004594403}
|
||||
m_Layer: 0
|
||||
m_Name: Item_Poster_Full_A00003
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1004594402
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1004594401}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1864423311}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 1000, y: 1000}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1004594403
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1004594401}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2a45ee4c5f287924692f425d857a0b21, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
itemId: 05c20e39-0651-4330-afa6-4758bf3f1d7c
|
||||
--- !u!114 &1004594404
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1004594401}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: bc3faf81ad097044f8066834e40dfcfd, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &1004594405
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1004594401}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1441365002
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1441365006}
|
||||
- component: {fileID: 1441365005}
|
||||
- component: {fileID: 1441365004}
|
||||
- component: {fileID: 1441365003}
|
||||
m_Layer: 0
|
||||
m_Name: Camera
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1441365003
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1441365002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RenderShadows: 1
|
||||
m_RequiresDepthTextureOption: 2
|
||||
m_RequiresOpaqueTextureOption: 2
|
||||
m_CameraType: 0
|
||||
m_Cameras: []
|
||||
m_RendererIndex: -1
|
||||
m_VolumeLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
m_VolumeTrigger: {fileID: 0}
|
||||
m_VolumeFrameworkUpdateModeOption: 2
|
||||
m_RenderPostProcessing: 0
|
||||
m_Antialiasing: 0
|
||||
m_AntialiasingQuality: 2
|
||||
m_StopNaN: 0
|
||||
m_Dithering: 0
|
||||
m_ClearDepth: 1
|
||||
m_AllowXRRendering: 1
|
||||
m_AllowHDROutput: 1
|
||||
m_UseScreenCoordOverride: 0
|
||||
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
m_Quality: 3
|
||||
m_FrameInfluence: 0.1
|
||||
m_JitterScale: 1
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
--- !u!81 &1441365004
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1441365002}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &1441365005
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1441365002}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1441365006
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1441365002}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -998.64105, y: -1004.2176, z: 4.931437}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1864423310 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2801276852109929304, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 655091518}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!224 &1864423311 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 9187515146072176872, guid: 0237158083cad3b49a81e2a887b344c2,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 655091518}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1864423312
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1864423310}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 959dd1fcd1f81dc43b0b8176863dbd6b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
pictorialDataJson: "{\n \"pictorialName\": \"NewPictorial\",\n \"backgroundPath\":
|
||||
\"Assets/Art/UI/Texture/ALLBG/Login/BG_Login.png\",\n \"backgroundSize\":
|
||||
{\n \"x\": 2048.0,\n \"y\": 1317.0\n },\n \"items\": [\n
|
||||
{\n \"itemId\": \"636a02b8-99d7-4003-b71b-3a24e33ddb6f\",\n
|
||||
\"itemName\": \"Item_Poster_Full_A00084\",\n \"imagePath\": \"Assets/Art_Out/UI/SplitTexture/Poster/Poster_Default/Poster_Full_A00084.png\",\n
|
||||
\"defaultSize\": {\n \"x\": 1000.0,\n \"y\": 1000.0\n
|
||||
},\n \"positions\": [\n {\n \"resolutionWidth\":
|
||||
2469,\n \"resolutionHeight\": 1079,\n \"position\":
|
||||
{\n \"x\": -800.0,\n \"y\": 0.0\n
|
||||
},\n \"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n },\n {\n
|
||||
\"resolutionWidth\": 1557,\n \"resolutionHeight\": 919,\n
|
||||
\"position\": {\n \"x\": -600.0,\n
|
||||
\"y\": 0.0\n },\n \"size\": {\n
|
||||
\"x\": 1000.0,\n \"y\": 1000.0\n },\n
|
||||
\"rotation\": {\n \"x\": 0.0,\n
|
||||
\"y\": 0.0,\n \"z\": 0.0\n },\n
|
||||
\"scale\": {\n \"x\": 1.0,\n \"y\":
|
||||
1.0,\n \"z\": 1.0\n }\n
|
||||
},\n {\n \"resolutionWidth\": 789,\n
|
||||
\"resolutionHeight\": 359,\n \"position\": {\n
|
||||
\"x\": -300.0,\n \"y\": 0.0\n },\n
|
||||
\"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n }\n ]\n },\n
|
||||
{\n \"itemId\": \"05c20e39-0651-4330-afa6-4758bf3f1d7c\",\n
|
||||
\"itemName\": \"Item_Poster_Full_A00003\",\n \"imagePath\": \"Assets/Art_Out/UI/SplitTexture/Poster/Poster_Default/Poster_Full_A00003.png\",\n
|
||||
\"defaultSize\": {\n \"x\": 1000.0,\n \"y\": 1000.0\n
|
||||
},\n \"positions\": [\n {\n \"resolutionWidth\":
|
||||
2469,\n \"resolutionHeight\": 1079,\n \"position\":
|
||||
{\n \"x\": 0.0,\n \"y\": 0.0\n
|
||||
},\n \"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n },\n {\n
|
||||
\"resolutionWidth\": 1557,\n \"resolutionHeight\": 919,\n
|
||||
\"position\": {\n \"x\": 0.0,\n
|
||||
\"y\": 0.0\n },\n \"size\": {\n
|
||||
\"x\": 1000.0,\n \"y\": 1000.0\n },\n
|
||||
\"rotation\": {\n \"x\": 0.0,\n
|
||||
\"y\": 0.0,\n \"z\": 0.0\n },\n
|
||||
\"scale\": {\n \"x\": 1.0,\n \"y\":
|
||||
1.0,\n \"z\": 1.0\n }\n
|
||||
},\n {\n \"resolutionWidth\": 789,\n
|
||||
\"resolutionHeight\": 359,\n \"position\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0\n },\n
|
||||
\"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n }\n ]\n },\n
|
||||
{\n \"itemId\": \"a3315d9e-543b-46d9-bb71-15d0184a403f\",\n
|
||||
\"itemName\": \"Item_Poster_Full_A00011\",\n \"imagePath\": \"Assets/Art_Out/UI/SplitTexture/Poster/Poster_Default/Poster_Full_A00011.png\",\n
|
||||
\"defaultSize\": {\n \"x\": 1000.0,\n \"y\": 1000.0\n
|
||||
},\n \"positions\": [\n {\n \"resolutionWidth\":
|
||||
2469,\n \"resolutionHeight\": 1079,\n \"position\":
|
||||
{\n \"x\": 800.0,\n \"y\": 0.0\n
|
||||
},\n \"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n },\n {\n
|
||||
\"resolutionWidth\": 1557,\n \"resolutionHeight\": 919,\n
|
||||
\"position\": {\n \"x\": 600.0,\n
|
||||
\"y\": 0.0\n },\n \"size\": {\n
|
||||
\"x\": 1000.0,\n \"y\": 1000.0\n },\n
|
||||
\"rotation\": {\n \"x\": 0.0,\n
|
||||
\"y\": 0.0,\n \"z\": 0.0\n },\n
|
||||
\"scale\": {\n \"x\": 1.0,\n \"y\":
|
||||
1.0,\n \"z\": 1.0\n }\n
|
||||
},\n {\n \"resolutionWidth\": 789,\n
|
||||
\"resolutionHeight\": 359,\n \"position\": {\n
|
||||
\"x\": 300.0,\n \"y\": 0.0\n },\n
|
||||
\"size\": {\n \"x\": 1000.0,\n
|
||||
\"y\": 1000.0\n },\n \"rotation\": {\n
|
||||
\"x\": 0.0,\n \"y\": 0.0,\n \"z\":
|
||||
0.0\n },\n \"scale\": {\n
|
||||
\"x\": 1.0,\n \"y\": 1.0,\n \"z\":
|
||||
1.0\n }\n }\n ]\n }\n
|
||||
],\n \"resolutionConfigs\": [\n {\n \"width\": 2960,\n
|
||||
\"height\": 1440,\n \"backgroundWidth\": 2469.1298828125,\n
|
||||
\"backgroundHeight\": 1079.0,\n \"timestamp\": \"2026-01-15 19:45:27\"\n
|
||||
},\n {\n \"width\": 2048,\n \"height\": 1280,\n
|
||||
\"backgroundWidth\": 1557.1300048828125,\n \"backgroundHeight\": 919.0,\n
|
||||
\"timestamp\": \"2026-01-15 19:46:00\"\n },\n {\n \"width\":
|
||||
1280,\n \"height\": 720,\n \"backgroundWidth\": 789.1300048828125,\n
|
||||
\"backgroundHeight\": 359.0,\n \"timestamp\": \"2026-01-15 19:46:48\"\n
|
||||
}\n ]\n}"
|
||||
--- !u!1 &2020995281
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2020995284}
|
||||
- component: {fileID: 2020995283}
|
||||
- component: {fileID: 2020995282}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &2020995282
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2020995281}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &2020995283
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2020995281}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &2020995284
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2020995281}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 410089550}
|
||||
- {fileID: 2020995284}
|
||||
- {fileID: 1441365006}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 618e38885fbd12f48a88e30bfd638559
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e887851f61247c44be0ed50314c1526
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,498 @@
|
|||
# 画报系统使用说明
|
||||
|
||||
## 目录
|
||||
- [系统概述](#系统概述)
|
||||
- [编辑器使用指南](#编辑器使用指南)
|
||||
- [1. 打开画报编辑器](#1-打开画报编辑器)
|
||||
- [2. 新建画报](#2-新建画报)
|
||||
- [3. 打开已有画报](#3-打开已有画报)
|
||||
- [4. 添加画报元素](#4-添加画报元素)
|
||||
- [5. 分辨率配置](#5-分辨率配置)
|
||||
- [6. 保存画报数据](#6-保存画报数据)
|
||||
- [运行时使用指南](#运行时使用指南)
|
||||
- [常见问题](#常见问题)
|
||||
|
||||
---
|
||||
|
||||
## 系统概述
|
||||
|
||||
画报系统是一个支持多分辨率自适应的 UI 内容展示系统,主要功能包括:
|
||||
|
||||
- ✅ **多分辨率适配**:支持保存多个分辨率下的元素位置配置
|
||||
- ✅ **自动位置计算**:运行时和编辑器模式下自动根据分辨率调整元素位置
|
||||
- ✅ **插值平滑过渡**:未配置的分辨率通过插值算法平滑计算位置
|
||||
- ✅ **可视化编辑**:所见即所得的画报编辑器
|
||||
- ✅ **数据持久化**:JSON 格式保存,支持导入导出
|
||||
|
||||
---
|
||||
|
||||
## 编辑器使用指南
|
||||
|
||||
### 1. 打开画报编辑器
|
||||
|
||||
**路径:** `Tools → 画报编辑器`
|
||||
|
||||
打开后会自动加载画报编辑器场景(`Assets/Editor/Pictorial/PictorialEditor.unity`)。
|
||||
|
||||
**编辑器界面说明:**
|
||||
```
|
||||
┌─ 画报编辑器 ─────────────────────────┐
|
||||
│ 1. 新建画报 │
|
||||
│ 2. 画报元素管理 │
|
||||
│ 3. 添加画报元素 │
|
||||
│ 4. 分辨率配置 │
|
||||
│ 5. 保存画报数据 │
|
||||
└──────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. 新建画报
|
||||
|
||||
#### 步骤 1:设置画报名称
|
||||
```
|
||||
画报名称: [MyPictorial]
|
||||
```
|
||||
输入画报的名称,用于标识和文件命名。
|
||||
|
||||
#### 步骤 2:选择背景图片
|
||||
```
|
||||
选择背景图片: [None (Sprite)] [⊙]
|
||||
```
|
||||
点击选择器按钮,选择画报的背景图片(需要是 Sprite 类型)。
|
||||
|
||||
#### 步骤 3:创建画报
|
||||
```
|
||||
[ 创建画报背景 ] [ 打开已有画报 ]
|
||||
```
|
||||
点击 **"创建画报背景"** 按钮。
|
||||
|
||||
**结果:**
|
||||
- 清空场景中的旧元素
|
||||
- 创建新的画报数据
|
||||
- 设置背景图片到 `Canvas/UI_DrawMainPanelNew/UI_DrawMainPanel/Mid/Image_Right/Image_CharacterBg`
|
||||
- 显示画报元素管理界面
|
||||
|
||||
---
|
||||
|
||||
### 3. 打开已有画报
|
||||
|
||||
#### 步骤 1:点击打开按钮
|
||||
```
|
||||
[ 创建画报背景 ] [ 打开已有画报 ]
|
||||
↑ 点击这里
|
||||
```
|
||||
|
||||
#### 步骤 2:选择 JSON 文件
|
||||
在弹出的文件选择对话框中:
|
||||
- 默认路径:`Assets/Resources/Pictorial`
|
||||
- 文件类型:`.json`
|
||||
- 选择目标画报的 JSON 文件
|
||||
|
||||
#### 步骤 3:自动加载
|
||||
系统会自动完成:
|
||||
- ✅ 解析 JSON 数据
|
||||
- ✅ 清理场景中的旧元素
|
||||
- ✅ 加载背景图片
|
||||
- ✅ 恢复所有画报元素
|
||||
- ✅ 根据当前分辨率重新计算元素位置
|
||||
|
||||
**加载结果示例:**
|
||||
```
|
||||
┌─ 加载成功 ─────────────────────┐
|
||||
│ 画报加载完成 │
|
||||
│ 画报名称: MyPictorial │
|
||||
│ 元素总数: 15 │
|
||||
│ 成功恢复: 15 │
|
||||
│ 失败: 0 │
|
||||
│ 分辨率配置: 3 │
|
||||
│ │
|
||||
│ [ 确定 ] │
|
||||
└────────────────────────────────┘
|
||||
```
|
||||
|
||||
**位置恢复策略:**
|
||||
- **精确匹配**:当前分辨率与保存的配置完全匹配时,直接恢复保存的位置
|
||||
- **插值计算**:当前分辨率与保存的配置不匹配时,通过多个配置进行线性插值
|
||||
|
||||
---
|
||||
|
||||
### 4. 添加画报元素
|
||||
|
||||
#### 步骤 1:设置元素尺寸
|
||||
```
|
||||
默认元素尺寸: [1000] [1000]
|
||||
```
|
||||
设置新添加元素的默认尺寸(宽 x 高)。
|
||||
|
||||
#### 步骤 2:配置文件名前缀
|
||||
```
|
||||
元素文件名前缀: [Poster_Full ] [清空]
|
||||
```
|
||||
- 设置前缀后,选择图片时会自动在搜索框中填入此前缀
|
||||
- 帮助快速筛选图片资源
|
||||
- 默认值:`Poster_Full`
|
||||
|
||||
**提示:** 点击'选择图片'按钮时,会自动在搜索框中填入前缀进行筛选。
|
||||
|
||||
#### 步骤 3:选择元素图片
|
||||
```
|
||||
选择元素图片: [None (Sprite)] [选择图片]
|
||||
↑ 点击
|
||||
```
|
||||
点击"选择图片"按钮:
|
||||
- 自动打开资源选择器
|
||||
- 搜索框自动填入前缀(如 `Poster_Full`)
|
||||
- 快速定位目标图片
|
||||
|
||||
#### 步骤 4:添加元素
|
||||
```
|
||||
[ 添加元素 ]
|
||||
```
|
||||
点击按钮后:
|
||||
- 在场景中创建元素 GameObject
|
||||
- 元素名称:`Item_` + 图片名称(如 `Item_Poster_Full_A00001`)
|
||||
- 默认位置:居中(0, 0)
|
||||
- 自动选中新元素,可在场景中拖动调整位置
|
||||
|
||||
**重要:** 元素的 GameObject 名称必须与数据中的 `itemName` 一致,以便正确加载位置数据。
|
||||
|
||||
---
|
||||
|
||||
### 5. 分辨率配置
|
||||
|
||||
#### 当前分辨率显示
|
||||
```
|
||||
ℹ️ 当前Game窗口分辨率: 1920 x 1080
|
||||
请在Game窗口工具栏调整分辨率到目标分辨率,然后保存配置
|
||||
```
|
||||
|
||||
#### 保存分辨率配置
|
||||
|
||||
**步骤 1:调整 Game 窗口分辨率**
|
||||
在 Unity 编辑器的 Game 窗口工具栏:
|
||||
1. 点击分辨率下拉菜单
|
||||
2. 选择目标分辨率(如 1920x1080)
|
||||
3. 等待背景尺寸自动调整
|
||||
|
||||
**步骤 2:调整元素位置**
|
||||
- 在场景视图中拖动元素到合适位置
|
||||
- 调整元素的尺寸、旋转、缩放
|
||||
|
||||
**步骤 3:保存配置**
|
||||
```
|
||||
[ 保存当前分辨率数据 ]
|
||||
```
|
||||
点击按钮后:
|
||||
- 保存当前屏幕分辨率
|
||||
- 保存当前背景尺寸
|
||||
- 保存所有元素在当前分辨率下的位置、尺寸、旋转、缩放
|
||||
|
||||
**成功提示:**
|
||||
```
|
||||
┌─ 保存成功 ─────────────────────┐
|
||||
│ 已保存分辨率数据 │
|
||||
│ 屏幕分辨率: 1920x1080 │
|
||||
│ 背景尺寸: 1800x1000 │
|
||||
│ 元素数量: 15 │
|
||||
│ │
|
||||
│ [ 确定 ] │
|
||||
└────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### 已保存的分辨率列表
|
||||
```
|
||||
已保存的分辨率:
|
||||
• 1920 x 1080 [2024-01-15 10:30:00] [删除]
|
||||
• 2560 x 1440 [2024-01-15 10:35:00] [删除]
|
||||
• 1280 x 720 [2024-01-15 10:40:00] [删除]
|
||||
```
|
||||
|
||||
点击"删除"按钮会:
|
||||
- 删除该分辨率配置
|
||||
- 删除所有元素在该分辨率下的位置数据
|
||||
- 需要确认操作
|
||||
|
||||
---
|
||||
|
||||
### 6. 保存画报数据
|
||||
|
||||
#### 设置保存路径
|
||||
```
|
||||
保存路径: [Assets/Resources/Pictorial/]
|
||||
```
|
||||
设置 JSON 文件的保存路径。
|
||||
|
||||
#### 保存选项
|
||||
|
||||
**方案1:保存画报数据**
|
||||
```
|
||||
[ 保存画报数据 ] [ 导出JSON ]
|
||||
```
|
||||
- 保存到指定路径的 JSON 文件
|
||||
- 文件名:`{画报名称}.json`
|
||||
- 包含所有元素数据和分辨率配置
|
||||
|
||||
**方案2:导出 JSON**
|
||||
- 弹出文件保存对话框
|
||||
- 可选择保存位置和文件名
|
||||
- 适合导出到项目外或备份
|
||||
|
||||
**JSON 数据结构:**
|
||||
```json
|
||||
{
|
||||
"pictorialName": "MyPictorial",
|
||||
"backgroundPath": "Assets/Art/Bg_01.png",
|
||||
"backgroundSize": {"x": 1920, "y": 1080},
|
||||
"items": [
|
||||
{
|
||||
"itemId": "uuid-xxx",
|
||||
"itemName": "Item_Poster_Full_A00001",
|
||||
"imagePath": "Assets/Art/Items/Poster_Full_A00001.png",
|
||||
"defaultSize": {"x": 1000, "y": 1000},
|
||||
"positions": [
|
||||
{
|
||||
"resolutionWidth": 1920,
|
||||
"resolutionHeight": 1080,
|
||||
"position": {"x": 100, "y": 200},
|
||||
"size": {"x": 1000, "y": 1000},
|
||||
"rotation": {"x": 0, "y": 0, "z": 0},
|
||||
"scale": {"x": 1, "y": 1, "z": 1}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"resolutionConfigs": [
|
||||
{
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"backgroundWidth": 1800,
|
||||
"backgroundHeight": 1000,
|
||||
"timestamp": "2024-01-15 10:30:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 运行时使用指南
|
||||
|
||||
### 1. 在场景中使用画报
|
||||
|
||||
#### 步骤 1:创建画报背景对象
|
||||
```csharp
|
||||
// 创建 GameObject
|
||||
GameObject bgObj = new GameObject("PictorialBg");
|
||||
|
||||
// 添加 RectTransform
|
||||
RectTransform bgRect = bgObj.AddComponent<RectTransform>();
|
||||
bgRect.sizeDelta = new Vector2(1920, 1080);
|
||||
|
||||
// 添加 Image 组件
|
||||
Image bgImage = bgObj.AddComponent<Image>();
|
||||
|
||||
// 添加 PictorialBackground 组件
|
||||
PictorialBackground background = bgObj.AddComponent<PictorialBackground>();
|
||||
```
|
||||
|
||||
#### 步骤 2:加载画报数据
|
||||
```csharp
|
||||
// 从 Resources 加载 JSON
|
||||
TextAsset jsonAsset = Resources.Load<TextAsset>("Pictorial/MyPictorial");
|
||||
string jsonContent = jsonAsset.text;
|
||||
|
||||
// 加载到背景组件
|
||||
background.LoadPictorialData(jsonContent);
|
||||
```
|
||||
|
||||
#### 步骤 3:重绘画报(创建元素)
|
||||
```csharp
|
||||
// 重绘会自动创建所有元素
|
||||
background.RebuildPictorial();
|
||||
```
|
||||
|
||||
**注意:** `RebuildPictorial()` 只能在编辑器模式下调用,运行时需要手动创建元素对象。
|
||||
|
||||
---
|
||||
|
||||
### 2. 运行时自动适配
|
||||
|
||||
画报元素在运行时会自动适配分辨率变化:
|
||||
|
||||
#### PictorialItem 组件
|
||||
- 自动检测背景尺寸变化(每 0.5 秒检查一次)
|
||||
- 根据保存的多个分辨率配置进行插值计算
|
||||
- 自动更新元素的位置、尺寸、旋转、缩放
|
||||
|
||||
#### 监测机制
|
||||
```csharp
|
||||
// 在 PictorialItem.Update() 中
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
// 运行时检查背景尺寸变化
|
||||
if (背景尺寸变化)
|
||||
{
|
||||
UpdatePosition(); // 重新计算位置
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. 编辑器模式自动适配
|
||||
|
||||
在编辑器非运行状态下:
|
||||
|
||||
#### PictorialBackground 组件
|
||||
```csharp
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
// 每 0.1 秒检查一次屏幕分辨率和背景尺寸
|
||||
if (屏幕分辨率变化 || 背景尺寸变化)
|
||||
{
|
||||
// 查找匹配的分辨率配置
|
||||
var config = FindMatchingResolutionConfig();
|
||||
|
||||
if (配置匹配)
|
||||
{
|
||||
RestoreItemsPosition(); // 精确恢复
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateAllItemsPosition(); // 插值计算
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
**好处:**
|
||||
- 在编辑器中调整 Game 窗口分辨率时,元素自动调整
|
||||
- 实时预览不同分辨率下的效果
|
||||
- 无需进入运行模式
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q1: 打开画报后元素位置不正确?
|
||||
|
||||
**原因:** 当前分辨率与保存的配置不匹配。
|
||||
|
||||
**解决方案:**
|
||||
1. 检查 Game 窗口的当前分辨率
|
||||
2. 系统会自动使用插值计算位置
|
||||
3. 如需精确位置,请调整 Game 窗口到已保存的分辨率
|
||||
|
||||
---
|
||||
|
||||
### Q2: 添加元素后图片不显示?
|
||||
|
||||
**原因:** 图片资源不是 Sprite 类型。
|
||||
|
||||
**解决方案:**
|
||||
1. 在 Project 窗口选中图片
|
||||
2. 在 Inspector 中设置 `Texture Type` 为 `Sprite (2D and UI)`
|
||||
3. 点击 Apply
|
||||
4. 重新添加元素
|
||||
|
||||
---
|
||||
|
||||
### Q3: 元素名称与数据不匹配?
|
||||
|
||||
**错误日志:**
|
||||
```
|
||||
[画报系统] Item_Poster_Full_A00001 在PictorialData中找不到匹配的数据
|
||||
```
|
||||
|
||||
**原因:** GameObject 名称与 JSON 数据中的 `itemName` 不一致。
|
||||
|
||||
**解决方案:**
|
||||
1. 在 Hierarchy 窗口检查 GameObject 名称
|
||||
2. 确保名称格式为 `Item_{图片名称}`
|
||||
3. 或在 JSON 文件中修改 `itemName` 与 GameObject 名称一致
|
||||
|
||||
---
|
||||
|
||||
### Q4: 分辨率变化后元素没有自动调整?
|
||||
|
||||
**检查项:**
|
||||
1. **运行时模式**:确保 `PictorialItem` 组件的 `Update()` 方法正常执行
|
||||
2. **编辑器模式**:确保 `PictorialBackground` 组件的 `Update()` 方法正常执行
|
||||
3. **日志输出**:查看 Console 是否有相关日志
|
||||
|
||||
**日志示例:**
|
||||
```
|
||||
[画报系统] 检测到背景尺寸变化: 1920x1080 -> 2560x1440
|
||||
[画报系统] 使用插值更新元素位置,成功更新 15/15 个元素
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Q5: 如何删除不需要的分辨率配置?
|
||||
|
||||
**步骤:**
|
||||
1. 在画报编辑器中找到"已保存的分辨率"列表
|
||||
2. 点击对应分辨率右侧的"删除"按钮
|
||||
3. 确认删除操作
|
||||
|
||||
**注意:** 删除分辨率配置会同时删除所有元素在该分辨率下的位置数据,此操作不可撤销!
|
||||
|
||||
---
|
||||
|
||||
### Q6: 元素文件名前缀如何使用?
|
||||
|
||||
**配置:**
|
||||
```
|
||||
元素文件名前缀: [Poster_Full]
|
||||
```
|
||||
|
||||
**效果:**
|
||||
1. 点击"选择图片"按钮
|
||||
2. 资源选择器自动打开
|
||||
3. 搜索框自动填入 `Poster_Full`
|
||||
4. 列表自动筛选显示匹配的图片
|
||||
|
||||
**好处:** 当项目资源很多时,快速定位目标图片,提高编辑效率。
|
||||
|
||||
---
|
||||
|
||||
### Q7: 如何备份画报数据?
|
||||
|
||||
**方案1:保存到版本控制**
|
||||
- 画报数据保存为 JSON 文件
|
||||
- 提交到 Git 等版本控制系统
|
||||
- 可追踪历史修改
|
||||
|
||||
**方案2:导出到其他位置**
|
||||
1. 点击"导出JSON"按钮
|
||||
2. 选择保存位置(项目外)
|
||||
3. 作为备份文件保存
|
||||
|
||||
---
|
||||
|
||||
### Q8: 画报元素太多,编辑卡顿怎么办?
|
||||
|
||||
**优化建议:**
|
||||
1. 减少不必要的日志输出(修改 `Debug.Log` 为条件输出)
|
||||
2. 增加分辨率检查间隔(修改 `CHECK_INTERVAL` 常量)
|
||||
3. 限制元素数量(建议单个画报不超过 50 个元素)
|
||||
4. 使用对象池管理元素(针对频繁创建销毁的场景)
|
||||
|
||||
---
|
||||
|
||||
## 技术支持
|
||||
|
||||
如遇到其他问题,请查看:
|
||||
- Unity Console 中的日志输出(搜索 `[画报系统]` 或 `[画报编辑器]`)
|
||||
- 源码文件:
|
||||
- `Assets/Code/Scripts/Framework/UI/Pictorial/PictorialBackground.cs`
|
||||
- `Assets/Code/Scripts/Framework/UI/Pictorial/PictorialItem.cs`
|
||||
- `Assets/Editor/Pictorial/PictorialEditorWindow.cs`
|
||||
|
||||
---
|
||||
|
||||
**文档版本:** 1.0
|
||||
**最后更新:** 2024-01-15
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c96d0764c2b049e4fa2a480b8cdd92fe
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue