加入了浮动小游戏功能和设置界面
运行时请手动修改运行库目录fdBrowser
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
[Header("Prefab基本信息")]
|
||||
public Image card_icon_image;
|
||||
public Text card_name_text;
|
||||
public Text authorName_text;
|
||||
public Text description_text;
|
||||
public Text _isOfficial_text;
|
||||
public Text source_text;
|
||||
public Text yyyy_mm_dd;
|
||||
|
||||
[Header("Optional clickable Button (auto-find if null)")]
|
||||
public Button clickButton;
|
||||
|
||||
// 存储对应 index.html 的本地路径(不含 file:// 前缀)
|
||||
private string indexFilePath;
|
||||
|
||||
// 给 loadLittleGamesPrefab 调用以填充文本和路径
|
||||
public void SetData(string indexPath, string cardName, string authorName, string description, string isOfficial, string source, string yyyyMmDd)
|
||||
{
|
||||
indexFilePath = indexPath;
|
||||
if (card_name_text != null) card_name_text.text = cardName ?? "";
|
||||
if (authorName_text != null) authorName_text.text = authorName ?? "";
|
||||
if (description_text != null) description_text.text = description ?? "";
|
||||
if (_isOfficial_text != null) _isOfficial_text.text = isOfficial ?? "";
|
||||
if (source_text != null) source_text.text = source ?? "";
|
||||
if (yyyy_mm_dd != null) yyyy_mm_dd.text = yyyyMmDd ?? "";
|
||||
|
||||
UnityEngine.Debug.Log($"game_card_Prefab.SetData: indexPath='{indexFilePath}', card_name='{cardName}', author='{authorName}', isOfficial='{isOfficial}', source='{source}'");
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// If no explicit Button assigned, try to find one on this GameObject or children
|
||||
if (clickButton == null)
|
||||
{
|
||||
clickButton = GetComponent<Button>();
|
||||
if (clickButton == null)
|
||||
clickButton = GetComponentInChildren<Button>(true);
|
||||
}
|
||||
|
||||
if (clickButton == null)
|
||||
{
|
||||
// Try to auto-add a Button to this GameObject so clicks are captured.
|
||||
// Ensure there's an Image component (Button requires Image for Raycast target)
|
||||
Image img = GetComponent<Image>();
|
||||
if (img == null)
|
||||
{
|
||||
img = gameObject.AddComponent<Image>();
|
||||
img.color = new Color(1, 1, 1, 0); // transparent
|
||||
}
|
||||
|
||||
clickButton = gameObject.AddComponent<Button>();
|
||||
UnityEngine.Debug.Log("game_card_Prefab.Awake: No Button found; added Image+Button to prefab at runtime to capture clicks.");
|
||||
}
|
||||
|
||||
// Check EventSystem presence
|
||||
if (EventSystem.current == null)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("game_card_Prefab.Awake: No EventSystem in scene. UI clicks and IPointerClickHandler won't work without an EventSystem.");
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (clickButton != null)
|
||||
{
|
||||
clickButton.onClick.AddListener(OnButtonClicked);
|
||||
UnityEngine.Debug.Log("game_card_Prefab: added onClick listener to Button");
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (clickButton != null)
|
||||
{
|
||||
clickButton.onClick.RemoveListener(OnButtonClicked);
|
||||
UnityEngine.Debug.Log("game_card_Prefab: removed onClick listener from Button");
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonClicked()
|
||||
{
|
||||
UnityEngine.Debug.Log($"game_card_Prefab.OnButtonClicked: indexPath='{indexFilePath}'");
|
||||
OpenIndexPath();
|
||||
}
|
||||
|
||||
// 点击时尝试通过 WebViewLauncher 打开对应的 index.html
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
UnityEngine.Debug.Log($"game_card_Prefab.OnPointerClick: indexPath='{indexFilePath}'");
|
||||
OpenIndexPath();
|
||||
}
|
||||
|
||||
void OpenIndexPath()
|
||||
{
|
||||
if (string.IsNullOrEmpty(indexFilePath))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("game_card_Prefab clicked but index path is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
// 优先使用 WebViewLauncher 单例
|
||||
if (WebViewLauncher.Instance != null)
|
||||
{
|
||||
UnityEngine.Debug.Log("Calling WebViewLauncher.OpenUrl with: " + indexFilePath);
|
||||
WebViewLauncher.Instance.OpenUrl(indexFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("WebViewLauncher instance not found. Attempting to start new launcher.");
|
||||
// 尝试查找场景中的 WebViewLauncher 或创建一个新的 GameObject
|
||||
var launcherObj = GameObject.FindObjectOfType<WebViewLauncher>();
|
||||
if (launcherObj != null)
|
||||
{
|
||||
UnityEngine.Debug.Log("Found launcher in scene, calling OpenUrl: " + indexFilePath);
|
||||
launcherObj.OpenUrl(indexFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a temporary launcher object to start webview
|
||||
UnityEngine.Debug.Log("Creating temporary WebViewLauncher and calling OpenUrl: " + indexFilePath);
|
||||
GameObject go = new GameObject("WebViewLauncher_Temp");
|
||||
var launcher = go.AddComponent<WebViewLauncher>();
|
||||
launcher.OpenUrl(indexFilePath);
|
||||
GameObject.DontDestroyOnLoad(go);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e862c8c48e4f8b49adae5e986da6e73
|
||||
@@ -0,0 +1,739 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &219047244547433570
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 872492842950718926}
|
||||
- component: {fileID: 7480212223569318349}
|
||||
- component: {fileID: 9193153990832272737}
|
||||
m_Layer: 5
|
||||
m_Name: author_name
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &872492842950718926
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 219047244547433570}
|
||||
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: 3566709735925945696}
|
||||
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: 10.717, y: 14.07}
|
||||
m_SizeDelta: {x: 252.359, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &7480212223569318349
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 219047244547433570}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &9193153990832272737
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 219047244547433570}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
|
||||
m_FontSize: 12
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 6
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: author_name
|
||||
--- !u!1 &964402434877421462
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 189438553718290088}
|
||||
- component: {fileID: 8767921256928017929}
|
||||
- component: {fileID: 5425439562977293950}
|
||||
m_Layer: 5
|
||||
m_Name: yyyyddmm
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &189438553718290088
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 964402434877421462}
|
||||
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: 3566709735925945696}
|
||||
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: 171.06035, y: -15.7}
|
||||
m_SizeDelta: {x: 38.41, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8767921256928017929
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 964402434877421462}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &5425439562977293950
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 964402434877421462}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: 775c674e81662c644b64550d2e8f74e0, type: 3}
|
||||
m_FontSize: 10
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 5
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'YYYY
|
||||
|
||||
MM
|
||||
|
||||
DD'
|
||||
--- !u!1 &2391360557458902149
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 604392950021451895}
|
||||
- component: {fileID: 5600536436187702497}
|
||||
- component: {fileID: 3389633104739560455}
|
||||
m_Layer: 5
|
||||
m_Name: card_name
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &604392950021451895
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2391360557458902149}
|
||||
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: 3566709735925945696}
|
||||
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: 15.512863, y: 20.5}
|
||||
m_SizeDelta: {x: 262.884, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &5600536436187702497
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2391360557458902149}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &3389633104739560455
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2391360557458902149}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
|
||||
m_FontSize: 20
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 2
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 3
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: CardNameHere
|
||||
--- !u!1 &3532408215758252597
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4583698199465520998}
|
||||
- component: {fileID: 301933785134177564}
|
||||
- component: {fileID: 6004099248657222439}
|
||||
m_Layer: 5
|
||||
m_Name: Image
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &4583698199465520998
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3532408215758252597}
|
||||
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: 3566709735925945696}
|
||||
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: -160, y: 0}
|
||||
m_SizeDelta: {x: 50, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &301933785134177564
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3532408215758252597}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6004099248657222439
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3532408215758252597}
|
||||
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: 4997328413415617422, guid: a8ff5cf9bafe9f544bfde136473da3cc, 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!1 &5110857998175197173
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2622440068852620012}
|
||||
- component: {fileID: 82439723018948691}
|
||||
- component: {fileID: 5166008895911254744}
|
||||
m_Layer: 5
|
||||
m_Name: _isOfficial
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2622440068852620012
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5110857998175197173}
|
||||
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: 3566709735925945696}
|
||||
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: 144.2521, y: 19.9}
|
||||
m_SizeDelta: {x: 94.529, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &82439723018948691
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5110857998175197173}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &5166008895911254744
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5110857998175197173}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
|
||||
m_FontSize: 12
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 5
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: _isOfficial
|
||||
--- !u!1 &5331475481345189989
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3566709735925945696}
|
||||
- component: {fileID: 3041038222081474245}
|
||||
- component: {fileID: 6180074520896239301}
|
||||
- component: {fileID: 3634709248270434128}
|
||||
m_Layer: 5
|
||||
m_Name: botton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3566709735925945696
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5331475481345189989}
|
||||
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:
|
||||
- {fileID: 4583698199465520998}
|
||||
- {fileID: 604392950021451895}
|
||||
- {fileID: 872492842950718926}
|
||||
- {fileID: 2019306417107768352}
|
||||
- {fileID: 2622440068852620012}
|
||||
- {fileID: 2138782682665805939}
|
||||
- {fileID: 189438553718290088}
|
||||
m_Father: {fileID: 9116228060429372210}
|
||||
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: 5.929, y: 0}
|
||||
m_SizeDelta: {x: 424.852, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &3041038222081474245
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5331475481345189989}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6180074520896239301
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5331475481345189989}
|
||||
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: 7f3b1220317607e44bbb8f0e1998044a, type: 3}
|
||||
m_Type: 1
|
||||
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!114 &3634709248270434128
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5331475481345189989}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 6180074520896239301}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &8844525127622122013
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2019306417107768352}
|
||||
- component: {fileID: 6796448552036844055}
|
||||
- component: {fileID: 4780041332280513338}
|
||||
m_Layer: 5
|
||||
m_Name: source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2019306417107768352
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8844525127622122013}
|
||||
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: 3566709735925945696}
|
||||
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: 158.28172, y: 16.64}
|
||||
m_SizeDelta: {x: 66.47, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6796448552036844055
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8844525127622122013}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &4780041332280513338
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8844525127622122013}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
|
||||
m_FontSize: 12
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 8
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: source
|
||||
--- !u!1 &8979588775758457773
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9116228060429372210}
|
||||
- component: {fileID: 1340434185471581111}
|
||||
m_Layer: 5
|
||||
m_Name: game_card_prefab
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &9116228060429372210
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8979588775758457773}
|
||||
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:
|
||||
- {fileID: 3566709735925945696}
|
||||
m_Father: {fileID: 0}
|
||||
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: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1340434185471581111
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8979588775758457773}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9e862c8c48e4f8b49adae5e986da6e73, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
card_icon_image: {fileID: 6004099248657222439}
|
||||
card_name_text: {fileID: 3389633104739560455}
|
||||
authorName_text: {fileID: 9193153990832272737}
|
||||
description_text: {fileID: 8118505406259206449}
|
||||
_isOfficial_text: {fileID: 5166008895911254744}
|
||||
source_text: {fileID: 4780041332280513338}
|
||||
yyyy_mm_dd: {fileID: 5425439562977293950}
|
||||
clickButton: {fileID: 0}
|
||||
--- !u!1 &9033496028734522550
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2138782682665805939}
|
||||
- component: {fileID: 3647945832167543742}
|
||||
- component: {fileID: 8118505406259206449}
|
||||
m_Layer: 5
|
||||
m_Name: description
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2138782682665805939
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9033496028734522550}
|
||||
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: 3566709735925945696}
|
||||
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: 10.130814, y: -15.7}
|
||||
m_SizeDelta: {x: 253.531, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &3647945832167543742
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9033496028734522550}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8118505406259206449
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9033496028734522550}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: 775c674e81662c644b64550d2e8f74e0, type: 3}
|
||||
m_FontSize: 15
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 3
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u7B80\u4ECB\u4E0D\u5F97\u8D85\u8FC71234567891011121314151617181920212223242526272829"
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6f011f2d2221db49a0f07a8cf5900ca
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,230 @@
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
public class loadLittleGamesPrefab : MonoBehaviour
|
||||
{
|
||||
[Header("Scroll Views")]
|
||||
public GameObject officialDocs_scrollView_content;
|
||||
public GameObject officialGames_scrollView_content;
|
||||
public GameObject thirdPartyGames_scrollView_content;
|
||||
|
||||
[Header("Prefab")]
|
||||
public GameObject littleGames_card_Prefab;
|
||||
|
||||
[Header("H5 Root Path (optional, leave empty to use WebViewLauncher settings)")]
|
||||
public string h5RootPath;
|
||||
|
||||
void Start()
|
||||
{
|
||||
LoadAllLittleGames();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在 WebViewLauncher 的 h5 目录下扫描 three categories 的所有子文件夹(递归一层),
|
||||
/// 找到含有 index.html 的目录(例如: ...\h5LG\_thirdPartyGames\kjb\index.html),
|
||||
/// 读取同目录下的 info.xml(如果存在),并把 prefab 实例化到对应的 content 中。
|
||||
///
|
||||
/// info.xml 示例格式(放在同目录下,编码 UTF-8):
|
||||
/// <?xml version="1.0" encoding="utf-8"?>
|
||||
/// <Info>
|
||||
/// <card_name>示例游戏名</card_name>
|
||||
/// <authorName>作者名</authorName>
|
||||
/// <description>这里是描述文本</description>
|
||||
/// <isOfficial>True</isOfficial>
|
||||
/// <source>来源信息</source>
|
||||
/// <yyyy_mm_dd>2025-12-23</yyyy_mm_dd>
|
||||
/// </Info>
|
||||
///
|
||||
/// 请保证节点名如上所示以便能被正确读取。
|
||||
/// </summary>
|
||||
public void LoadAllLittleGames()
|
||||
{
|
||||
string root = GetH5RootPath();
|
||||
if (string.IsNullOrEmpty(root) || !Directory.Exists(root))
|
||||
{
|
||||
Debug.LogWarning("H5 root path not found: " + root);
|
||||
return;
|
||||
}
|
||||
|
||||
// 目标一级子目录名称(与 WebViewLauncher 中保持一致)
|
||||
string[] categories = { "_officialDocs", "_officialGames", "_thirdPartyGames" };
|
||||
|
||||
foreach (string cat in categories)
|
||||
{
|
||||
string catPath = Path.Combine(root, cat);
|
||||
if (!Directory.Exists(catPath))
|
||||
continue;
|
||||
|
||||
// 遍历 catPath 下的第一层子目录,检查是否含有 index.html
|
||||
string[] subdirs = Directory.GetDirectories(catPath);
|
||||
foreach (string subdir in subdirs)
|
||||
{
|
||||
string indexPath = Path.Combine(subdir, "index.html");
|
||||
if (!File.Exists(indexPath))
|
||||
{
|
||||
// 也可能 index.html 在更深一层,但按照约定通常是 subdir/index.html
|
||||
continue;
|
||||
}
|
||||
|
||||
// 读取 info.xml(可选)
|
||||
string infoXmlPath = Path.Combine(subdir, "info.xml");
|
||||
var meta = ReadInfoXml(infoXmlPath);
|
||||
|
||||
// 根据分类选择目标 content
|
||||
GameObject targetContent = GetContentByCategory(cat);
|
||||
if (targetContent == null || littleGames_card_Prefab == null)
|
||||
{
|
||||
Debug.LogWarning("Missing prefab or content for category: " + cat);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 实例化 prefab
|
||||
GameObject go = Instantiate(littleGames_card_Prefab, targetContent.transform);
|
||||
|
||||
// 设置数据(indexPath 使用本地文件绝对路径)
|
||||
string absIndexPath = indexPath; // 使用绝对路径,WebViewLauncher.OpenUrl 会添加 file://
|
||||
var prefabComp = go.GetComponent<game_card_Prefab>();
|
||||
if (prefabComp != null)
|
||||
{
|
||||
// 若来自官方分类,覆盖 isOfficial 与 source 字段为固定值
|
||||
string finalIsOfficial = meta.GetValueOrDefault("isOfficial");
|
||||
string finalSource = meta.GetValueOrDefault("source");
|
||||
|
||||
if (cat == "_officialDocs" || cat == "_officialGames")
|
||||
{
|
||||
finalIsOfficial = "官方";
|
||||
finalSource = "小游戏DLC";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 非官方分类统一标记为第三方来源
|
||||
finalIsOfficial = "第三方来源";
|
||||
// 若 info.xml 没有 source,则可以保留原值或设置默认,这里若无则为空
|
||||
if (string.IsNullOrEmpty(finalSource))
|
||||
finalSource = "";
|
||||
}
|
||||
|
||||
// 格式化日期为 yyyy\nmm\ndd 的形式
|
||||
string rawDate = meta.GetValueOrDefault("yyyy_mm_dd");
|
||||
string formattedDate = FormatDateWithNewlines(rawDate);
|
||||
|
||||
prefabComp.SetData(absIndexPath,
|
||||
meta.GetValueOrDefault("card_name"),
|
||||
meta.GetValueOrDefault("authorName"),
|
||||
meta.GetValueOrDefault("description"),
|
||||
finalIsOfficial,
|
||||
finalSource,
|
||||
formattedDate
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string GetH5RootPath()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(h5RootPath) && Directory.Exists(h5RootPath))
|
||||
return h5RootPath;
|
||||
|
||||
// 从 WebViewLauncher 获取编辑器路径
|
||||
var w = GameObject.FindObjectOfType<WebViewLauncher>();
|
||||
if (w != null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return w.h5EditorPath;
|
||||
#else
|
||||
return Path.Combine(Application.streamingAssetsPath, "h5LG");
|
||||
#endif
|
||||
}
|
||||
|
||||
// 作为回退,使用 StreamingAssets/h5LG
|
||||
return Path.Combine(Application.streamingAssetsPath, "h5LG");
|
||||
}
|
||||
|
||||
GameObject GetContentByCategory(string categoryName)
|
||||
{
|
||||
switch (categoryName)
|
||||
{
|
||||
case "_officialDocs": return officialDocs_scrollView_content;
|
||||
case "_officialGames": return officialGames_scrollView_content;
|
||||
case "_thirdPartyGames": return thirdPartyGames_scrollView_content;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, string> ReadInfoXml(string xmlPath)
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
if (string.IsNullOrEmpty(xmlPath) || !File.Exists(xmlPath))
|
||||
return dict;
|
||||
|
||||
try
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
doc.Load(xmlPath);
|
||||
var root = doc.DocumentElement;
|
||||
if (root == null)
|
||||
return dict;
|
||||
|
||||
// 读取预定义字段
|
||||
string[] keys = { "card_name", "authorName", "description", "isOfficial", "source", "yyyy_mm_dd" };
|
||||
foreach (var k in keys)
|
||||
{
|
||||
var node = root.SelectSingleNode(k);
|
||||
if (node != null)
|
||||
dict[k] = node.InnerText;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogWarning("Failed to read info.xml: " + xmlPath + " error: " + e.Message);
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
// 将日期文本尝试解析成 yyyy\nmm\ndd 格式,若解析失败则做简单替换(支持 2025-12-23, 2025/12/23, 2025_12_23, 20251223 等)
|
||||
string FormatDateWithNewlines(string raw)
|
||||
{
|
||||
if (string.IsNullOrEmpty(raw))
|
||||
return "";
|
||||
|
||||
// 尝试按常见分隔符拆分
|
||||
char[] seps = new char[] { '-', '/', '_', ' ' };
|
||||
var parts = raw.Split(seps, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 3)
|
||||
{
|
||||
return parts[0] + "\n" + parts[1] + "\n" + parts[2];
|
||||
}
|
||||
|
||||
// 尝试连续数字 8 位
|
||||
var digits = System.Text.RegularExpressions.Regex.Replace(raw, "\\D", "");
|
||||
if (digits.Length == 8)
|
||||
{
|
||||
string y = digits.Substring(0, 4);
|
||||
string m = digits.Substring(4, 2);
|
||||
string d = digits.Substring(6, 2);
|
||||
return y + "\n" + m + "\n" + d;
|
||||
}
|
||||
|
||||
// 回退:尝试用第一个 4 位作为年,接下来的两位为月,之后为日
|
||||
if (digits.Length >= 6)
|
||||
{
|
||||
string y = digits.Substring(0, 4);
|
||||
string m = digits.Length >= 6 ? digits.Substring(4, 2) : "";
|
||||
string d = digits.Length >= 8 ? digits.Substring(6, 2) : "";
|
||||
return y + "\n" + m + "\n" + d;
|
||||
}
|
||||
|
||||
// 最后回退直接把原文本按字符换行(有限长度)
|
||||
return raw.Replace("-", "\n").Replace("/", "\n").Replace("_", "\n");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d009618c8f589b49a50efcd92597ce2
|
||||
Reference in New Issue
Block a user